diff options
author | Rein Henrichs <reinh@reinh.com> | 2010-03-18 14:37:49 -0700 |
---|---|---|
committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
commit | 7403c6e34270c01bb342c128fb88064c257467fe (patch) | |
tree | 69f903d5050711a5012bf752aea58db5a5c739c0 | |
parent | de94f68a9e30379738722df3c52fc6bb7b056510 (diff) | |
download | puppet-7403c6e34270c01bb342c128fb88064c257467fe.tar.gz puppet-7403c6e34270c01bb342c128fb88064c257467fe.tar.xz puppet-7403c6e34270c01bb342c128fb88064c257467fe.zip |
[#3392] Better Rakefile, remove puppetmasterd spec
- Minor improvements to Rakefile spec task
- Remove puppetmasterd spec, to be run as part of the testing matrix
-rw-r--r-- | Rakefile | 24 | ||||
-rwxr-xr-x | spec/integration/bin/puppetmasterd.rb | 145 |
2 files changed, 6 insertions, 163 deletions
@@ -7,6 +7,8 @@ require './lib/puppet.rb' require 'rake' require 'rake/packagetask' require 'rake/gempackagetask' +require 'spec' +require 'spec/rake/spectask' Dir['tasks/**/*.rake'].each { |t| load t } @@ -38,24 +40,10 @@ end desc "Create the tarball and the gem - use when releasing" task :puppetpackages => [:create_gem, :package] -desc "Run the specs under spec/" -task :spec do - require 'spec' - require 'spec/rake/spectask' - begin -# require 'rcov' - rescue LoadError - end - - Spec::Rake::SpecTask.new do |t| - t.spec_opts = ['--format','s', '--loadby','mtime'] - t.spec_files = FileList['spec/**/*.rb'] - t.fail_on_error = false - if defined?(Rcov) - t.rcov = true - t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*'] - end - end +Spec::Rake::SpecTask.new do |t| + t.spec_opts = ['--format','s', '--loadby','mtime'] + t.pattern ='spec/{unit,integation}/**/*.rb' + t.fail_on_error = false end desc "Run the unit tests" diff --git a/spec/integration/bin/puppetmasterd.rb b/spec/integration/bin/puppetmasterd.rb deleted file mode 100755 index 095263570..000000000 --- a/spec/integration/bin/puppetmasterd.rb +++ /dev/null @@ -1,145 +0,0 @@ -#!/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 - - Puppet::SSL::Host.instance_eval{ - @value_cache = {} - } - 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 - - bin = File.join(File.dirname(__FILE__), "..", "..", "..", "sbin", "puppetmasterd") - lib = File.join(File.dirname(__FILE__), "..", "..", "..", "lib") - output = %x{/usr/bin/env ruby -I #{lib} #{bin} #{args}}.chomp - end - - def stop - 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 - - 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 6 - - client = Puppet::Network::Client.status.new(:Server => "localhost", :Port => @@port) - - 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" - - describe "when run for the first time" do - before do - @ssldir = File.join(@dir, 'ssl') - FileUtils.rm_r(@ssldir) if File.exists?(@ssldir) - end - - describe "with noop" do - it "should create its ssl directory" do - File.directory?(@ssldir).should be_false - start(' --noop') - File.directory?(@ssldir).should be_true - end - end - - describe "without noop" do - it "should create its ssl directory" do - File.directory?(@ssldir).should be_false - start - File.directory?(@ssldir).should be_true - end - end - end -end |