diff options
author | Luke Kanies <luke@madstop.com> | 2007-10-13 14:07:24 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-10-13 14:07:24 -0500 |
commit | 29feac0cecddc910b74601d0914fa2c83757b10c (patch) | |
tree | 888305ecde1e4a488304f7e2e169bf1ca38e6d19 /test | |
parent | 74d77f76a012d523430e43f1092609a4ca584cc7 (diff) | |
download | puppet-29feac0cecddc910b74601d0914fa2c83757b10c.tar.gz puppet-29feac0cecddc910b74601d0914fa2c83757b10c.tar.xz puppet-29feac0cecddc910b74601d0914fa2c83757b10c.zip |
Translating the report handler to an indirected model.
I've provided backward compatibility with the old
handler.
The only terminus type that currently exists for reports
is the 'code' terminus, which is used to process reports
in the style of the old handler. At some point, we should
likely switch at least some of these report types (e.g., 'store')
to terminus types.
Diffstat (limited to 'test')
-rwxr-xr-x | test/network/handler/report.rb | 103 | ||||
-rwxr-xr-x | test/other/report.rb | 13 |
2 files changed, 8 insertions, 108 deletions
diff --git a/test/network/handler/report.rb b/test/network/handler/report.rb index ac8cf6fac..76326bce6 100755 --- a/test/network/handler/report.rb +++ b/test/network/handler/report.rb @@ -31,46 +31,13 @@ class TestReportServer < Test::Unit::TestCase client end - def test_report_autoloading - # Create a fake report - fakedir = tempfile() - $: << fakedir - cleanup do $:.delete(fakedir) end - - libdir = File.join(fakedir, "puppet", "reports") - FileUtils.mkdir_p(libdir) - - $myreportrun = false - file = File.join(libdir, "myreport.rb") - File.open(file, "w") { |f| f.puts %{ - Puppet::Network::Handler.report.newreport(:myreport) do - def process(report) - $myreportrun = true - return report - end - end - } - } - Puppet[:reports] = "myreport" - - # Create a server - server = Puppet::Network::Handler.report.new - - report = nil - assert_nothing_raised { - report = Puppet::Network::Handler.report.report(:myreport) - } - assert(report, "Did not get report") - - end - def test_process server = Puppet::Network::Handler.report.new # We have to run multiple reports to make sure there's no conflict reports = [] $run = [] - 5.times do |i| + 2.times do |i| name = "processtest%s" % i reports << name @@ -100,35 +67,6 @@ class TestReportServer < Test::Unit::TestCase } end - # Make sure reports can specify whether to use yaml or not - def test_useyaml - server = Puppet::Network::Handler.report.new - - Report.newreport(:yamlyes, :useyaml => true) do - def process(report) - $yamlyes = :yesyaml - end - end - - Report.newreport(:yamlno) do - def process - $yamlno = :noyaml - end - end - - Puppet[:reports] = "yamlyes, yamlno" - - report = fakereport - yaml = YAML.dump(report) - - assert_nothing_raised do - server.send(:process, yaml) - end - - assert_equal(:noyaml, $yamlno, "YAML was used for non-yaml report") - assert_equal(:yesyaml, $yamlyes, "YAML was not used for yaml report") - end - def test_reports Puppet[:reports] = "myreport" @@ -142,43 +80,4 @@ class TestReportServer < Test::Unit::TestCase assert_equal(ary, server.send(:reports)) end end - - def test_newreport - name = :newreporttest - assert_nothing_raised do - Report.newreport(name) do - attr_accessor :processed - - def process(report) - @processed = report - end - end - end - - assert(Report.report(name), "Did not get report") - assert_instance_of(Module, Report.report(name)) - - obj = "yay" - obj.extend(Report.report(name)) - - assert_nothing_raised do - obj.process("yay") - end - - assert_equal("yay", obj.processed) - end - - # Make sure we get a list of all reports - def test_report_list - list = nil - assert_nothing_raised do - list = Puppet::Network::Handler.report.reports - end - - [:rrdgraph, :store, :tagmail].each do |name| - assert(list.include?(name), "Did not load %s" % name) - end - end end - - diff --git a/test/other/report.rb b/test/other/report.rb index 8f33a7166..bed510f2f 100755 --- a/test/other/report.rb +++ b/test/other/report.rb @@ -3,6 +3,7 @@ $:.unshift("../lib").unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'puppet' +require 'puppet/reports' require 'puppet/transaction/report' require 'puppettest' require 'puppettest/reporttesting' @@ -97,14 +98,14 @@ class TestReports < Test::Unit::TestCase } assert_nothing_raised do - report.extend(Puppet::Network::Handler.report.report(:store)) + report.extend(Puppet::Reports.report(:store)) end yaml = YAML.dump(report) file = nil assert_nothing_raised { - file = report.process(yaml) + file = report.process } assert(FileTest.exists?(file), "report file did not get created") @@ -119,7 +120,7 @@ class TestReports < Test::Unit::TestCase assert(! report.metrics.empty?, "Did not receive any metrics") assert_nothing_raised do - report.extend(Puppet::Network::Handler.report.report(:rrdgraph)) + report.extend(Puppet::Reports.report(:rrdgraph)) end assert_nothing_raised { @@ -154,7 +155,7 @@ class TestReports < Test::Unit::TestCase def test_tagmail_parsing report = Object.new - report.extend(Puppet::Network::Handler.report.report(:tagmail)) + report.extend(Puppet::Reports.report(:tagmail)) passers = File.join(datadir, "reports", "tagmail_passers.conf") assert(FileTest.exists?(passers), "no passers file %s" % passers) @@ -178,7 +179,7 @@ class TestReports < Test::Unit::TestCase def test_tagmail_parsing_results report = Object.new - report.extend(Puppet::Network::Handler.report.report(:tagmail)) + report.extend(Puppet::Reports.report(:tagmail)) # Now test a few specific lines to make sure we get the results we want { "tag: abuse@domain.com" => [%w{abuse@domain.com}, %w{tag}, []], @@ -206,7 +207,7 @@ class TestReports < Test::Unit::TestCase list = report.logs.collect { |l| l.to_report } - report.extend(Puppet::Network::Handler.report.report(:tagmail)) + report.extend(Puppet::Reports.report(:tagmail)) { [%w{abuse@domain.com}, %w{all}, []] => list, |