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

Fix integration test and cleanup 1.9.3 warnings

This commit is contained in:
Evan Phoenix 2011-12-07 14:48:41 -08:00
parent 98b0624cba
commit 49d27f888f
5 changed files with 27 additions and 33 deletions

View file

@ -11,8 +11,9 @@ require 'socket'
module Puma
class ControlCLI
def initialize(argv)
def initialize(argv, stdout=STDOUT)
@argv = argv
@stdout = stdout
end
def setup_options
@ -80,7 +81,7 @@ module Puma
end
def command_pid
puts "#{@state['pid']}"
@stdout.puts "#{@state['pid']}"
end
def command_stop
@ -90,7 +91,7 @@ module Puma
if body != '{ "status": "ok" }'
raise "Invalid response: '#{body}'"
else
puts "Requested stop from server"
@stdout.puts "Requested stop from server"
end
end
@ -101,7 +102,7 @@ module Puma
if body != '{ "status": "ok" }'
raise "Invalid response: '#{body}'"
else
puts "Requested halt from server"
@stdout.puts "Requested halt from server"
end
end
@ -112,7 +113,7 @@ module Puma
if body != '{ "status": "ok" }'
raise "Invalid response: '#{body}'"
else
puts "Requested restart from server"
@stdout.puts "Requested restart from server"
end
end
@ -120,7 +121,7 @@ module Puma
sock = connect
body = request sock, "/stats"
puts body
@stdout.puts body
end
end
end

View file

@ -32,7 +32,7 @@ class TestAppStatus < Test::Unit::TestCase
env = { 'PATH_INFO' => "/whatever" }
status, header, body = @app.call env
status, _, _ = @app.call env
assert_equal 403, status
end
@ -45,7 +45,7 @@ class TestAppStatus < Test::Unit::TestCase
'QUERY_STRING' => "token=abcdef"
}
status, header, body = @app.call env
status, _, _ = @app.call env
assert_equal 404, status
end
@ -53,7 +53,7 @@ class TestAppStatus < Test::Unit::TestCase
def test_unsupported
env = { 'PATH_INFO' => "/not-real" }
status, header, body = @app.call env
status, _, _ = @app.call env
assert_equal 404, status
end
@ -61,7 +61,7 @@ class TestAppStatus < Test::Unit::TestCase
def test_stop
env = { 'PATH_INFO' => "/stop" }
status, header, body = @app.call env
status, _ , body = @app.call env
assert_equal :stop, @server.status
assert_equal 200, status
@ -71,7 +71,7 @@ class TestAppStatus < Test::Unit::TestCase
def test_halt
env = { 'PATH_INFO' => "/halt" }
status, header, body = @app.call env
status, _ , body = @app.call env
assert_equal :halt, @server.status
assert_equal 200, status
@ -84,7 +84,7 @@ class TestAppStatus < Test::Unit::TestCase
@server.backlog = 1
@server.running = 9
status, header, body = @app.call env
status, _ , body = @app.call env
assert_equal 200, status
assert_equal ['{ "backlog": 1, "running": 9 }'], body

View file

@ -37,14 +37,6 @@ class Http11ParserTest < Test::Unit::TestCase
assert_equal should_be_good.length, nread
assert parser.finished?
assert !parser.error?
nasty_pound_header = "GET / HTTP/1.1\r\nX-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0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8\r\n\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n\tRA==\r\n\t-----END CERTIFICATE-----\r\n\r\n"
parser = HttpParser.new
req = {}
#nread = parser.execute(req, nasty_pound_header, 0)
#assert_equal nasty_pound_header.length, nread
#assert parser.finished?
#assert !parser.error?
end
def test_parse_error
@ -54,8 +46,8 @@ class Http11ParserTest < Test::Unit::TestCase
error = false
begin
nread = parser.execute(req, bad_http, 0)
rescue => details
parser.execute(req, bad_http, 0)
rescue
error = true
end

View file

@ -2,6 +2,9 @@ require 'test/unit'
require 'rubygems'
require 'socket'
require 'puma/cli'
require 'puma/control_cli'
class TestIntegration < Test::Unit::TestCase
def setup
@state_path = "test/test_puma.state"
@ -16,15 +19,13 @@ class TestIntegration < Test::Unit::TestCase
end
def test_stop_via_pumactl
status = nil
sin = StringIO.new
sout = StringIO.new
io = IO.popen "#{Gem.ruby} -Ilib bin/puma -S #{@state_path} -b unix://#{@bind_path} --control unix://#{@control_path} test/hello.ru 2>&1", "r"
cli = Puma::CLI.new %W!-q -S #{@state_path} -b unix://#{@bind_path} --control unix://#{@control_path} test/hello.ru!, sin, sout
line = nil
until /Use Ctrl-C to stop/ =~ line.to_s
line = io.gets
raise "error" unless line
t = Thread.new do
cli.run
end
sleep 1
@ -33,10 +34,10 @@ class TestIntegration < Test::Unit::TestCase
s << "GET / HTTP/1.0\r\n\r\n"
assert_equal "Hello World", s.read.split("\r\n").last
`#{Gem.ruby} -Ilib bin/pumactl -S #{@state_path} stop 2>&1`
ccli = Puma::ControlCLI.new %W!-S #{@state_path} stop!, sout
pid, status = Process.wait2(io.pid)
ccli.run
assert_equal 0, status.to_i
assert_kind_of Thread, t.join(1), "server didn't stop"
end
end

View file

@ -90,7 +90,7 @@ class WebServerTest < Test::Unit::TestCase
def test_file_streamed_request
body = "a" * (Puma::Const::MAX_BODY * 2)
long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
do_test(long, Puma::Const::CHUNK_SIZE * 2 -400)
do_test(long, (Puma::Const::CHUNK_SIZE * 2) - 400)
end
end