mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
[CI] misc updates to test files (#2979)
* [CI] test/helper.rb - sort debug output by test * [CI] test/test_puma_server_ssl.rb - remove tap call * [CI] test/helpers/integration.rb - fixup hot_restart_does_not_drop_connections, may be pointless with CI variances
This commit is contained in:
parent
9770678f17
commit
838c136aeb
3 changed files with 22 additions and 15 deletions
|
@ -21,7 +21,7 @@ require_relative "helpers/apps"
|
|||
|
||||
Thread.abort_on_exception = true
|
||||
|
||||
$debugging_info = +''
|
||||
$debugging_info = []
|
||||
$debugging_hold = false # needed for TestCLI#test_control_clustered
|
||||
$test_case_timeout = ENV.fetch("TEST_CASE_TIMEOUT") do
|
||||
RUBY_ENGINE == "ruby" ? 45 : 60
|
||||
|
@ -197,7 +197,8 @@ end
|
|||
Minitest.after_run do
|
||||
# needed for TestCLI#test_control_clustered
|
||||
if !$debugging_hold && ENV['PUMA_TEST_DEBUG']
|
||||
out = $debugging_info.strip
|
||||
$debugging_info.sort!
|
||||
out = $debugging_info.join.strip
|
||||
unless out.empty?
|
||||
dash = "\u2500"
|
||||
wid = ENV['GITHUB_ACTIONS'] ? 88 : 90
|
||||
|
|
|
@ -340,8 +340,13 @@ class TestIntegration < Minitest::Test
|
|||
client_threads << Thread.new do
|
||||
num_requests.times do |req_num|
|
||||
begin
|
||||
socket = TCPSocket.new HOST, @tcp_port
|
||||
fast_write socket, "POST / HTTP/1.1\r\nContent-Length: #{message.bytesize}\r\n\r\n#{message}"
|
||||
begin
|
||||
socket = TCPSocket.new HOST, @tcp_port
|
||||
fast_write socket, "POST / HTTP/1.1\r\nContent-Length: #{message.bytesize}\r\n\r\n#{message}"
|
||||
rescue => e
|
||||
replies[:write_error] += 1
|
||||
raise e
|
||||
end
|
||||
body = read_body(socket, 10)
|
||||
if body == "Hello World"
|
||||
mutex.synchronize {
|
||||
|
@ -377,7 +382,7 @@ class TestIntegration < Minitest::Test
|
|||
run = true
|
||||
|
||||
restart_thread = Thread.new do
|
||||
sleep 0.30 # let some connections in before 1st restart
|
||||
sleep 0.2 # let some connections in before 1st restart
|
||||
while run
|
||||
if Puma.windows?
|
||||
cli_pumactl 'restart'
|
||||
|
@ -387,7 +392,7 @@ class TestIntegration < Minitest::Test
|
|||
sleep 0.5
|
||||
wait_for_server_to_boot
|
||||
restart_count += 1
|
||||
sleep(Puma.windows? ? 2.0 : 1.0)
|
||||
sleep(Puma.windows? ? 2.0 : 0.5)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -410,22 +415,24 @@ class TestIntegration < Minitest::Test
|
|||
msg << " %4d success after restart\n" % replies.fetch(:restart,0)
|
||||
msg << " %4d restart count\n" % restart_count
|
||||
|
||||
reset = replies[:reset]
|
||||
refused = replies[:refused]
|
||||
reset = replies[:reset]
|
||||
|
||||
if Puma.windows?
|
||||
# 5 is default thread count in Puma?
|
||||
reset_max = num_threads * restart_count
|
||||
assert_operator reset_max, :>=, reset, "#{msg}Expected reset_max >= reset errors"
|
||||
assert_operator 40, :>=, replies[:refused], "#{msg}Too many refused connections"
|
||||
assert_operator 40, :>=, refused, "#{msg}Too many refused connections"
|
||||
else
|
||||
assert_equal 0, reset, "#{msg}Expected no reset errors"
|
||||
assert_equal 0, replies[:refused], "#{msg}Expected no refused connections"
|
||||
max_refused = (0.001 * replies.fetch(:success,0)).round
|
||||
assert_operator max_refused, :>=, refused, "#{msg}Expected no than #{max_refused} refused connections"
|
||||
end
|
||||
assert_equal 0, replies[:unexpected_response], "#{msg}Unexpected response"
|
||||
assert_equal 0, replies[:read_timeout], "#{msg}Expected no read timeouts"
|
||||
|
||||
if Puma.windows?
|
||||
assert_equal (num_threads * num_requests) - reset - replies[:refused], replies[:success]
|
||||
assert_equal (num_threads * num_requests) - reset - refused, replies[:success]
|
||||
else
|
||||
assert_equal (num_threads * num_requests), replies[:success]
|
||||
end
|
||||
|
@ -433,7 +440,7 @@ class TestIntegration < Minitest::Test
|
|||
ensure
|
||||
return if skipped
|
||||
if passed?
|
||||
msg = " restart_count #{restart_count}, reset #{reset}, success after restart #{replies[:restart]}"
|
||||
msg = " #{restart_count} restarts, #{reset} resets, #{refused} refused, #{replies[:restart]} success after restart, #{replies[:write_error]} write error"
|
||||
$debugging_info << "#{full_name}\n#{msg}\n"
|
||||
else
|
||||
client_threads.each { |thr| thr.kill if thr.is_a? Thread }
|
||||
|
|
|
@ -513,10 +513,9 @@ class TestPumaServerSSLWithCertPemAndKeyPem < Minitest::Test
|
|||
def test_server_ssl_with_cert_pem_and_key_pem
|
||||
host = "localhost"
|
||||
port = 0
|
||||
ctx = Puma::MiniSSL::Context.new.tap { |ctx|
|
||||
ctx.cert_pem = File.read("#{CERT_PATH}/server.crt")
|
||||
ctx.key_pem = File.read("#{CERT_PATH}/server.key")
|
||||
}
|
||||
ctx = Puma::MiniSSL::Context.new
|
||||
ctx.cert_pem = File.read "#{CERT_PATH}/server.crt"
|
||||
ctx.key_pem = File.read "#{CERT_PATH}/server.key"
|
||||
|
||||
app = lambda { |env| [200, {}, [env['rack.url_scheme']]] }
|
||||
log_writer = SSLLogWriterHelper.new STDOUT, STDERR
|
||||
|
|
Loading…
Add table
Reference in a new issue