From c83401cfcf2cbe0ca23e1bef936d720ab5821291 Mon Sep 17 00:00:00 2001 From: Tim Morgan Date: Thu, 13 Feb 2020 13:59:16 -0600 Subject: [PATCH] Move test into separate file This test was failing on Travis when run in parallel with other tests in the TestIntegrationCluster test. Removing the line "parallelize_me!" from the top of the file worked, but I chose to move the test into its own file to keep the existing tests running in parallel. --- test/test_integration_cluster.rb | 24 ---------------------- test/test_preserve_bundler_env.rb | 33 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 test/test_preserve_bundler_env.rb diff --git a/test/test_integration_cluster.rb b/test/test_integration_cluster.rb index 1e22e59e..a7f58f84 100644 --- a/test/test_integration_cluster.rb +++ b/test/test_integration_cluster.rb @@ -133,30 +133,6 @@ class TestIntegrationCluster < TestIntegration worker_respawn { |phase0_worker_pids| Process.kill :USR1, @pid } end - # It does not wipe out BUNDLE_GEMFILE et al - def test_usr2_restart_preserves_bundler_environment - @tcp_port = UniquePort.call - env = { - # Intentionally set this to something we wish to keep intact on restarts - "BUNDLE_GEMFILE" => "Gemfile.bundle_env_preservation_test", - # Don't allow our (rake test's) original env to interfere with the child process - "BUNDLER_ORIG_BUNDLE_GEMFILE" => nil - } - # Must use `bundle exec puma` here, because otherwise Bundler may not be defined, which is required to trigger the bug - cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}" - Dir.chdir(File.expand_path("bundle_preservation_test", __dir__)) do - @server = IO.popen(env, cmd.split, "r") - end - wait_for_server_to_boot - @pid = @server.pid - connection = connect - initial_reply = read_body(connection) - assert_match("Gemfile.bundle_env_preservation_test", initial_reply) - restart_server connection - new_reply = read_body(connection) - assert_match("Gemfile.bundle_env_preservation_test", new_reply) - end - private # Send requests 10 per second. Send 10, then :TERM server, then send another 30. diff --git a/test/test_preserve_bundler_env.rb b/test/test_preserve_bundler_env.rb new file mode 100644 index 00000000..35aaee71 --- /dev/null +++ b/test/test_preserve_bundler_env.rb @@ -0,0 +1,33 @@ +require_relative "helper" +require_relative "helpers/integration" + +class TestPreserveBundlerEnv < TestIntegration + def setup + skip NO_FORK_MSG unless HAS_FORK + super + end + + # It does not wipe out BUNDLE_GEMFILE et al + def test_usr2_restart_preserves_bundler_environment + @tcp_port = UniquePort.call + env = { + # Intentionally set this to something we wish to keep intact on restarts + "BUNDLE_GEMFILE" => "Gemfile.bundle_env_preservation_test", + # Don't allow our (rake test's) original env to interfere with the child process + "BUNDLER_ORIG_BUNDLE_GEMFILE" => nil + } + # Must use `bundle exec puma` here, because otherwise Bundler may not be defined, which is required to trigger the bug + cmd = "bundle exec puma -q -w 1 --prune-bundler -b tcp://#{HOST}:#{@tcp_port}" + Dir.chdir(File.expand_path("bundle_preservation_test", __dir__)) do + @server = IO.popen(env, cmd.split, "r") + end + wait_for_server_to_boot + @pid = @server.pid + connection = connect + initial_reply = read_body(connection) + assert_match("Gemfile.bundle_env_preservation_test", initial_reply) + restart_server connection + new_reply = read_body(connection) + assert_match("Gemfile.bundle_env_preservation_test", new_reply) + end +end