diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-03-18 02:55:29 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-03-18 17:50:33 -0700 |
commit | f55db91a7f9e97190028839a41131ce9c308a8cf (patch) | |
tree | d653413e5ff964cc74167f5b768483c1e9521aa2 /test/exec/test_exec.rb | |
parent | 29c6af908c2bd1109be175c34b89c45c8cc2f60b (diff) | |
download | unicorn-f55db91a7f9e97190028839a41131ce9c308a8cf.tar.gz |
Although I didn't like the idea initially, signal queueing allows test_exec to run more reliably and the limited signal queue size will prevent scary queued signal behavior. Also, always wakeup the master immediately when CHLD is trapped to reduce the performance impact of SIGHUP-based config reloading. Combined with an extra check in test_exec, this should make test_exec run much more reliably than before.
Diffstat (limited to 'test/exec/test_exec.rb')
-rw-r--r-- | test/exec/test_exec.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/exec/test_exec.rb b/test/exec/test_exec.rb index 712037c..fc8ac26 100644 --- a/test/exec/test_exec.rb +++ b/test/exec/test_exec.rb @@ -283,6 +283,7 @@ end results = retry_hit(["http://#{@addr}:#{@port}/"]) assert_equal String, results[0].class wait_master_ready(COMMON_TMP.path) + wait_workers_ready(COMMON_TMP.path, 4) bf = File.readlines(COMMON_TMP.path).grep(/\bbefore_fork: worker=/) assert_equal 4, bf.size rotate = Tempfile.new('unicorn_rotate') @@ -496,6 +497,21 @@ end assert status.success?, "exited successfully" end + def wait_workers_ready(path, nr_workers) + tries = DEFAULT_TRIES + lines = [] + while (tries -= 1) > 0 + begin + lines = File.readlines(path).grep(/worker=\d+ spawned/) + lines.size == nr_workers and return + rescue Errno::ENOENT + end + sleep DEFAULT_RES + end + raise "#{nr_workers} workers never became ready:" \ + "\n\t#{lines.join("\n\t")}\n" + end + def wait_master_ready(master_log) tries = DEFAULT_TRIES while (tries -= 1) > 0 @@ -555,7 +571,7 @@ end while (tries -= 1) > 0 && ! File.exist?(path) sleep DEFAULT_RES end - assert File.exist?(path), "path=#{path} exists" + assert File.exist?(path), "path=#{path} exists #{caller.inspect}" end def xfork(&block) |