diff options
author | Luke Kanies <luke@madstop.com> | 2005-07-12 15:04:52 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-07-12 15:04:52 +0000 |
commit | a984d6604cf2463183fc1f3eac0cb94fbd545f59 (patch) | |
tree | 3ed064ee8d9e5ebe67cfa371def9bb3a3ea4775b /test | |
parent | 78bcfdc1e21e7ad4d89b990fd0cf6d87db563d51 (diff) | |
download | puppet-a984d6604cf2463183fc1f3eac0cb94fbd545f59.tar.gz puppet-a984d6604cf2463183fc1f3eac0cb94fbd545f59.tar.xz puppet-a984d6604cf2463183fc1f3eac0cb94fbd545f59.zip |
disabling metrics tests on machines missing RRD
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@380 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test')
-rw-r--r-- | test/other/tc_metrics.rb | 117 |
1 files changed, 64 insertions, 53 deletions
diff --git a/test/other/tc_metrics.rb b/test/other/tc_metrics.rb index f111ea792..0e4519b24 100644 --- a/test/other/tc_metrics.rb +++ b/test/other/tc_metrics.rb @@ -11,71 +11,82 @@ require 'test/unit' # $Id$ -class TestMetric < Test::Unit::TestCase +$haverrd = true +begin + require 'RRD' +rescue LoadError + $haverrd = false +end - def gendata - totalmax = 1000 - changemax = 1000 - eventmax = 10 - maxdiff = 10 +if $haverrd + class TestMetric < Test::Unit::TestCase - types = [Puppet::Type::PFile, Puppet::Type::Package, Puppet::Type::Service] - data = [:total, :managed, :outofsync, :changed, :totalchanges] - events = [:file_changed, :package_installed, :service_started] + def gendata + totalmax = 1000 + changemax = 1000 + eventmax = 10 + maxdiff = 10 - # if this is the first set of data points... - typedata = Hash.new { |typehash,type| - 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) - } + types = [Puppet::Type::PFile, Puppet::Type::Package, Puppet::Type::Service] + data = [:total, :managed, :outofsync, :changed, :totalchanges] + events = [:file_changed, :package_installed, :service_started] - events.each { |event| - eventdata[event] = rand(eventmax) - } + # if this is the first set of data points... + typedata = Hash.new { |typehash,type| + 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) + } - return [typedata,eventdata] - end + events.each { |event| + eventdata[event] = rand(eventmax) + } - def setup - Puppet[:rrddir] = File.join(Dir.getwd,"rrdtests") - Puppet[:rrdgraph] = true - Puppet[:loglevel] = :debug if __FILE__ == $0 - end + return [typedata,eventdata] + end - def teardown - system("rm -rf rrdtests") - end + def setup + Puppet[:rrddir] = File.join(Dir.getwd,"rrdtests") + Puppet[:rrdgraph] = true + Puppet[:loglevel] = :debug if __FILE__ == $0 + end - def test_fakedata - assert_nothing_raised { Puppet::Metric.init } - time = Time.now.to_i - start = time - 10.times { + def teardown + system("rm -rf rrdtests") + end + + def test_fakedata + assert_nothing_raised { Puppet::Metric.init } + 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 } + 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.clear } - 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]) } + assert_nothing_raised { Puppet::Metric.graph([start,time]) } - File.open(File.join(Puppet[:rrddir],"index.html"),"w") { |of| - of.puts "<html><body>" - Puppet::Metric.each { |metric| - of.puts "<img src=%s.png><br>" % metric.name + File.open(File.join(Puppet[:rrddir],"index.html"),"w") { |of| + of.puts "<html><body>" + Puppet::Metric.each { |metric| + of.puts "<img src=%s.png><br>" % metric.name + } } - } + end end +else + $stderr.puts "Missing RRD library -- skipping metric tests" end |