Skip to content

Commit

Permalink
Add tests for single/cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
nateberkopec committed Sep 11, 2019
1 parent 74ec30a commit 6d76e8d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/helpers/integration.rb
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion test/test_integration_cluster.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/test_integration_single.rb
Expand Up @@ -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

0 comments on commit 6d76e8d

Please sign in to comment.