From 6d76e8d26a2cd0a8609601ecc019ad2808ab08c2 Mon Sep 17 00:00:00 2001 From: Nate Berkopec Date: Wed, 11 Sep 2019 16:52:48 +0000 Subject: [PATCH] Add tests for single/cluster --- test/helpers/integration.rb | 2 +- test/test_integration_cluster.rb | 16 +++++++++++++++- test/test_integration_single.rb | 13 +++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/test/helpers/integration.rb b/test/helpers/integration.rb index 9dd6067139..31608ef880 100644 --- a/test/helpers/integration.rb +++ b/test/helpers/integration.rb @@ -97,7 +97,7 @@ def read_body(connection) end # gets worker pids from @server output - def get_worker_pids(phase, size = WORKERS) + def get_worker_pids(phase = 0, size = WORKERS) pids = [] re = /pid: (\d+)\) booted, phase: #{phase}/ while pids.size < size diff --git a/test/test_integration_cluster.rb b/test/test_integration_cluster.rb index c2c9efcb0f..09ba6643f6 100644 --- a/test/test_integration_cluster.rb +++ b/test/test_integration_cluster.rb @@ -8,6 +8,20 @@ def setup super end + def test_siginfo_thread_print + skip_unless_signal_exist? :INFO + + pid = cli_server("-w #{WORKERS} -q test/rackup/hello.ru") + worker_pids = get_worker_pids + output = [] + t = Thread.new { output << @server.readlines } + Process.kill(:INFO, worker_pids.first) + Process.kill(:INT, @server.pid) + t.join + + assert_match "Thread TID", output.join + end + def test_usr2_restart _, new_reply = restart_server_and_listen("-q -w #{WORKERS} test/rackup/hello.ru") assert_equal "Hello World", new_reply @@ -92,7 +106,7 @@ def test_term_worker_clean_exit pid = cli_server("-w #{WORKERS} test/rackup/hello.ru").pid # Get the PIDs of the child workers. - worker_pids = get_worker_pids 0 + worker_pids = get_worker_pids # Signal the workers to terminate, and wait for them to die. Process.kill :TERM, pid diff --git a/test/test_integration_single.rb b/test/test_integration_single.rb index 59fe811708..1c985e1e7d 100644 --- a/test/test_integration_single.rb +++ b/test/test_integration_single.rb @@ -84,4 +84,17 @@ def test_int_signal_with_background_thread_in_jruby assert_raises(Errno::ECONNREFUSED) { TCPSocket.new(HOST, @tcp_port) } end + + def test_siginfo_thread_print + skip_unless_signal_exist? :INFO + + pid = cli_server("test/rackup/hello.ru") + output = [] + t = Thread.new { output << @server.readlines } + Process.kill(:INFO, @server.pid) + Process.kill(:INT, @server.pid) + t.join + + assert_match "Thread TID", output.join + end end