summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-09-29 13:19:31 -0700
committerJohn Keiser <john@johnkeiser.com>2015-09-29 16:02:09 -0700
commit0eebff624051777537a61244db56ac159268e381 (patch)
tree0f1183d6d6a11988204f618e11602d16f30bd931 /spec
parentd8cb2cf50e6ccb275ee5c686ce14842d58376a16 (diff)
downloadchef-0eebff624051777537a61244db56ac159268e381.tar.gz
Add some insurance against timeouts failing (10s room, kill loop)
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/run_lock_spec.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index b66bc86f65..20e0ad4ccc 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -55,7 +55,7 @@ describe Chef::RunLock do
raise "Lockfile never created, abandoning test"
end
- CLIENT_PROCESS_TIMEOUT = 2
+ CLIENT_PROCESS_TIMEOUT = 10
BREATHING_ROOM = 1
# ClientProcess is defined below
@@ -382,11 +382,20 @@ describe Chef::RunLock do
if pid
example.log_event("#{name}.stop (pid #{pid})")
begin
- Process.kill(:KILL, pid)
- example.log_event("#{name}.stop kill signal sent (pid #{pid})")
- Timeout::timeout(CLIENT_PROCESS_TIMEOUT) do
- Process.waitpid2(pid)
+ # Send it the kill signal over and over until it dies
+ start_time = Time.now
+ dead = false
+ while Time.now - start_time < CLIENT_PROCESS_TIMEOUT
+ Process.kill(:KILL, pid)
+ Timeout::timeout(0.2) do
+ begin
+ Process.waitpid2(pid)
+ dead = true
+ rescue Timeout::Error
+ end
+ end
end
+ raise Timeout::Error, "took more than 10s to kill process #{pid}" if !dead
example.log_event("#{name}.stop finished (stopped pid #{pid})")
# Process not found is perfectly fine when we're trying to kill a process :)
rescue Errno::ESRCH