diff options
-rw-r--r-- | lib/puppet/transaction.rb | 6 | ||||
-rw-r--r-- | lib/puppet/transaction/event_manager.rb | 6 | ||||
-rw-r--r-- | lib/puppet/transaction/report.rb | 12 | ||||
-rwxr-xr-x | spec/unit/transaction.rb | 7 | ||||
-rwxr-xr-x | spec/unit/transaction/event_manager.rb | 16 | ||||
-rwxr-xr-x | spec/unit/transaction/report.rb | 10 |
6 files changed, 20 insertions, 37 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 9da761a8c..b49d12266 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -330,8 +330,6 @@ class Puppet::Transaction @event_manager = Puppet::Transaction::EventManager.new(self) @resource_harness = Puppet::Transaction::ResourceHarness.new(self) - - @resource_status = {} end # Prefetch any providers that support it. We don't support prefetching @@ -399,11 +397,11 @@ class Puppet::Transaction end def add_resource_status(status) - @resource_status[status.resource] = status + report.add_resource_status status end def resource_status(resource) - @resource_status[resource.to_s] + report.resource_statuses[resource.to_s] end # Roll all completed changes back. diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb index 89c4b9297..a6ca8a229 100644 --- a/lib/puppet/transaction/event_manager.rb +++ b/lib/puppet/transaction/event_manager.rb @@ -13,10 +13,6 @@ 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 @@ -37,8 +33,6 @@ 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 5a0332f66..787ef19ad 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_reader :events, :logs, :metrics, :host, :time + attr_reader :resource_statuses, :logs, :metrics, :host, :time # This is necessary since Marshall doesn't know how to # dump hash with default proc (see below @records) @@ -23,10 +23,14 @@ class Puppet::Transaction::Report return self end + def add_resource_status(status) + @resource_statuses[status.resource] = status + end + def initialize @metrics = {} @logs = [] - @events = [] + @resource_statuses = {} @host = Puppet[:certname] @time = Time.now end @@ -46,10 +50,6 @@ 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.rb b/spec/unit/transaction.rb index fba2518a5..e2ab00748 100755 --- a/spec/unit/transaction.rb +++ b/spec/unit/transaction.rb @@ -29,6 +29,13 @@ describe Puppet::Transaction do @transaction.resource_status(resource.to_s).should equal(status) end + it "should add provided resource statuses to its report" do + resource = Puppet::Type.type(:notify).new :title => "foobar" + status = Puppet::Resource::Status.new(resource) + @transaction.add_resource_status(status) + @transaction.report.resource_statuses[resource.to_s].should equal(status) + end + it "should return nil when asked for a status that has not been created" do @transaction.resource_status("File[/foo]").should be_nil end diff --git a/spec/unit/transaction/event_manager.rb b/spec/unit/transaction/event_manager.rb index 5503ad380..7d8fb8afd 100755 --- a/spec/unit/transaction/event_manager.rb +++ b/spec/unit/transaction/event_manager.rb @@ -20,15 +20,6 @@ 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 @manager = Puppet::Transaction::EventManager.new(@transaction) @@ -36,9 +27,7 @@ describe Puppet::Transaction::EventManager do @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 @@ -110,11 +99,6 @@ 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 730f83bd4..5be625e1d 100755 --- a/spec/unit/transaction/report.rb +++ b/spec/unit/transaction/report.rb @@ -36,15 +36,15 @@ describe Puppet::Transaction::Report do end end - describe "when accepting events" do + describe "when accepting resource statuses" 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) + it "should add each status to its status list" do + status = stub 'status', :resource => "foo" + @report.add_resource_status status + @report.resource_statuses["foo"].should equal(status) end end |