blob: 2aa78172cd8cde4177c0ce0c92118d386b98b20f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
if __FILE__ == $0
$:.unshift '..'
$:.unshift '../../lib'
$puppetbase = "../.."
end
require 'puppet'
require 'puppet/transaction/report'
require 'puppettest'
require 'test/unit'
class TestReports < Test::Unit::TestCase
include TestPuppet
# Make sure we can use reports as log destinations.
def test_reports_as_log_destinations
report = nil
assert_nothing_raised {
report = Puppet::Transaction::Report.new
}
assert_nothing_raised {
Puppet::Log.newdestination(report)
}
# Now make a file for testing logging
file = Puppet::Type.newfile(:path => tempfile(), :ensure => "file")
log = nil
assert_nothing_raised {
log = file.log "This is a message, yo"
}
assert(report.logs.include?(log), "Report did not get log message")
log = Puppet.info "This is a non-sourced message"
assert(! report.logs.include?(log), "Report got log message")
assert_nothing_raised {
Puppet::Log.close(report)
}
log = file.log "This is another message, yo"
assert(! report.logs.include?(log), "Report got log message after close")
end
def test_newmetric
report = nil
assert_nothing_raised {
report = Puppet::Transaction::Report.new
}
assert_nothing_raised {
report.newmetric(:mymetric,
:total => 12,
:done => 6
)
}
end
if Puppet::Metric.haverrd?
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
}
method = Puppet::Server::Report.report("rrdgraph")
server = nil
assert_nothing_raised {
server = Puppet::Server::Report.new()
}
assert_nothing_raised {
server.report_rrdgraph(trans.report)
}
end
else
$stderr.puts "Install RRD for metric reporting tests"
end
end
# $Id$
|