diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-15 12:09:14 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-15 12:09:14 -0800 |
commit | 6d7e11482a484b50215701993408057b80c82bbe (patch) | |
tree | 20930db93e47bb27775cfba45c1f646472c6e538 | |
parent | ada989844090d88c4fdc0a568ff4df2c0c8397fb (diff) | |
download | unicorn-6d7e11482a484b50215701993408057b80c82bbe.tar.gz |
This works around a race condition caused by the server closing the connection before writing out to stderr in the ensure block. So to ensure we've waited on the server to write to the log file, just send another HTTP request since we know our test server only processes requests serially.
-rw-r--r-- | test/unit/test_server.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/unit/test_server.rb b/test/unit/test_server.rb index a7f6a35..7f0c443 100644 --- a/test/unit/test_server.rb +++ b/test/unit/test_server.rb @@ -128,6 +128,8 @@ class WebServerTest < Test::Unit::TestCase buf = sock.read end assert_equal 'hello!\n', buf.split(/\r\n\r\n/).last + next_client = Net::HTTP.get(URI.parse("http://127.0.0.1:#@port/")) + assert_equal 'hello!\n', next_client lines = File.readlines("test_stderr.#$$.log") assert lines.grep(/^Unicorn::ClientShutdown: /).empty? assert_nothing_raised { sock.close } @@ -154,6 +156,8 @@ class WebServerTest < Test::Unit::TestCase buf = sock.read end assert_equal "", buf + next_client = Net::HTTP.get(URI.parse("http://127.0.0.1:#@port/")) + assert_equal 'hello!\n', next_client lines = File.readlines("test_stderr.#$$.log") lines = lines.grep(/^Unicorn::ClientShutdown: bytes_read=\d+/) assert_equal 1, lines.size |