diff options
| author | Luke Kanies <luke@madstop.com> | 2009-11-01 15:09:43 -0500 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | 4be86015bd0a663f9e662186f7acbf8c3c8b421f (patch) | |
| tree | 9a3ff142336ead0cecc2af9e659a3a6445a992b1 | |
| parent | 2aa579bdbd91db2cd9a154e0ead2b327fa9a8474 (diff) | |
| download | puppet-4be86015bd0a663f9e662186f7acbf8c3c8b421f.tar.gz puppet-4be86015bd0a663f9e662186f7acbf8c3c8b421f.tar.xz puppet-4be86015bd0a663f9e662186f7acbf8c3c8b421f.zip | |
Adding Transaction events to Transaction reports
This means that every event generated during a transaction,
with all of its metadata, will now be in the report.
Signed-off-by: Luke Kanies <luke@madstop.com>
| -rw-r--r-- | lib/puppet/transaction/event_manager.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/transaction/report.rb | 7 | ||||
| -rwxr-xr-x | spec/unit/transaction/event_manager.rb | 17 | ||||
| -rwxr-xr-x | spec/unit/transaction/report.rb | 17 |
4 files changed, 45 insertions, 2 deletions
diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb index 370938c5e..da282ec8e 100644 --- a/lib/puppet/transaction/event_manager.rb +++ b/lib/puppet/transaction/event_manager.rb @@ -13,6 +13,10 @@ class Puppet::Transaction::EventManager transaction.relationship_graph end + def report + transaction.report + end + # Respond to any queued events for this resource. def process_events(resource) restarted = false @@ -33,6 +37,8 @@ class Puppet::Transaction::EventManager def queue_event(resource, event) @events << event + report.register_event event + # Collect the targets of any subscriptions to those events. We pass # the parent resource in so it will override the source in the events, # since eval_generated children can't have direct relationships. diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 6d365a5f9..45a249f48 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -10,7 +10,7 @@ class Puppet::Transaction::Report indirects :report, :terminus_class => :processor - attr_accessor :logs, :metrics, :time, :host + attr_reader :events, :logs, :metrics, :host, :time # This is necessary since Marshall doesn't know how to # dump hash with default proc (see below @records) @@ -26,6 +26,7 @@ class Puppet::Transaction::Report def initialize @metrics = {} @logs = [] + @events = [] @host = Puppet[:certname] end @@ -44,6 +45,10 @@ class Puppet::Transaction::Report @metrics[metric.name] = metric end + def register_event(event) + @events << event + end + # Provide a summary of this report. def summary ret = "" diff --git a/spec/unit/transaction/event_manager.rb b/spec/unit/transaction/event_manager.rb index 96dd37d0a..5503ad380 100755 --- a/spec/unit/transaction/event_manager.rb +++ b/spec/unit/transaction/event_manager.rb @@ -20,15 +20,25 @@ describe Puppet::Transaction::EventManager do manager.relationship_graph.should == "mygraph" end + it "should delegate its report to the transaction" do + transaction = stub 'transaction' + manager = Puppet::Transaction::EventManager.new(transaction) + + transaction.expects(:report).returns "myreport" + + manager.report.should == "myreport" + end + describe "when queueing events" do before do - @transaction = stub 'transaction' @manager = Puppet::Transaction::EventManager.new(@transaction) @resource = stub("resource", :self_refresh? => false, :deleting => false) @graph = stub 'graph', :matching_edges => [], :resource => @resource + @report = stub 'report', :register_event => nil @manager.stubs(:relationship_graph).returns @graph + @manager.stubs(:report).returns @report @event = Puppet::Transaction::Event.new(:name => :foo, :resource => @resource) end @@ -100,6 +110,11 @@ describe Puppet::Transaction::EventManager do @manager.queue_event(@resource, @event) end + + it "should add each event to the transaction report's event list" do + @manager.report.expects(:register_event).with(@event) + @manager.queue_event(@resource, @event) + end end describe "when queueing events for a resource" do diff --git a/spec/unit/transaction/report.rb b/spec/unit/transaction/report.rb index e576f2393..478c941f5 100755 --- a/spec/unit/transaction/report.rb +++ b/spec/unit/transaction/report.rb @@ -10,6 +10,11 @@ describe Puppet::Transaction::Report do Puppet::Transaction::Report.new.host.should == "myhost" end + it "should return its host name as its name" do + r = Puppet::Transaction::Report.new + r.name.should == r.host + end + describe "when accepting logs" do before do @report = Puppet::Transaction::Report.new @@ -26,6 +31,18 @@ describe Puppet::Transaction::Report do end end + describe "when accepting events" do + before do + @report = Puppet::Transaction::Report.new + end + + it "should add each event to its event list" do + event = stub 'event' + @report.register_event event + @report.events.should be_include(event) + end + end + describe "when using the indirector" do it "should redirect :find to the indirection" do @indirection = stub 'indirection', :name => :report |
