diff options
author | Eric Wong <e@80x24.org> | 2013-10-20 00:39:23 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2013-10-20 00:39:23 +0000 |
commit | 2231035fd7a73629123eb76438ffabbefa807ad7 (patch) | |
tree | cec66e653a65104a61df31ed2c36302d1b3a2565 | |
parent | f593504584288fa9b0a434d8c87feb8e89041f29 (diff) | |
download | yahns-2231035fd7a73629123eb76438ffabbefa807ad7.tar.gz |
worker_processes only open the new log file after the master does, so the workers processing the request may not be writing to the new one, yet, so we repeat the HTTP request.
-rw-r--r-- | test/test_reopen_logs.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/test/test_reopen_logs.rb b/test/test_reopen_logs.rb index a5aeca7..b27e5be 100644 --- a/test/test_reopen_logs.rb +++ b/test/test_reopen_logs.rb @@ -45,10 +45,15 @@ class TestReopenLogs < Testcase Process.kill(:USR1, pid) Timeout.timeout(10) { sleep(0.01) until File.exist?(opath) } - res = http.request(Net::HTTP::Get.new("/bbb")) - assert_equal 200, res.code.to_i - assert_equal orig, res.body - Timeout.timeout(10) { Thread.pass until File.read(opath) =~ /bbb/ } + # we need to repeat the HTTP request since the worker_processes + # may not have switched to the new file, yet. + Timeout.timeout(10) do + begin + res = http.request(Net::HTTP::Get.new("/bbb")) + assert_equal 200, res.code.to_i + assert_equal orig, res.body + end until File.read(opath) =~ /bbb/ + end end rescue => e Yahns::Log.exception(Logger.new($stderr), "test", e) |