summaryrefslogtreecommitdiffstats
path: root/test/other
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-18 20:41:54 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-05-18 20:41:54 +0000
commitb3ea53cd99df84a93fe2f093d2224e711f49e5dd (patch)
tree848e3b2bc03865709e4b6e38f1536ebec99ba8b0 /test/other
parent93771b7935e544630c3416fda928a3820c615df2 (diff)
Adding a lot of structure to puppet.rb to make it easier to manage multiple objects in a single process, including making it easy to add threads. Added some testing for all of that.
Also added a "runner" server, meant to be started within puppetd, so that clients can have runs triggered from a central host git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1212 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/other')
-rwxr-xr-xtest/other/puppet.rb93
1 files changed, 93 insertions, 0 deletions
diff --git a/test/other/puppet.rb b/test/other/puppet.rb
new file mode 100755
index 000000000..966c574d4
--- /dev/null
+++ b/test/other/puppet.rb
@@ -0,0 +1,93 @@
+if __FILE__ == $0
+ $:.unshift '..'
+ $:.unshift '../../lib'
+ $puppetbase = "../.."
+end
+
+require 'puppet'
+require 'puppet/parsedfile'
+require 'puppettest'
+require 'test/unit'
+
+# Test the different features of the main puppet module
+class TestPuppetModule < Test::Unit::TestCase
+ include TestPuppet
+ include SignalObserver
+ def mktestclass
+ Class.new do
+ def initialize(file)
+ @file = file
+ end
+
+ def started?
+ FileTest.exists?(@file)
+ end
+
+ def start
+ File.open(@file, "w") do |f| f.puts "" end
+ end
+
+ def shutdown
+ File.unlink(@file)
+ end
+ end
+ end
+
+ # Make sure that services get correctly started and stopped
+ def test_servicehandling
+ file = tempfile()
+ testclass = mktestclass()
+
+ obj = testclass.new(file)
+
+ assert_nothing_raised {
+ Puppet.newservice(obj)
+ }
+
+ assert_nothing_raised {
+ Puppet.start(false)
+ }
+
+ # Give it a sec or so
+ sleep 0.3
+
+ assert(obj.started?, "Object was not started")
+
+ assert_nothing_raised {
+ Puppet.shutdown(false)
+ }
+ # Give it a sec or so
+ sleep 0.3
+
+ assert(!obj.started?, "Object is still running")
+
+ end
+
+ # Make sure timers are being handled correctly
+ def test_timerhandling
+ timer = nil
+ file = tempfile()
+ assert_nothing_raised {
+ timer = Puppet.newtimer(
+ :interval => 0.1,
+ :tolerance => 1,
+ :start? => true
+ ) do
+ File.open(file, "w") do |f| f.puts "" end
+ Puppet.shutdown(false)
+ end
+ }
+
+ assert(timer, "Did not get timer back from Puppet")
+
+ assert_nothing_raised {
+ timeout(1) do
+ Puppet.start()
+ end
+ }
+
+ assert(FileTest.exists?(file), "timer never got triggered")
+ end
+end
+
+# $Id$