summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 22:30:27 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-30 22:30:27 +0000
commit34e779fcf2bfed1c6874084af6c99e072c4ecc7f (patch)
treec8d6cf6d26d8b6dfda7b7fe8f814f0e29cfd66de /test
parent24f07e0686cc9d81452d33daf215fa050ec89129 (diff)
downloadpuppet-34e779fcf2bfed1c6874084af6c99e072c4ecc7f.tar.gz
puppet-34e779fcf2bfed1c6874084af6c99e072c4ecc7f.tar.xz
puppet-34e779fcf2bfed1c6874084af6c99e072c4ecc7f.zip
Significantly redoing metrics. There are now no class variables for metrics, nor no class methods for it.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1350 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r--test/other/metrics.rb42
-rwxr-xr-xtest/other/report.rb34
-rwxr-xr-xtest/server/report.rb16
3 files changed, 67 insertions, 25 deletions
diff --git a/test/other/metrics.rb b/test/other/metrics.rb
index 4cbc1ff1e..c6a563bb2 100644
--- a/test/other/metrics.rb
+++ b/test/other/metrics.rb
@@ -36,21 +36,27 @@ if $haverrd
typehash[type] = Hash.new(0)
}
eventdata = Hash.new(0)
- types.each { |type|
- name = type.name
- typedata[type] = {}
- typedata[type][:total] = rand(totalmax)
- typedata[type][:managed] = rand(typedata[type][:total])
- typedata[type][:outofsync] = rand(typedata[type][:managed])
- typedata[type][:changed] = rand(typedata[type][:outofsync])
- typedata[type][:totalchanges] = rand(changemax)
- }
+ typedata = {}
+ typedata[:total] = rand(totalmax)
+ typedata[:managed] = rand(typedata[:total])
+ typedata[:outofsync] = rand(typedata[:managed])
+ typedata[:changed] = rand(typedata[:outofsync])
+ typedata[:totalchanges] = rand(changemax)
events.each { |event|
eventdata[event] = rand(eventmax)
}
- return [typedata,eventdata]
+ return {:typedata => typedata, :eventdata => eventdata}
+ end
+
+ def rundata(report, time)
+ assert_nothing_raised {
+ gendata.each do |name, data|
+ report.newmetric(name, data)
+ end
+ report.metrics.each { |n, m| m.store(time) }
+ }
end
def setup
@@ -59,24 +65,20 @@ if $haverrd
end
def test_fakedata
- assert_nothing_raised { Puppet::Metric.init }
+ report = Puppet::Transaction::Report.new
time = Time.now.to_i
start = time
10.times {
- assert_nothing_raised { Puppet::Metric.load(gendata) }
- assert_nothing_raised { Puppet::Metric.tally }
- assert_nothing_raised { Puppet::Metric.store(time) }
- assert_nothing_raised { Puppet::Metric.clear }
+ rundata(report, time)
time += 300
}
- assert_nothing_raised { Puppet::Metric.load(gendata) }
- assert_nothing_raised { Puppet::Metric.tally }
- assert_nothing_raised { Puppet::Metric.store(time) }
- assert_nothing_raised { Puppet::Metric.graph([start,time]) }
+ rundata(report, time)
+
+ report.metrics.each do |n, m| m.graph end
File.open(File.join(Puppet[:rrddir],"index.html"),"w") { |of|
of.puts "<html><body>"
- Puppet::Metric.each { |metric|
+ report.metrics.each { |name, metric|
of.puts "<img src=%s.png><br>" % metric.name
}
}
diff --git a/test/other/report.rb b/test/other/report.rb
index 8d6f8541c..8b3cb9517 100755
--- a/test/other/report.rb
+++ b/test/other/report.rb
@@ -59,6 +59,40 @@ class TestReports < Test::Unit::TestCase
)
}
end
+
+ def test_rrdgraph_report
+ Puppet.config.use(:metrics)
+ # First do some work
+ objects = []
+ 25.times do |i|
+ file = tempfile()
+
+ # Make every third file
+ File.open(file, "w") { |f| f.puts "" } if i % 3 == 0
+
+ objects << Puppet::Type.newfile(
+ :path => file,
+ :ensure => "file"
+ )
+ end
+
+ comp = newcomp(*objects)
+
+ trans = nil
+ assert_nothing_raised("Failed to create transaction") {
+ trans = comp.evaluate
+ }
+
+ assert_nothing_raised("Failed to evaluate transaction") {
+ trans.evaluate
+ }
+
+ code = Puppet::Server::Report.report("rrdgraph")
+
+ assert_nothing_raised {
+ code.call(trans.report)
+ }
+ end
end
# $Id$
diff --git a/test/server/report.rb b/test/server/report.rb
index 927052936..ba3bece4b 100755
--- a/test/server/report.rb
+++ b/test/server/report.rb
@@ -34,11 +34,14 @@ class TestServerRunner < Test::Unit::TestCase
def test_report
# Create a bunch of log messages in an array.
- report = []
+ report = Puppet::Transaction::Report.new
+
10.times { |i|
- report << info("Report test message %s" % i)
- report[-1].tags = %w{a list of tags}
- report[-1].tags << "tag%s" % i
+ log = info("Report test message %s" % i)
+ log.tags = %w{a list of tags}
+ log.tags << "tag%s" % i
+
+ report.newlog(log)
}
# Now make our reporting client
@@ -61,13 +64,16 @@ class TestServerRunner < Test::Unit::TestCase
}
# Make sure our report is valid and stuff.
- report.zip(newreport).each do |ol,nl|
+ report.logs.zip(newreport.logs).each do |ol,nl|
%w{level message time tags source}.each do |method|
assert_equal(ol.send(method), nl.send(method),
"%s got changed" % method)
end
end
end
+
+ def test_rrdgraph_report
+ end
end
# $Id$