Permalink
Browse files

cucumber: check for the worker pids to also shutdown

aslo: @wip scenario for daemonized version
  • Loading branch information...
1 parent 778b07d commit 51a16280a8200bcdaa76aa13e390cdf238eaf3ef @nevans nevans committed Feb 23, 2011
@@ -31,8 +31,34 @@ Feature: Basic resque-pool daemon configuration and operation
And the pool manager should have 2 "bar" worker child processes
And the pool manager should have 3 "bar,baz" worker child processes
When I send the pool manager the "QUIT" signal
- Then the pool manager should finish
+ Then the resque workers should all shutdown
+ And the pool manager should finish
And the pool manager should report that a "foo" worker has been reaped
And the pool manager should report that a "bar" worker has been reaped
And the pool manager should report that a "bar,baz" worker has been reaped
And the pool manager should report that it is finished
+
+ @wip
+ Scenario: daemonized
+ Given a directory named "log"
+ And a directory named "tmp/pids"
+ And a file named "config/resque-pool.yml" with:
+ """
+ foo: 2
+ bar: 4
+ "baz,quux": 4
+ """
+ When I run the pool manager as "resque-pool -d"
+ Then the pool manager should daemonize
+ And the pool manager should record its pid in "tmp/pids/resque-pool.pid"
+ Then the pool manager should log that 10 workers are in the pool
+ And the pool manager should have 2 "foo" worker child processes
+ And the pool manager should have 4 "bar" worker child processes
+ And the pool manager should have 4 "baz,quux" worker child processes
+ When I send the pool manager the "QUIT" signal
+ Then the resque workers should all shutdown
+ And the pool manager daemon should finish
+ And the pool manager should log that a "foo" worker has been reaped
+ And the pool manager should log that a "bar" worker has been reaped
+ And the pool manager should log that a "bar,baz" worker has been reaped
+ And the pool manager should log that it is finished
@@ -33,10 +33,19 @@
Then /^the pool manager should report that (\d+) workers are in the pool$/ do |count|
count = Integer(count)
announce "TODO: check output for worker started messages"
- pid_regex = (1..count).map { '\d+' }.join ', '
- Then "the output should match:", <<-EOF
-resque-pool-manager\\[\\d+\\]: Pool contains worker PIDs: \\[#{pid_regex}\\]
- EOF
+ pid_regex = (1..count).map { '(\d+)' }.join ', '
+ full_regex = /resque-pool-manager\[\d+\]: Pool contains worker PIDs: \[#{pid_regex}\]/m
+ output = all_output
+ output.should =~ full_regex
+ @worker_pids = full_regex.match(output).captures.map {|pid| pid.to_i }
+end
+
+Then /^the resque workers should all shutdown$/ do
+ @worker_pids.each do |pid|
+ keep_trying do
+ lambda { Process.kill(0, pid) }.should raise_error(Errno::ESRCH)
+ end
+ end
end
def children_of(ppid)
@@ -11,7 +11,7 @@ def keep_trying(timeout=10, tries=0)
announce "Try: #{tries}" if @announce_env
yield
rescue RSpec::Expectations::ExpectationNotMetError
- if tries < 10
+ if tries < timeout
sleep 1
tries += 1
retry

0 comments on commit 51a1628

Please sign in to comment.