summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/event.rb10
-rw-r--r--lib/puppet/statechange.rb15
-rw-r--r--test/other/tc_transactions.rb50
3 files changed, 49 insertions, 26 deletions
diff --git a/lib/puppet/event.rb b/lib/puppet/event.rb
index cb120bc28..86893f6d1 100644
--- a/lib/puppet/event.rb
+++ b/lib/puppet/event.rb
@@ -103,18 +103,18 @@ module Puppet
end
def initialize(args)
- unless args.include?(:event) and args.include?(:object)
+ unless args.include?(:event) and args.include?(:change)
raise "Event.new called incorrectly"
end
- @state = args[:state]
+ @change = args[:change]
@event = args[:event]
- @object = args[:object]
+ #@object = args[:object]
@transaction = args[:transaction]
#Puppet.info "%s: %s(%s)" %
- Puppet.info "%s: %s changed from %s to %s" %
- [@object,@state.name, @state.is,@state.should]
+ #Puppet.info "%s: %s changed from %s to %s" %
+ # [@object,@state.name, @state.is,@state.should]
# initially, just stuff all instances into a central bucket
# to be handled as a batch
diff --git a/lib/puppet/statechange.rb b/lib/puppet/statechange.rb
index 3aca38a39..257558513 100644
--- a/lib/puppet/statechange.rb
+++ b/lib/puppet/statechange.rb
@@ -58,10 +58,12 @@ module Puppet
# i should maybe include object type, but the event type
# should basically point to that, right?
+ #:state => @state,
+ #:object => @state.parent,
+ Puppet.info self.to_s
return Puppet::Event.new(
:event => event,
- :state => @state,
- :object => @state.parent,
+ :change => self,
:transaction => @transaction,
:message => self.to_s
)
@@ -74,10 +76,12 @@ module Puppet
#if pname.is_a?(Symbol)
# pname = pname.id2name
#end
+ #:state => @state,
+ #:object => @state.parent,
+ Puppet.info "Failed: " + self.to_s
return Puppet::Event.new(
:event => pname + "_failed",
- :state => @state,
- :object => @state.parent,
+ :change => self,
:transaction => @transaction,
:message => "Failed: " + self.to_s
)
@@ -121,7 +125,8 @@ module Puppet
#---------------------------------------------------------------
def to_s
- return "%s: %s => %s" % [@state,@is,@should]
+ return "%s: %s changed %s to %s" %
+ [@state.parent, @state.name, @is, @should]
end
#---------------------------------------------------------------
end
diff --git a/test/other/tc_transactions.rb b/test/other/tc_transactions.rb
index 3383b3b34..fc849c04b 100644
--- a/test/other/tc_transactions.rb
+++ b/test/other/tc_transactions.rb
@@ -193,20 +193,29 @@ class TestTransactions < Test::Unit::TestCase
}
# this should cause a restart of the service
+ events = nil
assert_nothing_raised() {
- transaction.evaluate
+ events = transaction.evaluate
}
- fakevent = Puppet::Event.new(
- :event => :ALL_EVENTS,
- :object => self,
- :transaction => transaction,
- :message => "yay"
- )
+ event = events.pop
+
+ assert(event)
+
+ #fakevent = nil
+ #assert_nothing_raised {
+ # fakevent = Puppet::Event.new(
+ # :event => :ALL_EVENTS,
+ # :object => file,
+ # :state => file.state(:mode),
+ # :transaction => transaction,
+ # :message => "yay"
+ # )
+ #}
sub = nil
assert_nothing_raised() {
- sub = file.subscribers?(fakevent)
+ sub = file.subscribers?(event)
}
assert(sub)
@@ -256,20 +265,29 @@ class TestTransactions < Test::Unit::TestCase
}
# this should cause a restart of the service
+ events = nil
assert_nothing_raised() {
- transaction.evaluate
+ events = transaction.evaluate
}
- fakevent = Puppet::Event.new(
- :event => :ALL_EVENTS,
- :object => self,
- :transaction => transaction,
- :message => "yay"
- )
+ event = events.pop
+
+ assert(event)
+
+ #fakevent = nil
+ #assert_nothing_raised {
+ # fakevent = Puppet::Event.new(
+ # :event => :ALL_EVENTS,
+ # :object => file,
+ # :state => file.state(:mode),
+ # :transaction => transaction,
+ # :message => "yay"
+ # )
+ #}
sub = nil
assert_nothing_raised() {
- sub = fcomp.subscribers?(fakevent)
+ sub = file.subscribers?(event)
}
assert(sub)