From f55db91a7f9e97190028839a41131ce9c308a8cf Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 18 Mar 2009 02:55:29 -0700 Subject: Add signal queueing for test reliability 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. --- test/exec/test_exec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test') 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) -- cgit v1.2.3-24-ge0c7