From 88d3400e5bee4f523546e56a87ca108f1a37decc Mon Sep 17 00:00:00 2001 From: Hunter Haugen Date: Thu, 20 Oct 2011 17:08:33 -0700 Subject: [PATCH] Adding spec test for dead process --- agent/puppetd/spec/puppetd_agent_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/agent/puppetd/spec/puppetd_agent_spec.rb b/agent/puppetd/spec/puppetd_agent_spec.rb index 0d7469d..dd1ae61 100755 --- a/agent/puppetd/spec/puppetd_agent_spec.rb +++ b/agent/puppetd/spec/puppetd_agent_spec.rb @@ -149,6 +149,19 @@ result.should be_successful end + it "with puppet agent stopped but PID file present" do + File.expects(:exists?).with("spec_test_lock_file").returns(false) + File.expects(:exists?).with("spec_test_pid_file").returns(true) + File.expects(:read).with("spec_test_pid_file").returns("99999999\n") + ::Process.expects(:kill).with(0, 99999999).raises(Errno::ESRCH) + ::Process.expects(:kill).with("USR1", 99999999).never + @agent.instance_variable_set("@puppetd", "spec_test_puppetd") + @agent.expects(:run).with("spec_test_puppetd --onetime", :stdout => :output, :chomp => true) + result = @agent.call(:runonce) + result[:statusmsg].should == "OK" + result.should be_successful + end + it "with PID file containing rubbish" do File.expects(:exists?).with("spec_test_lock_file").returns(false) File.expects(:exists?).with("spec_test_pid_file").returns(true)