diff options
| author | Luke Kanies <luke@madstop.com> | 2009-10-29 00:23:05 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 2cbd9e85259ed1742f8a54a7e5b9825d0bb79d5e (patch) | |
| tree | bafbe77d88527b56c3d10a975180a1748fa971da /test | |
| parent | 6a450c51eedc38b73d79389c19b8d5e5964a9d71 (diff) | |
| download | puppet-2cbd9e85259ed1742f8a54a7e5b9825d0bb79d5e.tar.gz puppet-2cbd9e85259ed1742f8a54a7e5b9825d0bb79d5e.tar.xz puppet-2cbd9e85259ed1742f8a54a7e5b9825d0bb79d5e.zip | |
Switching transactions to callback-based events
Events are now queued as they are created, and
the queues are managed through simple interfaces,
rather than collecting events over time and
responding to them inline.
This drastically simplifies event management,
and will make moving it to a separate system
essentially trivial.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/lib/puppettest/support/utils.rb | 8 | ||||
| -rwxr-xr-x | test/other/events.rb | 124 |
2 files changed, 3 insertions, 129 deletions
diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index 5dd531200..405a0c54b 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -79,11 +79,9 @@ module PuppetTest::Support::Utils method = type - newevents = nil - assert_nothing_raised("Transaction %s %s failed" % [type, msg]) { - newevents = trans.send(method).reject { |e| e.nil? }.collect { |e| - e.name - } + trans.send(method) + newevents = trans.events.reject { |e| e.nil? }.collect { |e| + e.name } assert_equal(events, newevents, "Incorrect %s %s events" % [type, msg]) diff --git a/test/other/events.rb b/test/other/events.rb deleted file mode 100755 index 052afc0c9..000000000 --- a/test/other/events.rb +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../lib/puppettest' - -require 'puppet' -require 'puppettest' - - -class TestEvents < Test::Unit::TestCase - include PuppetTest - - def test_simplesubscribe - name = tempfile() - file = Puppet::Type.type(:file).new( - :name => name, - :ensure => "file" - ) - exec = Puppet::Type.type(:exec).new( - :name => "echo true", - :path => "/usr/bin:/bin", - :refreshonly => true, - :subscribe => Puppet::Resource::Reference.new(file.class.name, file.name) - ) - - comp = mk_catalog("eventtesting", file, exec) - - trans = assert_events([:file_created, :triggered], comp) - - assert_equal(1, trans.triggered?(exec, :refresh)) - end - - def test_simplerequire - name = tempfile() - file = Puppet::Type.type(:file).new( - :name => name, - :ensure => "file" - ) - exec = Puppet::Type.type(:exec).new( - :name => "echo true", - :path => "/usr/bin:/bin", - :refreshonly => true, - :require => Puppet::Resource::Reference.new(file.class.name, file.name) - ) - - - config = mk_catalog - config.add_resource file - config.add_resource exec - trans = config.apply - - assert_equal(1, trans.events.length) - - assert_equal(0, trans.triggered?(exec, :refresh)) - end - - def test_multiplerefreshes - files = [] - - 4.times { |i| - files << Puppet::Type.type(:file).new( - :name => tempfile(), - :ensure => "file" - ) - } - - fname = tempfile() - exec = Puppet::Type.type(:exec).new( - :name => "touch %s" % fname, - :path => "/usr/bin:/bin", - :refreshonly => true - ) - - exec[:subscribe] = files.collect { |f| - Puppet::Resource::Reference.new(:file, f.name) - } - - comp = mk_catalog(exec, *files) - - assert_apply(comp) - assert(FileTest.exists?(fname), "Exec file did not get created") - end - - # Make sure refreshing happens mid-transaction, rather than at the end. - def test_refreshordering - file = tempfile() - - exec1 = Puppet::Type.type(:exec).new( - :title => "one", - :name => "echo one >> %s" % file, - :path => "/usr/bin:/bin" - ) - - exec2 = Puppet::Type.type(:exec).new( - :title => "two", - :name => "echo two >> %s" % file, - :path => "/usr/bin:/bin", - :refreshonly => true, - :subscribe => exec1 - ) - - exec3 = Puppet::Type.type(:exec).new( - :title => "three", - :name => "echo three >> %s" % file, - :path => "/usr/bin:/bin", - :require => exec2 - ) - execs = [exec1, exec2, exec3] - - config = mk_catalog(exec1,exec2,exec3) - - trans = Puppet::Transaction.new(config) - execs.each do |e| assert(config.vertex?(e), "%s is not in graph" % e.title) end - trans.prepare - execs.each do |e| assert(config.vertex?(e), "%s is not in relgraph" % e.title) end - reverse = trans.relationship_graph.reversal - execs.each do |e| assert(reverse.vertex?(e), "%s is not in reversed graph" % e.title) end - - config.apply - - assert(FileTest.exists?(file), "File does not exist") - - assert_equal("one\ntwo\nthree\n", File.read(file)) - end -end |
