-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align tests to heroku/java tests (#79)
* Align tests to heroku/java tests * Add java-properties gem * Reduce amount of split test processes When there are less tests than processes, some processes will not run any tests. Togehter with `config.fail_if_no_examples = true`, this results in always failing test suites.
- Loading branch information
Showing
11 changed files
with
163 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ gem 'heroku_hatchet' | |
gem 'rspec-retry' | ||
gem 'rspec-expectations' | ||
gem 'parallel_split_test' | ||
gem 'java-properties' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
--- | ||
- - spec/fixtures/repos/grails/grails3-example | ||
- - test/spec/fixtures/repos/grails/grails3-example | ||
- c47a582e5b61dd069d17b7178697472d90fbc1bc | ||
- - spec/fixtures/repos/kotlin/gradle-kotlin-dsl-sample | ||
- - test/spec/fixtures/repos/kotlin/gradle-kotlin-dsl-sample | ||
- 57c0c86437ac17fdf8a416845eb8a34c014305bf | ||
- - spec/fixtures/repos/kotlin/spring-boot-gradle-kotlin-dsl | ||
- - test/spec/fixtures/repos/kotlin/spring-boot-gradle-kotlin-dsl | ||
- cd66c342c01377325eed141465586e473dc6e41f | ||
- - spec/fixtures/repos/ratpack/example-ratpack-gradle-groovy-app | ||
- - test/spec/fixtures/repos/ratpack/example-ratpack-gradle-groovy-app | ||
- 13c508d77f6ca910d4d1fd71586d3b1016a4faa0 | ||
- - spec/fixtures/repos/ratpack/gradle-getting-started | ||
- - test/spec/fixtures/repos/ratpack/gradle-getting-started | ||
- e73be20fda0ba4a0e5d972638acdb76eff1d66c2 | ||
- - spec/fixtures/repos/spring/spring-boot-gradle | ||
- - test/spec/fixtures/repos/spring/spring-boot-gradle | ||
- cc13b4b70fe49a8cae7c0ea6691dcf92d4a7b30e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
require_relative 'spec_helper' | ||
|
||
describe "Gradle" do | ||
|
||
before(:each) do | ||
init_app(app) | ||
end | ||
|
||
context "on JDK 8" do | ||
let(:app) { Hatchet::Runner.new("gradle-getting-started") } | ||
let(:jdk_version) { "1.8" } | ||
|
||
describe "Gradle" do | ||
context "on JDK #{DEFAULT_OPENJDK_VERSION}" do | ||
it "deploys successfully" do | ||
app.deploy do |app| | ||
expect(app.output).not_to include("Ratpack detected") | ||
expect(app.output).to include("Spring Boot detected") | ||
expect(app.output).not_to include("Spring Boot and Webapp Runner detected") | ||
expect(app.output).to include("Building Gradle app") | ||
expect(app.output).not_to include("executing ./gradlew stage") | ||
expect(app.output).to include("executing ./gradlew build -x test") | ||
expect(app.output).to include("BUILD SUCCESSFUL") | ||
new_default_hatchet_runner("gradle-getting-started").tap do |app| | ||
app.before_deploy do | ||
set_java_version(DEFAULT_OPENJDK_VERSION) | ||
end | ||
|
||
app.deploy do | ||
expect(app.output).not_to include("Ratpack detected") | ||
expect(app.output).to include("Spring Boot detected") | ||
expect(app.output).not_to include("Spring Boot and Webapp Runner detected") | ||
expect(app.output).to include("Building Gradle app") | ||
expect(app.output).not_to include("executing ./gradlew stage") | ||
expect(app.output).to include("executing ./gradlew build -x test") | ||
expect(app.output).to include("BUILD SUCCESSFUL") | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,64 @@ | ||
require 'rspec/core' | ||
require 'hatchet' | ||
require 'fileutils' | ||
require 'hatchet' | ||
require 'rspec/retry' | ||
require 'date' | ||
require 'tmpdir' | ||
require "rspec/core" | ||
require "rspec/retry" | ||
require "hatchet" | ||
require "java-properties" | ||
|
||
ENV['RACK_ENV'] = 'test' | ||
DEFAULT_OPENJDK_VERSION="1.8" | ||
|
||
RSpec.configure do |config| | ||
config.filter_run focused: true unless ENV['CI'] | ||
config.run_all_when_everything_filtered = true | ||
config.alias_example_to :fit, focused: true | ||
config.fail_if_no_examples = true | ||
config.full_backtrace = true | ||
config.verbose_retry = true # show retry status in spec process | ||
config.default_retry_count = 2 if ENV['CI'] # retry all tests that fail again | ||
# rspec-retry | ||
config.verbose_retry = true | ||
config.default_retry_count = 2 if ENV["CI"] | ||
end | ||
|
||
def new_default_hatchet_runner(*args, **kwargs) | ||
kwargs[:stack] ||= ENV["DEFAULT_APP_STACK"] | ||
kwargs[:config] ||= {} | ||
|
||
config.expect_with :rspec do |c| | ||
c.syntax = :expect | ||
ENV.keys.each do |key| | ||
if key.start_with?("DEFAULT_APP_CONFIG_") | ||
kwargs[:config][key.delete_prefix("DEFAULT_APP_CONFIG_")] ||= ENV[key] | ||
end | ||
end | ||
#config.mock_with :none | ||
|
||
Hatchet::Runner.new(*args, **kwargs) | ||
end | ||
|
||
def git_repo | ||
"https://github.com/heroku/heroku-buildpack-gradle.git" | ||
def set_java_version(version_string) | ||
set_system_properties_key("java.runtime.version", version_string) | ||
end | ||
|
||
def init_app(app, stack="heroku-16") | ||
app.setup! | ||
app.platform_api.app.update(app.name, {"build_stack" => ENV["HEROKU_TEST_STACK"] || stack}) | ||
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']) | ||
end | ||
def set_maven_version(version_string) | ||
set_system_properties_key("maven.version", version_string) | ||
end | ||
|
||
def add_database(app, heroku) | ||
Hatchet::RETRIES.times.retry do | ||
heroku.post_addon(app.name, 'heroku-postgresql') | ||
_, value = heroku.get_config_vars(app.name).body.detect {|key, value| key.match(/HEROKU_POSTGRESQL_[A-Z]+_URL/) } | ||
heroku.put_config_vars(app.name, 'DATABASE_URL' => value) | ||
def set_system_properties_key(key, value) | ||
properties = {} | ||
|
||
if File.file?("system.properties") | ||
properties = JavaProperties.load("system.properties") | ||
end | ||
end | ||
|
||
def successful_body(app, options = {}) | ||
retry_limit = options[:retry_limit] || 50 | ||
path = options[:path] ? "/#{options[:path]}" : '' | ||
Excon.get("http://#{app.name}.herokuapp.com#{path}", :idempotent => true, :expects => 200, :retry_limit => retry_limit).body | ||
properties[key.to_sym] = value | ||
JavaProperties.write(properties, "system.properties") | ||
end | ||
|
||
def create_file_with_size_in(size, dir) | ||
name = File.join(dir, SecureRandom.hex(16)) | ||
File.open(name, 'w') {|f| f.print([ 1 ].pack("C") * size) } | ||
Pathname.new name | ||
def write_to_procfile(content) | ||
File.open("Procfile", "w") do |file| | ||
file.write(content) | ||
end | ||
end | ||
|
||
def set_java_version(d, v) | ||
Dir.chdir(d) do | ||
File.open('system.properties', 'w') do |f| | ||
f.puts "java.runtime.version=#{v}" | ||
end | ||
`git add system.properties` | ||
`git commit -am "setting jdk version"` | ||
end | ||
def run(cmd) | ||
out = `#{cmd}` | ||
raise "Command #{cmd} failed with output #{out}" unless $?.success? | ||
out | ||
end | ||
|
||
def set_gradle_versions(gradle_version) | ||
propsFile = "gradle/wrapper/gradle-wrapper.properties" | ||
File.open(propsFile, 'w') do |f| | ||
f.puts <<-EOF | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-#{gradle_version}-bin.zip | ||
EOF | ||
end | ||
`git add #{propsFile}` | ||
`git commit -m "setting gradle version"` | ||
def http_get(app, options = {}) | ||
retry_limit = options[:retry_limit] || 50 | ||
path = options[:path] ? "/#{options[:path]}" : "" | ||
Excon.get("https://#{app.name}.herokuapp.com#{path}", :idempotent => true, :expects => 200, :retry_limit => retry_limit).body | ||
end |
Oops, something went wrong.