diff options
-rw-r--r-- | lib/puppet/agent.rb | 7 | ||||
-rwxr-xr-x | spec/unit/agent.rb | 21 |
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/puppet/agent.rb b/lib/puppet/agent.rb index e7d40f68c..438b668a6 100644 --- a/lib/puppet/agent.rb +++ b/lib/puppet/agent.rb @@ -37,7 +37,7 @@ class Puppet::Agent # Perform a run with our client. def run - if client + if running? Puppet.notice "Run of %s already in progress; skipping" % client_class return end @@ -56,11 +56,6 @@ class Puppet::Agent end end - # If the client instance is set, we're mid-run. - def running? - ! client.nil? - end - def stop if self.stopping? Puppet.notice "Already in shutdown" diff --git a/spec/unit/agent.rb b/spec/unit/agent.rb index 03136c484..da1cadea5 100755 --- a/spec/unit/agent.rb +++ b/spec/unit/agent.rb @@ -37,6 +37,7 @@ describe Puppet::Agent do client.expects(:run) + @agent.stubs(:running?).returns false @agent.run end @@ -45,23 +46,29 @@ describe Puppet::Agent do @agent.lockfile_path.should == "/my/lock" end - it "should be considered running if a client instance is available" do - client = AgentTestClient.new - AgentTestClient.expects(:new).returns client + it "should be considered running if the lock file is locked" do + lockfile = mock 'lockfile' - client.expects(:run).with { @agent.should be_running } - @agent.run + @agent.expects(:lockfile).returns lockfile + lockfile.expects(:locked?).returns true + + @agent.should be_running end describe "when being run" do + before do + @agent.stubs(:running?).returns false + end + it "should splay" do @agent.expects(:splay) + @agent.stubs(:running?).returns false @agent.run end it "should do nothing if already running" do - @agent.expects(:client).returns "eh" + @agent.expects(:running?).returns true AgentTestClient.expects(:new).never @agent.run end @@ -205,6 +212,8 @@ describe Puppet::Agent do it "should run within the block passed to the timer" do timer = stub 'timer', :sound_alarm => nil EventLoop::Timer.expects(:new).returns(timer).yields + @agent.expects(:run) + @agent.start end end |