From bcb32e59353b660c6ec4701ca41673d1fca257c0 Mon Sep 17 00:00:00 2001 From: Tyler Brock Date: Wed, 15 Feb 2012 18:17:24 -0500 Subject: [PATCH] minor: wait for mongod to die when we kill it during replica set tests --- test/tools/repl_set_manager.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/tools/repl_set_manager.rb b/test/tools/repl_set_manager.rb index 3c3922f..4bc5b37 100644 --- a/test/tools/repl_set_manager.rb +++ b/test/tools/repl_set_manager.rb @@ -172,12 +172,27 @@ class ReplSetManager con.close ensure_up end + + def wait_for_death(pid) + @retries.times do + if `ps a | grep mongod`.include?("#{pid}") + puts "waiting for mongod @ pid #{pid} to die..." + sleep(1) + else + puts "mongod @ pid #{pid} was killed successfully" + return true + end + end + puts "mongod never died" + return false + end def kill(node, signal=2) pid = @mongods[node]['pid'] puts "** Killing node with pid #{pid} at port #{@mongods[node]['port']}" system("kill #{pid}") - @mongods[node]['up'] = false + dead = wait_for_death(pid) + @mongods[node]['up'] = false if dead end def kill_primary(signal=2)