diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-06 19:03:05 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-06 19:03:05 +0000 |
| commit | 46d344b9daa24047b60183cc94509d306b6b562a (patch) | |
| tree | 3c11eaad696ba3d6e6dd40bd7b9e7d1a4a71af85 /test/network/handler/runner.rb | |
| parent | 68233706a9ff05be8fa8ab3ab7198cd0918517d6 (diff) | |
| download | puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.gz puppet-46d344b9daa24047b60183cc94509d306b6b562a.tar.xz puppet-46d344b9daa24047b60183cc94509d306b6b562a.zip | |
Merging the webserver_portability branch from version 2182 to version 2258.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2259 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/network/handler/runner.rb')
| -rwxr-xr-x | test/network/handler/runner.rb | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/test/network/handler/runner.rb b/test/network/handler/runner.rb new file mode 100755 index 000000000..5c3acde2b --- /dev/null +++ b/test/network/handler/runner.rb @@ -0,0 +1,105 @@ +#!/usr/bin/env ruby + +$:.unshift("../../lib") if __FILE__ =~ /\.rb$/ + +require 'puppettest' + +class TestHandlerRunner < Test::Unit::TestCase + include PuppetTest + + def mkclient(file) + master = nil + client = nil + # create our master + assert_nothing_raised() { + # this is the default server setup + master = Puppet::Network::Handler.master.new( + :Manifest => file, + :UseNodes => false, + :Local => true + ) + } + + # and our client + assert_nothing_raised() { + client = Puppet::Network::Client.master.new( + :Master => master + ) + } + + client + end + + def test_runner + FileUtils.mkdir_p(Puppet[:statedir]) + Puppet[:ignoreschedules] = false + # Okay, make our manifest + file = tempfile() + created = tempfile() + File.open(file, "w") do |f| + f.puts %{ + class yayness { + file { "#{created}": ensure => file, schedule => weekly } + } + + include yayness + } + end + + client = mkclient(file) + + runner = nil + assert_nothing_raised { + runner = Puppet::Network::Handler.runner.new + } + # First: tags + # Second: ignore schedules true/false + # Third: background true/false + # Fourth: whether file should exist true/false + [ + ["with no backgrounding", + nil, true, true, true], + ["in the background", + nil, true, false, true], + ["with a bad tag", + ["coolness"], true, false, false], + ["with another bad tag", + "coolness", true, false, false], + ["with a good tag", + ["coolness", "yayness"], true, false, true], + ["with another good tag", + ["yayness"], true, false, true], + ["with a third good tag", + "yayness", true, false, true], + ["with no tags", + "", true, false, true], + ["not ignoring schedules", + nil, false, false, false], + ["ignoring schedules", + nil, true, false, true], + ].each do |msg, tags, ignore, fg, shouldexist| + if FileTest.exists?(created) + File.unlink(created) + end + assert_nothing_raised { + # Try it without backgrounding + runner.run(tags, ignore, fg) + } + + unless fg + Puppet.join + end + + if shouldexist + assert(FileTest.exists?(created), "File did not get created " + + msg) + else + assert(!FileTest.exists?(created), "File got created incorrectly " + + msg) + end + end + end +end + +# $Id$ + |
