diff options
| author | Paul Berry <paul@puppetlabs.com> | 2010-12-16 16:23:34 -0800 |
|---|---|---|
| committer | Paul Berry <paul@puppetlabs.com> | 2010-12-17 11:02:12 -0800 |
| commit | 4d3030c6dd67dcb1f6116e7e3d09ddcd20ee726b (patch) | |
| tree | e62d0db3e04e0c3ebbfd806cc9966ac67ab0eff9 /spec/unit/transaction | |
| parent | 7fff7808e25491a5ea1e207b8de3ade0c4f95f4f (diff) | |
| download | puppet-4d3030c6dd67dcb1f6116e7e3d09ddcd20ee726b.tar.gz puppet-4d3030c6dd67dcb1f6116e7e3d09ddcd20ee726b.tar.xz puppet-4d3030c6dd67dcb1f6116e7e3d09ddcd20ee726b.zip | |
Modified the behavior of Puppet::Resource::Status as follows:
- #change_count now only counts events that represent successful
changes. It does not count failures, audits, or noops.
- #changed is equivalent to #change_count > 0.
- #out_of_sync_count (a new attribute) counts all events except audits.
- #out_of_sync is equivalent to #out_of_sync_count > 0.
This should hopefully make the summary statistics in reports more useful.
Diffstat (limited to 'spec/unit/transaction')
| -rwxr-xr-x | spec/unit/transaction/report_spec.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/transaction/resource_harness_spec.rb | 34 |
2 files changed, 31 insertions, 5 deletions
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb index 3b7c3b0bd..34c6ecd96 100755 --- a/spec/unit/transaction/report_spec.rb +++ b/spec/unit/transaction/report_spec.rb @@ -170,7 +170,7 @@ describe Puppet::Transaction::Report do describe "for changes" do it "should provide the number of changes from the resource statuses" do - add_statuses(3) { |status| 3.times { status << Puppet::Transaction::Event.new } } + add_statuses(3) { |status| 3.times { status << Puppet::Transaction::Event.new(:status => 'success') } } @report.calculate_metrics metric(:changes, :total).should == 9 end diff --git a/spec/unit/transaction/resource_harness_spec.rb b/spec/unit/transaction/resource_harness_spec.rb index d888b05ea..387deca61 100755 --- a/spec/unit/transaction/resource_harness_spec.rb +++ b/spec/unit/transaction/resource_harness_spec.rb @@ -180,10 +180,36 @@ describe Puppet::Transaction::ResourceHarness do expected_event_logs = @logs.reject {|l| l.message =~ /newly-recorded/ } status.events.map {|e| e.message}.should =~ expected_event_logs.map {|l| l.message } - # Check status summary fields - status.changed.should == (status.events.empty? ? nil : true) - status.out_of_sync.should == (status.events.empty? ? nil : true) - status.change_count.should == status.events.length + # Check change count - this is the number of changes that actually occurred. + expected_change_count = 0 + if (machine_state != nil) != file_should_be_there + expected_change_count = 1 + elsif machine_state != nil + if expected_file_mode != machine_state + expected_change_count = 1 + end + end + status.change_count.should == expected_change_count + + # Check out of sync count - this is the number + # of changes that would have occurred in + # non-noop mode. + expected_out_of_sync_count = 0 + if (machine_state != nil) != file_would_be_there_if_not_noop + expected_out_of_sync_count = 1 + elsif machine_state != nil + if mode_property != nil && mode_property != machine_state + expected_out_of_sync_count = 1 + end + end + if !noop_mode + expected_out_of_sync_count.should == expected_change_count + end + status.out_of_sync_count.should == expected_out_of_sync_count + + # Check legacy summary fields + status.changed.should == (expected_change_count == 0 ? nil : true) + status.out_of_sync.should == (expected_out_of_sync_count == 0 ? nil : true) # Check the :synced field on state.yml synced_should_be_set = !noop_mode && status.changed != nil |
