[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:30:43 UTC 2010


The following commit has been merged in the upstream branch:
commit 4be86015bd0a663f9e662186f7acbf8c3c8b421f
Author: Luke Kanies <luke at madstop.com>
Date:   Sun Nov 1 15:09:43 2009 -0500

    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 at madstop.com>

diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb
index 370938c..da282ec 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 6d365a5..45a249f 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 96dd37d..5503ad3 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 e576f23..478c941 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

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list