From a95a0bd3306015bd4f4f6da332864c000e8ef7ca Mon Sep 17 00:00:00 2001 From: sumeka Date: Fri, 28 Aug 2020 13:34:55 +0530 Subject: [PATCH 1/2] [changelog skip] Move integration logging test to main test suite --- Rakefile | 13 ++----------- test/{shell => config}/t3_conf.rb | 0 test/shell/run.rb | 10 ---------- test/shell/t3.rb | 24 ------------------------ test/test_integration_cluster.rb | 25 +++++++++++++++++++++++++ 5 files changed, 27 insertions(+), 45 deletions(-) rename test/{shell => config}/t3_conf.rb (100%) delete mode 100644 test/shell/run.rb delete mode 100644 test/shell/t3.rb diff --git a/Rakefile b/Rakefile index 231be50b..ef11de51 100644 --- a/Rakefile +++ b/Rakefile @@ -72,18 +72,9 @@ else end namespace :test do - desc "Run the integration tests" - - task :integration do - sh "ruby test/shell/run.rb" - end - desc "Run all tests" - if (Puma.jruby? && ENV['TRAVIS']) || Puma.windows? - task :all => :test - else - task :all => [:test, "test:integration"] - end + + task :all => :test end task :default => [:rubocop, "test:all"] diff --git a/test/shell/t3_conf.rb b/test/config/t3_conf.rb similarity index 100% rename from test/shell/t3_conf.rb rename to test/config/t3_conf.rb diff --git a/test/shell/run.rb b/test/shell/run.rb deleted file mode 100644 index 458f6400..00000000 --- a/test/shell/run.rb +++ /dev/null @@ -1,10 +0,0 @@ -require "puma" -require "puma/detect" - -return unless Process.respond_to?(:fork) - -if system("ruby -rrubygems test/shell/t3.rb ") - exit 0 -else - exit 1 -end diff --git a/test/shell/t3.rb b/test/shell/t3.rb deleted file mode 100644 index 125a07d6..00000000 --- a/test/shell/t3.rb +++ /dev/null @@ -1,24 +0,0 @@ -system "ruby -rrubygems -Ilib bin/puma -p 10102 -C test/shell/t3_conf.rb test/rackup/hello.ru &" -sleep 5 - -worker_pid_was_present = File.file? "t3-worker-2-pid" - -Process.kill :TERM, Integer(File.read("t3-worker-2-pid")) # kill off a worker - -sleep 2 - -worker_index_within_number_of_workers = !File.file?("t3-worker-3-pid") - -Process.kill :TERM, Integer(File.read("t3-pid")) - -File.unlink "t3-pid" if File.file? "t3-pid" -File.unlink "t3-worker-0-pid" if File.file? "t3-worker-0-pid" -File.unlink "t3-worker-1-pid" if File.file? "t3-worker-1-pid" -File.unlink "t3-worker-2-pid" if File.file? "t3-worker-2-pid" -File.unlink "t3-worker-3-pid" if File.file? "t3-worker-3-pid" - -if worker_pid_was_present and worker_index_within_number_of_workers - exit 0 -else - exit 1 -end diff --git a/test/test_integration_cluster.rb b/test/test_integration_cluster.rb index f409443c..041da01a 100644 --- a/test/test_integration_cluster.rb +++ b/test/test_integration_cluster.rb @@ -157,6 +157,31 @@ end RUBY end + def test_worker_index_is_with_in_options_limit + skip_unless_signal_exist? :TERM + + cli_server "-C test/config/t3_conf.rb test/rackup/hello.ru" + + pids = get_worker_pids + + worker_pid_was_present = File.file? "t3-worker-2-pid" + + stop_server(Integer(File.read("t3-worker-2-pid"))) + + worker_index_within_number_of_workers = !File.file?("t3-worker-3-pid") + + stop_server(Integer(File.read("t3-pid"))) + + File.unlink "t3-pid" if File.file? "t3-pid" + File.unlink "t3-worker-0-pid" if File.file? "t3-worker-0-pid" + File.unlink "t3-worker-1-pid" if File.file? "t3-worker-1-pid" + File.unlink "t3-worker-2-pid" if File.file? "t3-worker-2-pid" + File.unlink "t3-worker-3-pid" if File.file? "t3-worker-3-pid" + + assert(worker_pid_was_present) + assert(worker_index_within_number_of_workers) + end + def test_refork refork = Tempfile.new('refork') cli_server "-w #{WORKERS} test/rackup/sleep.ru", config: < Date: Fri, 28 Aug 2020 13:56:21 +0530 Subject: [PATCH 2/2] removed unused variable --- test/test_integration_cluster.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_integration_cluster.rb b/test/test_integration_cluster.rb index 041da01a..d4c9f2a5 100644 --- a/test/test_integration_cluster.rb +++ b/test/test_integration_cluster.rb @@ -162,7 +162,7 @@ RUBY cli_server "-C test/config/t3_conf.rb test/rackup/hello.ru" - pids = get_worker_pids + get_worker_pids # this will wait till all the processes are up worker_pid_was_present = File.file? "t3-worker-2-pid"