Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup integration tests #155

Merged
merged 4 commits into from
Oct 21, 2020
Merged

Cleanup integration tests #155

merged 4 commits into from
Oct 21, 2020

Conversation

Malax
Copy link
Member

@Malax Malax commented Oct 21, 2020

First pass at cleaning up the integration test suite. The main goal was to solve concurrency issues, but the scope expanded a bit while refactoring:

  • Removes usage of app.directory, fixing concurrency issues.
  • Better Java properties file handling by using java-properties gem.
  • Exit codes of shell commands are now properly checked instead of silently ignored.
  • Removing old code that is no longer required. This includes some rspec setup code and workarounds of former Hatchet issues.
  • Remove magic strings for Java versions.
  • Simplify test execution by removing many layers of indirection. Those might also have caused concurrency issues.
  • Better test descriptions.
  • Overall cleaner code.

There is still work to do in terms of what is tested and how - we're testing the same things as before. A proper refactoring across the JVM buildpack testing landscape is in the works.

Closes W-8239355

@Malax Malax added the skip changelog Pull requests that do not require changes to the CHANGELOG file label Oct 21, 2020
@Malax Malax requested a review from a team October 21, 2020 13:50
@Malax Malax marked this pull request as ready for review October 21, 2020 13:57
@Malax Malax requested a review from schneems October 21, 2020 14:31
unless ENV['JVM_COMMON_BUILDPACK'].nil? or ENV['JVM_COMMON_BUILDPACK'].empty?
app.set_config("JVM_COMMON_BUILDPACK" => ENV['JVM_COMMON_BUILDPACK'])
expect(app.get_config['JVM_COMMON_BUILDPACK']).to eq(ENV['JVM_COMMON_BUILDPACK'])
def set_system_properties_key(key, value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When setting keys and values one thing I like to do is make my input a hash so I can do something like this

  set_system_properties("maven.version" => version_string)

And you can also set multiple values at the same time:

set_system_properties(
  "maven.version" => version_string,
  "java.runtime.version" => "11.whatever",
)

You could implement this function like this if you desired:

def set_system_properties(set_properties = {})
  if File.file?("system.properties")
    properties = JavaProperties.load("system.properties")
  else
    properties = {}
  end

  set_properties.each do |key, value|
    properties[key.to_sym] = value
  end

  JavaProperties.write(properties, "system.properties")
end

c.syntax = :expect
end
#config.mock_with :none
def set_java_version(version_string)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From an API perspective, I feel like I want a single set_version function that does both java and maven something like:

def set_version(maven: nil, java: nil)
     set_system_properties_key("java.runtime.version", java)  if java
     set_system_properties_key("maven.version", java)  if maven
end

schneems
schneems previously approved these changes Oct 21, 2020
hatchet.lock Show resolved Hide resolved
test/spec/java_spec.rb Outdated Show resolved Hide resolved
@Malax Malax merged commit 30314ef into main Oct 21, 2020
@Malax Malax deleted the malax/cleanup-integration-tests branch October 21, 2020 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Pull requests that do not require changes to the CHANGELOG file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants