[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:31:29 UTC 2010


The following commit has been merged in the upstream branch:
commit 9cb68417670d6bc98caf1169af4ecafb59f4c14c
Author: Ethan Rowe <ethan at endpoint.com>
Date:   Thu Jul 30 15:28:16 2009 -0400

    Fix 2239 (step four): Refactored Puppet::Daemon's stop/restart methods to set status flags appropriately in Puppet::Application, and removed call to now-deprecated @agent.configure_delayed_restart.  This should get the restart and stop behavior for daemons and their agents working nicely with the new global process status interface of Puppet::Application.

diff --git a/lib/puppet/daemon.rb b/lib/puppet/daemon.rb
index 0f538fe..b6dbf26 100755
--- a/lib/puppet/daemon.rb
+++ b/lib/puppet/daemon.rb
@@ -1,6 +1,7 @@
 require 'puppet'
 require 'puppet/util/pidlock'
 require 'puppet/external/event-loop'
+require 'puppet/application'
 
 # A module that handles operations common to all daemons.  This is included
 # into the Server and Client base classes.
@@ -83,11 +84,8 @@ class Puppet::Daemon
     end
 
     def restart
-        if agent and agent.running?
-            agent.configure_delayed_restart
-        else
-            reexec
-        end
+        Puppet::Application.restart!
+        reexec unless agent and agent.running?
     end
 
     def reopen_logs
@@ -107,9 +105,9 @@ class Puppet::Daemon
 
     # Stop everything
     def stop(args = {:exit => true})
-        server.stop if server
+        Puppet::Application.stop!
 
-        agent.stop if agent
+        server.stop if server
 
         remove_pidfile()
 
diff --git a/spec/unit/daemon.rb b/spec/unit/daemon.rb
index 960d79d..1bf8f56 100755
--- a/spec/unit/daemon.rb
+++ b/spec/unit/daemon.rb
@@ -3,6 +3,13 @@
 require File.dirname(__FILE__) + '/../spec_helper'
 require 'puppet/daemon'
 
+def without_warnings
+    flag = $VERBOSE
+    $VERBOSE = nil
+    yield
+    $VERBOSE = flag
+end
+
 describe Puppet::Daemon do
     before do
         @daemon = Puppet::Daemon.new
@@ -86,6 +93,14 @@ describe Puppet::Daemon do
             @daemon.stubs(:remove_pidfile)
             @daemon.stubs(:exit)
             Puppet::Util::Log.stubs(:close_all)
+            # to make the global safe to mock, set it to a subclass of itself,
+            # then restore it in an after pass
+            without_warnings { Puppet::Application = Class.new(Puppet::Application) }
+        end
+
+        after do
+            # restore from the superclass so we lose the stub garbage
+            without_warnings { Puppet::Application = Puppet::Application.superclass }
         end
 
         it "should stop its server if one is configured" do
@@ -96,11 +111,8 @@ describe Puppet::Daemon do
             @daemon.stop
         end
 
-        it "should stop its agent if one is configured" do
-            agent = mock 'agent'
-            agent.expects(:stop)
-            @daemon.stubs(:agent).returns agent
-
+        it 'should request a stop from Puppet::Application' do
+            Puppet::Application.expects(:stop!)
             @daemon.stop
         end
 
@@ -236,28 +248,31 @@ describe Puppet::Daemon do
     end
 
     describe "when restarting" do
-        it "should reexec itself if no agent is available" do
-            @daemon.expects(:reexec)
+        before do
+            without_warnings { Puppet::Application = Class.new(Puppet::Application) }
+        end
 
+        after do
+            without_warnings { Puppet::Application = Puppet::Application.superclass }
+        end
+
+        it 'should set Puppet::Application.restart!' do
+            Puppet::Application.expects(:restart!)
+            @daemon.stubs(:reexec)
             @daemon.restart
         end
 
-        it "should reexec itself if the agent is not running" do
-            agent = mock 'agent'
-            agent.expects(:running?).returns false
-            @daemon.stubs(:agent).returns agent
+        it "should reexec itself if no agent is available" do
             @daemon.expects(:reexec)
 
             @daemon.restart
         end
 
-        it "should configure the agent for later restart if the agent is running" do
+        it "should reexec itself if the agent is not running" do
             agent = mock 'agent'
-            agent.expects(:running?).returns true
+            agent.expects(:running?).returns false
             @daemon.stubs(:agent).returns agent
-            @daemon.expects(:reexec).never
-
-            agent.expects(:configure_delayed_restart)
+            @daemon.expects(:reexec)
 
             @daemon.restart
         end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list