From 330359015602eba83077fccaa708c819d2d78b53 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 7 May 2008 12:29:58 -0500 Subject: The master and client now successfully speak xmlrpc using the new system. The server is actually serving REST, but the client can't use it until we resolve the format and security issues that REST hasn't yet tackled. --- spec/integration/bin/puppetmasterd.rb | 109 +++++++++++++++++++++++++++++ spec/integration/network/server/webrick.rb | 2 + spec/integration/ssl/host.rb | 2 + spec/unit/ssl/certificate_authority.rb | 2 +- 4 files changed, 114 insertions(+), 1 deletion(-) create mode 100755 spec/integration/bin/puppetmasterd.rb (limited to 'spec') diff --git a/spec/integration/bin/puppetmasterd.rb b/spec/integration/bin/puppetmasterd.rb new file mode 100755 index 000000000..447344472 --- /dev/null +++ b/spec/integration/bin/puppetmasterd.rb @@ -0,0 +1,109 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +describe "puppetmasterd" do + before do + # Get a safe temporary file + file = Tempfile.new("puppetmaster_integration_testing") + @dir = file.path + file.delete + + Dir.mkdir(@dir) + + Puppet.settings[:confdir] = @dir + Puppet.settings[:vardir] = @dir + Puppet[:certdnsnames] = "localhost" + + @@port = 12345 + end + + after { + stop + + Puppet::SSL::Host.ca_location = :none + + system("rm -rf %s" % @dir) + Puppet.settings.clear + } + + def arguments + rundir = File.join(Puppet[:vardir], "run") + @pidfile = File.join(rundir, "testing.pid") + args = "" + args += " --confdir %s" % Puppet[:confdir] + args += " --rundir %s" % rundir + args += " --pidfile %s" % @pidfile + args += " --vardir %s" % Puppet[:vardir] + args += " --certdnsnames %s" % Puppet[:certdnsnames] + args += " --masterport %s" % @@port + args += " --user %s" % Puppet::Util::SUIDManager.uid + args += " --group %s" % Puppet::Util::SUIDManager.gid + args += " --autosign true" + end + + def start(addl_args = "") + Puppet.settings.mkdir(:manifestdir) + Puppet.settings.write(:manifest) do |f| + f.puts { "notify { testing: }" } + end + + args = arguments + addl_args + + output = %x{puppetmasterd #{args}}.chomp + end + + def stop + if @pidfile and FileTest.exist?(@pidfile) + pid = File.read(@pidfile).chomp.to_i + Process.kill(:TERM, pid) + end + end + + it "should create a PID file" do + start + + FileTest.exist?(@pidfile).should be_true + end + + it "should be serving status information over REST" + + it "should be serving status information over xmlrpc" do + start + + sleep 0.5 + + 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 + end + + it "should exit with return code 0 after parsing if --parseonly is set and there are no errors" do + start(" --parseonly > /dev/null") + sleep(1) + + ps = Facter["ps"].value || "ps -ef" + pid = nil + %x{#{ps}}.chomp.split(/\n/).each { |line| + next if line =~ /^puppet/ # skip normal master procs + if line =~ /puppetmasterd.+--manifest/ + ary = line.split(" ") + pid = ary[1].to_i + end + } + + $?.should == 0 + + pid.should be_nil + end + + it "should exit with return code 1 after parsing if --parseonly is set and there are errors" +end diff --git a/spec/integration/network/server/webrick.rb b/spec/integration/network/server/webrick.rb index ab9e94605..f2b55ef92 100755 --- a/spec/integration/network/server/webrick.rb +++ b/spec/integration/network/server/webrick.rb @@ -28,6 +28,8 @@ describe Puppet::Network::Server do @tmpfile.delete Puppet.settings.clear + system("rm -rf %s" % @dir) + # This is necessary so the terminus instances don't lie around. Puppet::SSL::Key.indirection.clear_cache Puppet::SSL::Certificate.indirection.clear_cache diff --git a/spec/integration/ssl/host.rb b/spec/integration/ssl/host.rb index 5e457bded..d4834c341 100755 --- a/spec/integration/ssl/host.rb +++ b/spec/integration/ssl/host.rb @@ -32,6 +32,8 @@ describe Puppet::SSL::Host do # This is necessary so the terminus instances don't lie around. Puppet::SSL::Key.indirection.clear_cache + Puppet::SSL::Certificate.indirection.clear_cache + Puppet::SSL::CertificateRevocationList.indirection.clear_cache Puppet::SSL::CertificateRequest.indirection.clear_cache } diff --git a/spec/unit/ssl/certificate_authority.rb b/spec/unit/ssl/certificate_authority.rb index b0be0e450..a4581fb21 100755 --- a/spec/unit/ssl/certificate_authority.rb +++ b/spec/unit/ssl/certificate_authority.rb @@ -293,7 +293,7 @@ describe Puppet::SSL::CertificateAuthority do end it "should return the current content of the serial file" do - FileTest.expects(:exist?).with(@path).returns true + FileTest.stubs(:exist?).with(@path).returns true File.expects(:read).with(@path).returns "0002" @ca.next_serial.should == 2 -- cgit