summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPaul Berry <paul@puppetlabs.com>2010-12-29 15:33:14 -0800
committerPaul Berry <paul@puppetlabs.com>2010-12-30 11:53:16 -0800
commit716ee1cd76a2b30c10e715bca3e22896d9c4e36f (patch)
treee7ea2e94a99dd842abad74c417e9c104bc986dfa /spec
parent037eac4383ed5a5e9cdde765b607a180209bad1e (diff)
downloadpuppet-716ee1cd76a2b30c10e715bca3e22896d9c4e36f.tar.gz
puppet-716ee1cd76a2b30c10e715bca3e22896d9c4e36f.tar.xz
puppet-716ee1cd76a2b30c10e715bca3e22896d9c4e36f.zip
(#5715) Changed the type of metric names to always be strings.
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/indirector/report/rest_spec.rb28
-rwxr-xr-xspec/unit/transaction/report_spec.rb26
-rwxr-xr-xspec/unit/util/metric_spec.rb14
3 files changed, 32 insertions, 36 deletions
diff --git a/spec/integration/indirector/report/rest_spec.rb b/spec/integration/indirector/report/rest_spec.rb
index 7fa026b73..5b5b2ddd8 100644
--- a/spec/integration/indirector/report/rest_spec.rb
+++ b/spec/integration/indirector/report/rest_spec.rb
@@ -67,30 +67,26 @@ describe "Report REST Terminus" do
report = Puppet::Transaction::Report.new("apply")
resourcemetrics = {
- :total => 12,
- :out_of_sync => 20,
- :applied => 45,
- :skipped => 1,
- :restarted => 23,
- :failed_restarts => 1,
- :scheduled => 10
+ "total" => 12,
+ "out_of_sync" => 20,
+ "applied" => 45,
+ "skipped" => 1,
+ "restarted" => 23,
+ "failed_restarts" => 1,
+ "scheduled" => 10
}
report.add_metric(:resources, resourcemetrics)
timemetrics = {
- :resource1 => 10,
- :resource2 => 50,
- :resource3 => 40,
- :resource4 => 20,
+ "resource1" => 10,
+ "resource2" => 50,
+ "resource3" => 40,
+ "resource4" => 20,
}
report.add_metric(:times, timemetrics)
- report.add_metric(
- :changes,
-
- :total => 20
- )
+ report.add_metric(:changes, "total" => 20)
report.save
end
diff --git a/spec/unit/transaction/report_spec.rb b/spec/unit/transaction/report_spec.rb
index 96d464b7a..766d4f14d 100755
--- a/spec/unit/transaction/report_spec.rb
+++ b/spec/unit/transaction/report_spec.rb
@@ -101,22 +101,22 @@ describe Puppet::Transaction::Report do
describe "when computing exit status" do
it "should produce 2 if changes are present" do
report = Puppet::Transaction::Report.new("apply")
- report.add_metric("changes", {:total => 1})
- report.add_metric("resources", {:failed => 0})
+ report.add_metric("changes", {"total" => 1})
+ report.add_metric("resources", {"failed" => 0})
report.exit_status.should == 2
end
it "should produce 4 if failures are present" do
report = Puppet::Transaction::Report.new("apply")
- report.add_metric("changes", {:total => 0})
- report.add_metric("resources", {:failed => 1})
+ report.add_metric("changes", {"total" => 0})
+ report.add_metric("resources", {"failed" => 1})
report.exit_status.should == 4
end
it "should produce 6 if both changes and failures are present" do
report = Puppet::Transaction::Report.new("apply")
- report.add_metric("changes", {:total => 1})
- report.add_metric("resources", {:failed => 1})
+ report.add_metric("changes", {"total" => 1})
+ report.add_metric("resources", {"failed" => 1})
report.exit_status.should == 6
end
end
@@ -162,7 +162,7 @@ describe Puppet::Transaction::Report do
add_statuses(3)
@report.finalize_report
- metric(:resources, :total).should == 3
+ metric(:resources, "total").should == 3
end
Puppet::Resource::Status::STATES.each do |state|
@@ -170,7 +170,7 @@ describe Puppet::Transaction::Report do
add_statuses(3) { |status| status.send(state.to_s + "=", true) }
@report.finalize_report
- metric(:resources, state).should == 3
+ metric(:resources, state.to_s).should == 3
end
end
@@ -185,13 +185,13 @@ describe Puppet::Transaction::Report do
it "should provide the number of changes from the resource statuses and mark the report as 'changed'" do
add_statuses(3) { |status| 3.times { status << Puppet::Transaction::Event.new(:status => 'success') } }
@report.finalize_report
- metric(:changes, :total).should == 9
+ metric(:changes, "total").should == 9
@report.status.should == 'changed'
end
it "should provide a total even if there are no changes, and mark the report as 'unchanged'" do
@report.finalize_report
- metric(:changes, :total).should == 0
+ metric(:changes, "total").should == 0
@report.status.should == 'unchanged'
end
end
@@ -234,15 +234,15 @@ describe Puppet::Transaction::Report do
describe "for events" do
it "should provide the total number of events" do
add_statuses(3) do |status|
- 3.times { |i| status.add_event(Puppet::Transaction::Event.new) }
+ 3.times { |i| status.add_event(Puppet::Transaction::Event.new :status => 'success') }
end
@report.finalize_report
- metric(:events, :total).should == 9
+ metric(:events, "total").should == 9
end
it "should provide the total even if there are no events" do
@report.finalize_report
- metric(:events, :total).should == 0
+ metric(:events, "total").should == 0
end
Puppet::Transaction::Event::EVENT_STATUSES.each do |status_name|
diff --git a/spec/unit/util/metric_spec.rb b/spec/unit/util/metric_spec.rb
index 72571ee4a..600b88f85 100755
--- a/spec/unit/util/metric_spec.rb
+++ b/spec/unit/util/metric_spec.rb
@@ -59,7 +59,7 @@ describe Puppet::Util::Metric do
end
it "should support a label for values" do
- @metric.newvalue(:foo, 10, "label")
+ @metric.newvalue("foo", 10, "label")
@metric.values[0][1].should == "label"
end
@@ -69,19 +69,19 @@ describe Puppet::Util::Metric do
end
it "should return its values sorted by label" do
- @metric.newvalue(:foo, 10, "b")
- @metric.newvalue(:bar, 10, "a")
+ @metric.newvalue("foo", 10, "b")
+ @metric.newvalue("bar", 10, "a")
- @metric.values.should == [[:bar, "a", 10], [:foo, "b", 10]]
+ @metric.values.should == [["bar", "a", 10], ["foo", "b", 10]]
end
it "should use an array indexer method to retrieve individual values" do
- @metric.newvalue(:foo, 10)
- @metric[:foo].should == 10
+ @metric.newvalue("foo", 10)
+ @metric["foo"].should == 10
end
it "should return nil if the named value cannot be found" do
- @metric[:foo].should == 0
+ @metric["foo"].should == 0
end
# LAK: I'm not taking the time to develop these tests right now.