This patches two leaks in the puppetmasterd integration tests that were
preventing the script from succesfully connecting to its child
puppetmasterd process more than once:
1) a race condition in shutting down puppetmasterd before restarting
it
2) holding onto stale SSH certificate information.

Signed-off-by: Jesse Wolfe <[email protected]>
---
 spec/integration/bin/puppetmasterd.rb |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/spec/integration/bin/puppetmasterd.rb 
b/spec/integration/bin/puppetmasterd.rb
index 27b0f52..f1d77ef 100755
--- a/spec/integration/bin/puppetmasterd.rb
+++ b/spec/integration/bin/puppetmasterd.rb
@@ -16,6 +16,10 @@ describe "puppetmasterd" do
         Puppet[:certdnsnames] = "localhost"
 
         @@port = 12345
+
+        Puppet::SSL::Host.instance_eval{
+            @value_cache = {}
+        }
     end
 
     after {
@@ -48,7 +52,7 @@ describe "puppetmasterd" do
             f.puts { "notify { testing: }" }
         end
 
-        args = arguments + addl_args
+        args = arguments + " " + addl_args
 
         bin = File.join(File.dirname(__FILE__), "..", "..", "..", "sbin", 
"puppetmasterd")
         lib = File.join(File.dirname(__FILE__), "..", "..", "..", "lib")
@@ -56,9 +60,22 @@ describe "puppetmasterd" do
     end
 
     def stop
-        if @pidfile and FileTest.exist?(@pidfile)
+        if @pidfile and File.exist?(@pidfile)
             pid = File.read(@pidfile).chomp.to_i
             Process.kill(:TERM, pid)
+            10.times do
+                break unless File.exist?(@pidfile)
+                sleep 1
+            end
+            begin
+                # sigkill and report if process was still running
+                Process.kill(:KILL, pid)
+
+                raise "Process didn't die from SIGTERM after 10 seconds"
+            rescue Errno::ESRCH
+                # process wasn't running. good.
+            end
+
         end
     end
 
@@ -73,16 +90,10 @@ describe "puppetmasterd" do
     it "should be serving status information over xmlrpc" do
         start
 
-        sleep 5
+        sleep 6
 
         client = Puppet::Network::Client.status.new(:Server => "localhost", 
:Port => @@port)
 
-        FileUtils.mkdir_p(File.dirname(Puppet[:autosign]))
-        File.open(Puppet[:autosign], "w") { |f|
-            f.puts Puppet[:certname]
-        }
-
-        client.cert
         retval = client.status
 
         retval.should == 1
-- 
1.6.3.3

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to