[CI] fixup test_plugin.rb, change IO.select to IO#wait_* (#2975)
This commit is contained in:
parent
968578fb8a
commit
673a9e7e89
|
@ -1 +0,0 @@
|
||||||
plugin 'tmp_restart'
|
|
|
@ -30,6 +30,10 @@ end.to_i
|
||||||
require "puma"
|
require "puma"
|
||||||
require "puma/detect"
|
require "puma/detect"
|
||||||
|
|
||||||
|
unless ::Puma::HAS_NATIVE_IO_WAIT
|
||||||
|
require "io/wait"
|
||||||
|
end
|
||||||
|
|
||||||
# used in various ssl test files, see test_puma_server_ssl.rb and
|
# used in various ssl test files, see test_puma_server_ssl.rb and
|
||||||
# test_puma_localhost_authority.rb
|
# test_puma_localhost_authority.rb
|
||||||
if Puma::HAS_SSL
|
if Puma::HAS_SSL
|
||||||
|
|
|
@ -200,7 +200,7 @@ class TestIntegration < Minitest::Test
|
||||||
begin
|
begin
|
||||||
n = io.syswrite str
|
n = io.syswrite str
|
||||||
rescue Errno::EAGAIN, Errno::EWOULDBLOCK => e
|
rescue Errno::EAGAIN, Errno::EWOULDBLOCK => e
|
||||||
if !IO.select(nil, [io], nil, 5)
|
unless io.wait_writable 5
|
||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -237,10 +237,7 @@ class TestPersistent < Minitest::Test
|
||||||
c2 = TCPSocket.new HOST, @port
|
c2 = TCPSocket.new HOST, @port
|
||||||
c2 << @valid_request
|
c2 << @valid_request
|
||||||
|
|
||||||
out = IO.select([c2], nil, nil, 1)
|
assert c2.wait_readable(1), "2nd request starved"
|
||||||
|
|
||||||
assert out, "select returned nil"
|
|
||||||
assert_equal c2, out.first.first
|
|
||||||
|
|
||||||
assert_equal "HTTP/1.1 200 OK\r\nX-Header: Works\r\nContent-Length: #{sz}\r\n\r\n", lines(4, c2)
|
assert_equal "HTTP/1.1 200 OK\r\nX-Header: Works\r\nContent-Length: #{sz}\r\n\r\n", lines(4, c2)
|
||||||
assert_equal "Hello", c2.read(5)
|
assert_equal "Hello", c2.read(5)
|
||||||
|
|
|
@ -4,35 +4,24 @@ require_relative "helpers/integration"
|
||||||
class TestPlugin < TestIntegration
|
class TestPlugin < TestIntegration
|
||||||
def test_plugin
|
def test_plugin
|
||||||
skip "Skipped on Windows Ruby < 2.5.0, Ruby bug" if windows? && RUBY_VERSION < '2.5.0'
|
skip "Skipped on Windows Ruby < 2.5.0, Ruby bug" if windows? && RUBY_VERSION < '2.5.0'
|
||||||
@tcp_bind = UniquePort.call
|
@control_tcp_port = UniquePort.call
|
||||||
@tcp_ctrl = UniquePort.call
|
|
||||||
|
|
||||||
Dir.mkdir("tmp") unless Dir.exist?("tmp")
|
Dir.mkdir("tmp") unless Dir.exist?("tmp")
|
||||||
|
|
||||||
cli_server "-b tcp://#{HOST}:#{@tcp_bind} --control-url tcp://#{HOST}:#{@tcp_ctrl} --control-token #{TOKEN} -C test/config/plugin1.rb test/rackup/hello.ru"
|
cli_server "--control-url tcp://#{HOST}:#{@control_tcp_port} --control-token #{TOKEN} test/rackup/hello.ru",
|
||||||
|
config: "plugin 'tmp_restart'"
|
||||||
|
|
||||||
File.open('tmp/restart.txt', mode: 'wb') { |f| f.puts "Restart #{Time.now}" }
|
File.open('tmp/restart.txt', mode: 'wb') { |f| f.puts "Restart #{Time.now}" }
|
||||||
|
|
||||||
assert wait_for_server_to_include('Restarting...')
|
assert wait_for_server_to_include('Restarting...')
|
||||||
|
|
||||||
assert wait_for_server_to_boot
|
assert wait_for_server_to_boot
|
||||||
|
|
||||||
out = StringIO.new
|
cli_pumactl "stop"
|
||||||
|
|
||||||
cli_pumactl "-C tcp://#{HOST}:#{@tcp_ctrl} -T #{TOKEN} stop"
|
|
||||||
|
|
||||||
assert wait_for_server_to_include('Goodbye')
|
assert wait_for_server_to_include('Goodbye')
|
||||||
|
|
||||||
@server.close
|
@server.close
|
||||||
@server = nil
|
@server = nil
|
||||||
out.close
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def cli_pumactl(argv)
|
|
||||||
pumactl = IO.popen("#{BASE} bin/pumactl #{argv}", "r")
|
|
||||||
@ios_to_close << pumactl
|
|
||||||
Process.wait pumactl.pid
|
|
||||||
pumactl
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -525,7 +525,7 @@ EOF
|
||||||
|
|
||||||
sock = send_http "POST / HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\nContent-Length: 5\r\n\r\n"
|
sock = send_http "POST / HTTP/1.1\r\nHost: test.com\r\nContent-Type: text/plain\r\nContent-Length: 5\r\n\r\n"
|
||||||
|
|
||||||
sock << "Hello" unless IO.select([sock], nil, nil, 1.15)
|
sock << "Hello" unless sock.wait_readable(1.15)
|
||||||
|
|
||||||
data = sock.gets
|
data = sock.gets
|
||||||
|
|
||||||
|
@ -1209,9 +1209,9 @@ EOF
|
||||||
assert_match(s1_response, s1.gets) if s1_response
|
assert_match(s1_response, s1.gets) if s1_response
|
||||||
|
|
||||||
# Send s2 after shutdown begins
|
# Send s2 after shutdown begins
|
||||||
s2 << "\r\n" unless IO.select([s2], nil, nil, 0.2)
|
s2 << "\r\n" unless s2.wait_readable(0.2)
|
||||||
|
|
||||||
assert IO.select([s2], nil, nil, 10), 'timeout waiting for response'
|
assert s2.wait_readable(10), 'timeout waiting for response'
|
||||||
s2_result = begin
|
s2_result = begin
|
||||||
s2.gets
|
s2.gets
|
||||||
rescue Errno::ECONNABORTED, Errno::ECONNRESET
|
rescue Errno::ECONNABORTED, Errno::ECONNRESET
|
||||||
|
@ -1350,7 +1350,7 @@ EOF
|
||||||
sleep 0.5 # give enough time for new connection to enter reactor
|
sleep 0.5 # give enough time for new connection to enter reactor
|
||||||
@server.stop false
|
@server.stop false
|
||||||
|
|
||||||
assert IO.select([sock], nil, nil, 1), 'Unexpected timeout'
|
assert sock.wait_readable(1), 'Unexpected timeout'
|
||||||
assert_raises EOFError do
|
assert_raises EOFError do
|
||||||
sock.read_nonblock(256)
|
sock.read_nonblock(256)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue