From e5f1655e4784f9c4c80f358a9e8beb4d6eb5fafe Mon Sep 17 00:00:00 2001 From: Harry Lewis Date: Wed, 29 Apr 2020 02:06:11 -0400 Subject: [PATCH] [changelog skip] Move integration logging test to main test suite (#2240) * Copy test from shell/t1.rb to test/test_integration_t1.rb --- test/{shell => config}/t1_conf.rb | 0 test/shell/run.rb | 4 ++-- test/shell/t1.rb | 18 ------------------ test/test_integration_single.rb | 19 +++++++++++++++++++ test/test_rack_handler.rb | 4 ++-- 5 files changed, 23 insertions(+), 22 deletions(-) rename test/{shell => config}/t1_conf.rb (100%) delete mode 100644 test/shell/t1.rb diff --git a/test/shell/t1_conf.rb b/test/config/t1_conf.rb similarity index 100% rename from test/shell/t1_conf.rb rename to test/config/t1_conf.rb diff --git a/test/shell/run.rb b/test/shell/run.rb index d5e9019f..58317f92 100644 --- a/test/shell/run.rb +++ b/test/shell/run.rb @@ -2,9 +2,9 @@ require "puma" require "puma/detect" TESTS_TO_RUN = if Process.respond_to?(:fork) - %w[t1 t2 t3] + %w[t2 t3] else - %w[t1 t2] + %w[t2] end results = TESTS_TO_RUN.map do |test| diff --git a/test/shell/t1.rb b/test/shell/t1.rb deleted file mode 100644 index bffbfb47..00000000 --- a/test/shell/t1.rb +++ /dev/null @@ -1,18 +0,0 @@ -system "ruby -rrubygems -Ilib bin/puma -p 10102 -C test/shell/t1_conf.rb test/rackup/hello.ru &" - -sleep 1 until system "curl http://localhost:10102/" - -Process.kill :TERM, Integer(File.read("t1-pid")) - -sleep 1 - -log = File.read("t1-stdout") - -File.unlink "t1-stdout" if File.file? "t1-stdout" -File.unlink "t1-pid" if File.file? "t1-pid" - -if log =~ %r!GET / HTTP/1\.1! - exit 0 -else - exit 1 -end diff --git a/test/test_integration_single.rb b/test/test_integration_single.rb index 864c3385..ebe8fa57 100644 --- a/test/test_integration_single.rb +++ b/test/test_integration_single.rb @@ -112,4 +112,23 @@ class TestIntegrationSingle < TestIntegration assert_match "Thread: TID", output.join end + + def test_write_to_log + skip_unless_signal_exist? :TERM + + suppress_output = '> /dev/null 2>&1' + + cli_server '-C test/config/t1_conf.rb test/rackup/hello.ru' + + system "curl http://localhost:#{@tcp_port}/ #{suppress_output}" + + stop_server + + log = File.read('t1-stdout') + + File.unlink 't1-stdout' if File.file? 't1-stdout' + File.unlink 't1-pid' if File.file? 't1-pid' + + assert_match(%r!GET / HTTP/1\.1!, log) + end end diff --git a/test/test_rack_handler.rb b/test/test_rack_handler.rb index bcfc3542..348e874f 100644 --- a/test/test_rack_handler.rb +++ b/test/test_rack_handler.rb @@ -236,7 +236,7 @@ class TestUserSuppliedOptionsIsNotPresent < Minitest::Test file_log_requests_config = true @options[:config_files] = [ - 'test/shell/t1_conf.rb' + 'test/config/t1_conf.rb' ] conf = Rack::Handler::Puma.config(->{}, @options) @@ -250,7 +250,7 @@ class TestUserSuppliedOptionsIsNotPresent < Minitest::Test @options[:log_requests] = user_log_requests_config @options[:config_files] = [ - 'test/shell/t1_conf.rb' + 'test/config/t1_conf.rb' ] conf = Rack::Handler::Puma.config(->{}, @options)