diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-02-09 23:09:14 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-02-11 00:20:22 +0000 |
commit | 2163a4c6f09a9813a0e69a9533923623d448dce9 (patch) | |
tree | 396d8aa896cf55e36c11613b189a1e1789612413 | |
parent | 7d56b023d2aac8530b249b2db7d90a738297a6fc (diff) | |
download | cmogstored-2163a4c6f09a9813a0e69a9533923623d448dce9.tar.gz |
We need to ensure the PID file is non-empty, not just that it exists.
-rw-r--r-- | test/upgrade.rb | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/test/upgrade.rb b/test/upgrade.rb index a3e8258..3811b8f 100644 --- a/test/upgrade.rb +++ b/test/upgrade.rb @@ -61,9 +61,8 @@ class TestUpgrade < Test::Unit::TestCase # start the upgrade Process.kill(:USR2, old_pid) - Timeout.timeout(30) do - sleep(0.01) until File.exist?(@old) && File.exist?(@pid_path) - end + wait_for_pidfile(@old) + wait_for_pidfile(@pid_path) # both old and new should be running first_pid = assert_pidfile_valid(@old) @@ -79,7 +78,7 @@ class TestUpgrade < Test::Unit::TestCase Process.kill(new_sig, new_pid) wait_for_death(new_pid) Timeout.timeout(30) { sleep(0.01) while File.exist?(@old) } - Timeout.timeout(30) { sleep(0.01) until File.exist?(@pid_path) } + wait_for_pidfile(@pid_path) orig_pid = assert_pidfile_valid(@pid_path) assert_equal old_pid, orig_pid Process.kill(:QUIT, orig_pid) @@ -133,6 +132,20 @@ class TestUpgrade < Test::Unit::TestCase end end + def wait_for_pidfile(pidf, seconds = 30) + Timeout.timeout(seconds) do + begin + if File.exist?(pidf) + nr = File.read(pidf) + return if nr.to_i > 0 + end + sleep 0.01 + rescue Errno::ENOENT + sleep 0.01 + end while true + end + end + def assert_http_running # make sure process is running and signals are ready Net::HTTP.start(@host, @http_port) do |http| |