diff --git a/Gemfile b/Gemfile index 0dd811c1..abe42162 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,4 @@ gem 'heroku_hatchet' gem 'rspec-retry' gem 'rspec-expectations' gem 'parallel_split_test' +gem 'java-properties' diff --git a/Gemfile.lock b/Gemfile.lock index d41366f6..02099a21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,6 +15,7 @@ GEM rrrretry (~> 1) thor (~> 1) threaded (~> 0) + java-properties (0.2.1) moneta (1.0.0) multi_json (1.15.0) parallel (1.19.2) @@ -50,6 +51,7 @@ PLATFORMS DEPENDENCIES heroku_hatchet + java-properties parallel_split_test rspec-expectations rspec-retry diff --git a/hatchet.lock b/hatchet.lock index 60fb7ffa..2122998e 100644 --- a/hatchet.lock +++ b/hatchet.lock @@ -1,17 +1,17 @@ --- -- - spec/fixtures/repos/db/java-apache-dbcp-sample +- - test/spec/fixtures/repos/db/java-apache-dbcp-sample - bc8ef681cf36bf3d78dd94ea514e6d26c649bbb1 -- - spec/fixtures/repos/java/java-servlets-sample +- - test/spec/fixtures/repos/java/java-servlets-sample - 1cc2843067197d939a1218f1bbe63f5ed28c6111 -- - spec/fixtures/repos/java/korvan +- - test/spec/fixtures/repos/java/korvan - 1a99202ecc10f9a27ad3fedb30403b3f4bcb4750 -- - spec/fixtures/repos/java/libpng-test +- - test/spec/fixtures/repos/java/libpng-test - 2afd98d3a953fd49f9a2f77380a639ae3091ec98 -- - spec/fixtures/repos/java/maven-polyglot +- - test/spec/fixtures/repos/java/maven-polyglot - ecab985c6fa8678b69cc6764f939fd76a9de70ee -- - spec/fixtures/repos/java/webapp-runner-sample - - 493b385f3621d78e150ef12e2ac5362381e2c085 -- - spec/fixtures/repos/spring/spring-boot-executable +- - test/spec/fixtures/repos/java/webapp-runner-sample + - 02b128a87db6df7776baafdcb9a69504e4a41a58 +- - test/spec/fixtures/repos/spring/spring-boot-executable - e10d57ce128ad43225b2e0c6c3a0c0d0aa71ff9e -- - spec/fixtures/repos/spring/spring-boot-webapp-runner +- - test/spec/fixtures/repos/spring/spring-boot-webapp-runner - dd3ec06e76b562bd3734ad5dc576b416ff1559ea diff --git a/test/spec/agent_spec.rb b/test/spec/agent_spec.rb index e229aadc..d1a33b71 100644 --- a/test/spec/agent_spec.rb +++ b/test/spec/agent_spec.rb @@ -1,48 +1,29 @@ -require_relative 'spec_helper' +require_relative "spec_helper" -describe "JavaAgent" do +describe "Heroku's Java buildpack" do + context "using OpenJDK #{DEFAULT_OPENJDK_VERSION}" do + it "supports heroku-javaagent" do + Hatchet::Runner.new("webapp-runner-sample", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) - %w{1.8}.each do |version| - context "on #{version}" do - let(:app) { @app } - - before(:all) do - @app = Hatchet::Runner.new("webapp-runner-sample") - init_app(@app) - javaagent="heroku-javaagent-2.0.jar" - Dir.chdir(@app.directory) do - `curl --silent -O -L https://repo1.maven.org/maven2/com/heroku/agent/heroku-javaagent/2.0/#{javaagent}` - `git add #{javaagent}` - - # edit the procfile - File.open('Procfile', 'w') do |f| - f.puts <<-EOF -web: java $JAVA_OPTS -javaagent:#{javaagent}=stdout=true,lxmem=true -jar target/dependency/webapp-runner.jar --port $PORT target/*.war -EOF - end - `git add Procfile` - `git commit -m "adding java agent"` + java_agent_filename="heroku-javaagent-2.0.jar" + run("curl --silent -O -L https://repo1.maven.org/maven2/com/heroku/agent/heroku-javaagent/2.0/#{java_agent_filename}") + write_to_procfile("web: java $JAVA_OPTS -javaagent:#{java_agent_filename}=stdout=true,lxmem=true -jar target/dependency/webapp-runner.jar --port $PORT target/*.war") end - @app.deploy - end - after(:all) do - @app.teardown! - end + app.deploy do + expect(app.output).to include("BUILD SUCCESS") + expect(http_get(app)).to eq("Hello from Java!") - it "deploys successfully" do - expect(app.output).to include("BUILD SUCCESS") - sleep(10) # :( for the logs really - expect(successful_body(app)).to eq("Hello from Java!") - expect(app).to be_deployed - end + # We need to wait a moment for the logs to show up + sleep(10) - it "logs memory usage", :retry => 10, :retry_wait => 5 do - logs = `heroku logs -n 2000 -a #{app.name}` - expect(logs). - to include("measure.mem.jvm.heap.used="). - and include("measure.mem.jvm.nonheap.used="). - and include("measure.threads.jvm.total=") + expect(run("heroku logs -n 2000 -a #{app.name}")) + .to include("measure.mem.jvm.heap.used=") + .and include("measure.mem.jvm.nonheap.used=") + .and include("measure.threads.jvm.total=") + end end end end diff --git a/test/spec/db_spec.rb b/test/spec/db_spec.rb index efbd053a..dc5008e9 100644 --- a/test/spec/db_spec.rb +++ b/test/spec/db_spec.rb @@ -1,25 +1,18 @@ -require_relative 'spec_helper' +require_relative "spec_helper" -describe "Java" do - before(:each) do - set_java_version(app.directory, jdk_version) - init_app(app) - end +describe "Heroku's Java buildpack" do + context "using OpenJDK #{DEFAULT_OPENJDK_VERSION}" do + it "should use connection pool" do + Hatchet::Runner.new("java-apache-dbcp-sample", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) + end - %w{1.8}.each do |version| - context "on jdk-#{version}" do - let(:app) { Hatchet::Runner.new("java-apache-dbcp-sample") } - let(:jdk_version) { version } - it "should use connection pool" do - app.deploy do |app| - expect(app.output).to include("Installing JDK #{jdk_version}") + app.deploy do + expect(app.output).to include("Installing JDK #{DEFAULT_OPENJDK_VERSION}") expect(app.output).to include("Installing Maven") - expect(app.output).not_to include("BUILD FAILURE") expect(app.output).to include("BUILD SUCCESS") - - expect(successful_body(app, :path => "db")).to match("Read from DB:") - - expect(app).to be_deployed + expect(http_get(app, :path => "db")).to match("Read from DB:") end end end diff --git a/test/spec/java_spec.rb b/test/spec/java_spec.rb index 75c9ab70..13bc4e90 100644 --- a/test/spec/java_spec.rb +++ b/test/spec/java_spec.rb @@ -1,126 +1,120 @@ -require_relative 'spec_helper' +require_relative "spec_helper" -describe "Java" do - - def expect_successful_maven(app, jdk_version) - expect(app.output).to include("Installing JDK #{jdk_version}") - expect(app.output).not_to include("BUILD FAILURE") - expect(app.output).to include("BUILD SUCCESS") - end - - ["1.7", "1.8", "11"].each do |jdk_version| - context "on jdk-#{jdk_version}" do - it "should reinstall maven" do +describe "Heroku's Java buildpack" do + OPENJDK_VERSIONS.each do |openjdk_version| + context "using OpenJDK #{openjdk_version}" do + it "should not reinstall Maven" do Hatchet::Runner.new("java-servlets-sample", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| app.before_deploy do - set_java_version(Dir.pwd, jdk_version) + set_java_version(openjdk_version) end - app.deploy do |app| - expect_successful_maven(app, jdk_version) + app.deploy do + expect(app.output).to include("Installing JDK #{openjdk_version}") expect(app.output).to include("BUILD SUCCESS") - expect(successful_body(app)).to eq("Hello from Java!") + # Commit ed358d63b384bc7c8cf96be61ada768f4cc55a19 on the example app added Maven Wrapper to + # the project, bypassing Maven installation entirely. + # expect(app.output).to include("Installing Maven") + expect(app.output).not_to include("BUILD FAILURE") + expect(http_get(app)).to eq("Hello from Java!") app.commit! app.push! - expect_successful_maven(app, jdk_version) - expect(app.output).not_to include("Installing Maven") + expect(app.output).to include("Installing JDK #{openjdk_version}") expect(app.output).to include("BUILD SUCCESS") - - expect(successful_body(app)).to eq("Hello from Java!") - - expect(app.run("env", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption }})). # work around a CLI bug that doesn't allow --exit-code when invoking a process type via "heroku run" - to include(%q{DATABASE_URL}) + expect(app.output).not_to include("BUILD FAILURE") + expect(app.output).not_to include("Installing Maven") + expect(http_get(app)).to eq("Hello from Java!") end end end - end - end - - context "korvan" do - ["1.8", "11", "13", "15"].each do |jdk_version| - context "on jdk-#{jdk_version}" do - it "runs commands" do - Hatchet::Runner.new("korvan", stack: ENV["HEROKU_TEST_STACK"], run_multi: true).tap do |app| - app.before_deploy do - set_java_version(Dir.pwd, jdk_version) - end - app.deploy do |app| - expect_successful_maven(app, jdk_version) + it "builds and executes Korvan test commands successfully" do + Hatchet::Runner.new("korvan", stack: ENV["HEROKU_TEST_STACK"], run_multi: true).tap do |app| + app.before_deploy do + set_java_version(openjdk_version) + end - expect(successful_body(app)).to eq("/1") + app.deploy do + expect(app.output).to include("Installing JDK #{openjdk_version}") + expect(app.output).to include("BUILD SUCCESS") + expect(app.output).not_to include("BUILD FAILURE") + expect(http_get(app)).to eq("/1") - expect(app.run('echo $JAVA_OPTS')). - to include(%q{-Xmx300m -Xss512k}) + app.run_multi("echo $JAVA_OPTS") do |out, status| + expect(status.success?).to be_truthy + expect(out).to include("-Xmx300m -Xss512k") + end - expect(app.run("env", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption }})). # work around a CLI bug that doesn't allow --exit-code when invoking a process type via "heroku run" - not_to include(%q{DATABASE_URL}) + app.run_multi("env") do |out, status| + expect(status.success?).to be_truthy + expect(out).not_to include("DATABASE_URL") + end - expect(app.run("jce", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption }})). # work around a CLI bug that doesn't allow --exit-code when invoking a process type via "heroku run" - to include(%q{Encrypting, "Test"}). - and include(%q{Decrypted: Test}) + app.run_multi("java -cp target/app.jar JCE") do |out, status| + expect(status.success?).to be_truthy + expect(out) + .to include("Encrypting, \"Test\"") + .and include("Decrypted: Test") + end - expect(app.run("netpatch", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption }})). # work around a CLI bug that doesn't allow --exit-code when invoking a process type via "heroku run" - to include(%q{name:eth0 (eth0)}). - and include(%q{name:lo (lo)}) + app.run_multi("java -cp target/app.jar NetPatch") do |out, status| + expect(status.success?).to be_truthy + expect(out) + .to include("name:eth0 (eth0)") + .and include("name:lo (lo)") + end - expect(app.run("https", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption }})). # work around a CLI bug that doesn't allow --exit-code when invoking a process type via "heroku run" - to include("Successfully invoked HTTPS service."). - and match(%r{"X-Forwarded-Proto(col)?":\s?"https"}) + app.run_multi("java -cp target/app.jar Https") do |out, status| + expect(status.success?).to be_truthy + expect(out) + .to include("Successfully invoked HTTPS service.") + .and match(%r{"X-Forwarded-Proto(col)?":\s?"https"}) + end - # JDK 9, 10, 11 and beyond do not have the jre/lib/ext dir where we drop the pgconfig.jar - if jdk_version.match(/^(1\.7|1\.8|7|8)$/) - expect(app.run("pgssl", { :heroku => { "exit-code" => Hatchet::App::SkipDefaultOption }})). # work around a CLI bug that doesn't allow --exit-code when invoking a process type via "heroku run" - to include("sslmode: require") + # OpenJDK versions > 9 do not have the jre/lib/ext directory where we drop the pgconfig.jar + if openjdk_version.match(%r{^(1\.7|1\.8)$}) + app.run_multi("java -cp target/app.jar PostgresSSLTest") do |out, status| + expect(status.success?).to be_truthy + expect(out).to include("sslmode: require") end end end end end - end - end - - %w{1.7 1.8}.each do |jdk_version| - context "#{jdk_version} with webapp-runner" do - context "and expanded war" do - it "expands war", :retry => 3, :retry_wait => 5 do - Hatchet::Runner.new("webapp-runner-sample").tap do |app| - app.before_deploy do - set_java_version(Dir.pwd, jdk_version) - - File.open('Procfile', 'w') do |f| - f.puts <<-EOF - web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --expand-war --port $PORT target/*.war - EOF - end - `git commit -am "adding --expand-war to Procfile"` - end - app.deploy - expect_successful_maven(app, jdk_version) - expect(app.output).to match(%r{Building war: /tmp/.*/target/.*.war}) - expect(app.output).not_to match(%r{Building jar: /tmp/.*/target/.*.jar}) + it "work correctly when libpng dependent features are used" do + Hatchet::Runner.new("libpng-test", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(openjdk_version) + end - expect(successful_body(app)).to eq("Hello from Java!") - end + app.deploy do + expect(app.output).to include("Installing JDK #{openjdk_version}") + expect(app.output).to include("BUILD SUCCESS") + expect(app.output).not_to include("BUILD FAILURE") + expect(http_get(app)).to eq("All Good!!!") end end end - end - %w{1.8 11 13 15}.each do |jdk_version| - context "#{jdk_version} libpng test" do - it "returns a successful response", :retry => 3, :retry_wait => 5 do - Hatchet::Runner.new("libpng-test").tap do |app| + it "works correctly with --expand-war option on webapp-runner" do + Hatchet::Runner.new("webapp-runner-sample").tap do |app| app.before_deploy do - set_java_version(Dir.pwd, jdk_version) + set_java_version(openjdk_version) + write_to_procfile("web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --expand-war --port $PORT target/*.war") end - app.deploy do |app| - expect_successful_maven(app, jdk_version) - expect(successful_body(app)).to eq("All Good!!!") + app.deploy do + expect(app.output).to include("Installing JDK #{openjdk_version}") + expect(app.output).to include("BUILD SUCCESS") + expect(app.output).not_to include("BUILD FAILURE") + + expect(app.output).to match(%r{Building war: /tmp/.*/target/.*.war}) + expect(app.output).not_to match(%r{Building jar: /tmp/.*/target/.*.jar}) + + expect(http_get(app)).to eq("Hello from Java!") end end end diff --git a/test/spec/maven_spec.rb b/test/spec/maven_spec.rb index cf9f9835..bb009c58 100644 --- a/test/spec/maven_spec.rb +++ b/test/spec/maven_spec.rb @@ -1,55 +1,46 @@ -require_relative 'spec_helper' - -describe "Maven" do - - context "polyglot" do - let(:app) { Hatchet::Runner.new("maven-polyglot") } - let(:jdk_version) { "1.8" } - it "detects and deploys" do - app.deploy do |app| - expect(app.output).to include("Installing JDK #{jdk_version}") - expect(app.output).to include(".polyglot.pom.yaml") - expect(app.output).not_to include("BUILD FAILURE") - expect(app.output).to include("BUILD SUCCESS") - expect(successful_body(app)).to eq("Hello from Java!") +require_relative "spec_helper" + +describe "Heroku's Java buildpack" do + context "using OpenJDK #{DEFAULT_OPENJDK_VERSION}" do + it "supports Maven polyglot" do + Hatchet::Runner.new("maven-polyglot", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) + end + + app.deploy do + expect(app.output).to include("Installing JDK #{DEFAULT_OPENJDK_VERSION}") + expect(app.output).to include(".polyglot.pom.yaml") + expect(app.output).not_to include("BUILD FAILURE") + expect(app.output).to include("BUILD SUCCESS") + expect(http_get(app)).to eq("Hello from Java!") + end end end - end - - context "on jdk-1.8" do - let(:app) { Hatchet::Runner.new("java-servlets-sample") } - let(:jdk_version) { "1.8" } - - it "should upgrade and downgrade successfully" do - Dir.chdir(app.directory) do - set_java_and_maven_versions(jdk_version, "3.2.5") - end - - app.deploy do |app| - expect(app.output).to include("Installing Maven 3.2.5") - expect(app.output).to include("BUILD SUCCESS") - expect(successful_body(app)).to eq("Hello from Java!") - - set_java_and_maven_versions(jdk_version, "3.6.2") - - app.push! - expect(app.output).to include("Installing Maven 3.6.2") - expect(app.output).to include("BUILD SUCCESS") - expect(successful_body(app)).to eq("Hello from Java!") - - set_java_and_maven_versions(jdk_version, "3.5.4") - - app.push! - expect(app.output).to include("Installing Maven 3.5.4") - expect(app.output).to include("BUILD SUCCESS") - expect(successful_body(app)).to eq("Hello from Java!") - - set_java_and_maven_versions(jdk_version, "3.3.9") - app.push! - expect(app.output).to include("Installing Maven 3.3.9") - expect(app.output).to include("BUILD SUCCESS") - expect(successful_body(app)).to eq("Hello from Java!") + it "handles Maven upgrades and downgrades correctly" do + Hatchet::Runner.new("java-servlets-sample", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) + set_maven_version("3.2.5") + end + + app.deploy do + expect(app.output).to include("Installing Maven 3.2.5") + expect(app.output).not_to include("BUILD FAILURE") + expect(app.output).to include("BUILD SUCCESS") + expect(http_get(app)).to eq("Hello from Java!") + + %w(3.6.2 3.5.4 3.3.9).each do |maven_version| + set_maven_version(maven_version) + app.commit! + app.push! + + expect(app.output).to include("Installing Maven #{maven_version}") + expect(app.output).to include("BUILD SUCCESS") + expect(http_get(app)).to eq("Hello from Java!") + end + end end end end diff --git a/test/spec/spec_helper.rb b/test/spec/spec_helper.rb index 9383e0d9..4df5cd7b 100644 --- a/test/spec/spec_helper.rb +++ b/test/spec/spec_helper.rb @@ -1,66 +1,54 @@ -require 'rspec/core' -require 'hatchet' -require 'fileutils' -require 'hatchet' -require 'rspec/retry' -require 'date' +require "rspec/core" +require "rspec/retry" +require "hatchet" +require "java-properties" -ENV['RACK_ENV'] = 'test' +# Omitting 1.7 here since most example projects used in testing are not +# compatible with 1.7. +OPENJDK_VERSIONS=%w(1.8 11 13 15) +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 - config.expect_with :rspec do |c| - c.syntax = :expect - end - #config.mock_with :none +def set_java_version(version_string) + set_system_properties_key("java.runtime.version", version_string) end -def git_repo - "https://github.com/heroku/heroku-buildpack-java.git" +def set_maven_version(version_string) + set_system_properties_key("maven.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']) +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 = {}) - sleep 5 - 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_java_and_maven_versions(java_version, maven_version) - File.open('system.properties', 'w') do |f| - f.puts "java.runtime.version=#{java_version}" - f.puts "maven.version=#{maven_version}" - end - `git add system.properties` - `git commit -m "setting jdk and maven versions"` +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 diff --git a/test/spec/spring_spec.rb b/test/spec/spring_spec.rb index c0be3580..47e44150 100644 --- a/test/spec/spring_spec.rb +++ b/test/spec/spring_spec.rb @@ -1,73 +1,61 @@ require_relative 'spec_helper' -describe "Spring" do - before(:each) do - set_java_version(app.directory, jdk_version) - init_app(app) - end - ["1.8"].each do |version| - context "on jdk-#{version}" do - let(:jdk_version) { version } +describe "Heroku's Java buildpack" do + context "using OpenJDK #{DEFAULT_OPENJDK_VERSION}" do + it "correctly builds spring-boot-webapp-runner" do + Hatchet::Runner.new("spring-boot-webapp-runner", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) + end - context "spring-boot-webapp-runner", :retry => 3, :retry_wait => 10 do - let(:app) { Hatchet::Runner.new("spring-boot-webapp-runner") } - it "builds a war" do - app.deploy do |app| - sleep(10) # :( - expect(app.output).to include("Installing JDK #{jdk_version}") - expect(app.output).to match(%r{Building war: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.war}) - expect(app.output).not_to match(%r{Building jar: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.jar}) - expect(app.output).not_to include("BUILD FAILURE") + app.deploy do + expect(app.output).to include("Installing JDK #{DEFAULT_OPENJDK_VERSION}") + expect(app.output).to match(%r{Building war: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.war}) + expect(app.output).not_to match(%r{Building jar: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.jar}) + expect(app.output).not_to include("BUILD FAILURE") - expect(successful_body(app)).to include("Create a New Appointment") - expect(app).to be_deployed - end + expect(http_get(app)).to include("Create a New Appointment") end end + end + + it "correctly builds spring-boot-executable" do + Hatchet::Runner.new("spring-boot-executable", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) + end - context "spring-boot-executable", :retry => 3, :retry_wait => 10 do - let(:app) { Hatchet::Runner.new("spring-boot-executable") } - it "builds an executable jar" do - app.deploy do |app| - sleep(10) # :( - expect(app.output).to include("Installing JDK #{jdk_version}") - expect(app.output).not_to include("Installing Maven") - expect(app.output).not_to match(%r{Building war: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.war}) - expect(app.output).to match(%r{Building jar: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.jar}) - expect(app.output).not_to include("BUILD FAILURE") + app.deploy do |app| + expect(app.output).to include("Installing JDK #{DEFAULT_OPENJDK_VERSION}") + expect(app.output).not_to include("Installing Maven") + expect(app.output).not_to match(%r{Building war: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.war}) + expect(app.output).to match(%r{Building jar: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.jar}) + expect(app.output).not_to include("BUILD FAILURE") - expect(successful_body(app)).to include("Create a New Appointment") - expect(app).to be_deployed - end + expect(http_get(app)).to include("Create a New Appointment") end + end + end - context "without a Procfile" do - before do - Dir.chdir(app.directory) do - if File.exists?("Procfile") - `git rm -f Procfile && git commit -am "remove procfile"` - end - end - end + it "provides a default web process type for spring-boot-executable" do + Hatchet::Runner.new("spring-boot-executable", stack: ENV["HEROKU_TEST_STACK"]).tap do |app| + app.before_deploy do + set_java_version(DEFAULT_OPENJDK_VERSION) + File.delete("Procfile") + end - it "creates a default process type" do - app.deploy do |app| - sleep(10) # :( - expect(app.output).to include("Installing JDK #{jdk_version}") - expect(app.output).not_to match(%r{Building war: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.war}) - expect(app.output).to match(%r{Building jar: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.jar}) - expect(app.output).not_to include("BUILD FAILURE") - expect(app.output).to include("Procfile declares types -> (none)") - expect(app.output).to include("Default types for buildpack -> web") + app.deploy do |app| + expect(app.output).to include("Installing JDK #{DEFAULT_OPENJDK_VERSION}") + expect(app.output).not_to match(%r{Building war: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.war}) + expect(app.output).to match(%r{Building jar: /tmp/.*/target/spring-boot-example-1.0-SNAPSHOT.jar}) + expect(app.output).not_to include("BUILD FAILURE") + expect(app.output).to include("Procfile declares types -> (none)") + expect(app.output).to include("Default types for buildpack -> web") - expect(successful_body(app)).to include("Create a New Appointment") - expect(app).to be_deployed - end - end + expect(http_get(app)).to include("Create a New Appointment") end end - end end end