summaryrefslogtreecommitdiffstats
path: root/test/network/server/runner.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-08 02:22:57 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-02-08 02:22:57 +0000
commita216df2bcb304ad379e152f2f59ef7d942f54f3b (patch)
treeeef3289c588cf44373fe959619d732c5a05ab7b5 /test/network/server/runner.rb
parent7e07e3dc843798bdbc7a03428ca054adaff2fb72 (diff)
Okay, last file moves for the night. The test code has been moved to match the lib directory, and I have moved a couple of things into network/ instead of network/server, since they did not belong as much.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2180 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/network/server/runner.rb')
-rwxr-xr-xtest/network/server/runner.rb106
1 files changed, 106 insertions, 0 deletions
diff --git a/test/network/server/runner.rb b/test/network/server/runner.rb
new file mode 100755
index 000000000..ce782298a
--- /dev/null
+++ b/test/network/server/runner.rb
@@ -0,0 +1,106 @@
+#!/usr/bin/env ruby
+
+$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
+
+require 'puppet/network/server/runner'
+require 'puppettest'
+
+class TestServerRunner < 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::Server::Master.new(
+ :Manifest => file,
+ :UseNodes => false,
+ :Local => true
+ )
+ }
+
+ # and our client
+ assert_nothing_raised() {
+ client = Puppet::Network::Client::MasterClient.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::Server::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$
+