1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

[CI] fixup test_plugin.rb, change IO.select to IO#wait_* (#2975)

This commit is contained in:
MSP-Greg 2022-09-27 19:14:39 -05:00 committed by GitHub
parent 968578fb8a
commit 673a9e7e89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 26 deletions

View file

@ -1 +0,0 @@
plugin 'tmp_restart'

View file

@ -30,6 +30,10 @@ end.to_i
require "puma"
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
# test_puma_localhost_authority.rb
if Puma::HAS_SSL

View file

@ -200,7 +200,7 @@ class TestIntegration < Minitest::Test
begin
n = io.syswrite str
rescue Errno::EAGAIN, Errno::EWOULDBLOCK => e
if !IO.select(nil, [io], nil, 5)
unless io.wait_writable 5
raise e
end

View file

@ -237,10 +237,7 @@ class TestPersistent < Minitest::Test
c2 = TCPSocket.new HOST, @port
c2 << @valid_request
out = IO.select([c2], nil, nil, 1)
assert out, "select returned nil"
assert_equal c2, out.first.first
assert c2.wait_readable(1), "2nd request starved"
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)

View file

@ -4,35 +4,24 @@ require_relative "helpers/integration"
class TestPlugin < TestIntegration
def test_plugin
skip "Skipped on Windows Ruby < 2.5.0, Ruby bug" if windows? && RUBY_VERSION < '2.5.0'
@tcp_bind = UniquePort.call
@tcp_ctrl = UniquePort.call
@control_tcp_port = UniquePort.call
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}" }
assert wait_for_server_to_include('Restarting...')
assert wait_for_server_to_boot
out = StringIO.new
cli_pumactl "-C tcp://#{HOST}:#{@tcp_ctrl} -T #{TOKEN} stop"
cli_pumactl "stop"
assert wait_for_server_to_include('Goodbye')
@server.close
@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

View file

@ -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 << "Hello" unless IO.select([sock], nil, nil, 1.15)
sock << "Hello" unless sock.wait_readable(1.15)
data = sock.gets
@ -1209,9 +1209,9 @@ EOF
assert_match(s1_response, s1.gets) if s1_response
# 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.gets
rescue Errno::ECONNABORTED, Errno::ECONNRESET
@ -1350,7 +1350,7 @@ EOF
sleep 0.5 # give enough time for new connection to enter reactor
@server.stop false
assert IO.select([sock], nil, nil, 1), 'Unexpected timeout'
assert sock.wait_readable(1), 'Unexpected timeout'
assert_raises EOFError do
sock.read_nonblock(256)
end