forked from voxpupuli/puppet-collectd
/
class_plugin_load_spec.rb
127 lines (117 loc) · 3.97 KB
/
class_plugin_load_spec.rb
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
require 'spec_helper_acceptance'
describe 'collectd::plugin::load class' do
context 'basic parameters' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
pp = <<-EOS
class{'collectd':
utils => true,
}
class{'collectd::plugin::load': }
# Add one write plugin to keep logs quiet
class{'collectd::plugin::csv':}
# Create a socket to query
class{'collectd::plugin::unixsock':
socketfile => '/var/run/collectd-sock',
socketgroup => 'root',
}
EOS
# Run 3 times since the collectd_version
# fact is impossible until collectd is
# installed.
apply_manifest(pp, catch_failures: false)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# Wait to get some data
shell('sleep 10')
end
describe service('collectd') do
it { is_expected.to be_running }
end
describe command('collectdctl -s /var/run/collectd-sock listval') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{load/load$} }
its(:stdout) { is_expected.not_to match %r{load/load-relative$} }
end
end
context 'report relative false' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
pp = <<-EOS
class{'collectd':
utils => true,
}
class{'collectd::plugin::load':
report_relative => false,
}
# Add one write plugin to keep logs quiet
class{'collectd::plugin::csv':}
# Create a socket to query
class{'collectd::plugin::unixsock':
socketfile => '/var/run/collectd-sock',
socketgroup => 'root',
}
EOS
# Run 3 times since the collectd_version
# fact is impossible until collectd is
# installed.
apply_manifest(pp, catch_failures: false)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# Wait to get some data
shell('sleep 10')
end
describe service('collectd') do
it { is_expected.to be_running }
end
describe command('collectdctl -s /var/run/collectd-sock listval') do
its(:exit_status) { is_expected.to eq 0 }
its(:stdout) { is_expected.to match %r{load/load$} }
its(:stdout) { is_expected.not_to match %r{load/load-relative$} }
end
end
context 'report relative true' do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
pp = <<-EOS
class{'collectd':
utils => true,
}
class{'collectd::plugin::load':
report_relative => true,
}
# Add one write plugin to keep logs quiet
class{'collectd::plugin::csv':}
# Create a socket to query
class{'collectd::plugin::unixsock':
socketfile => '/var/run/collectd-sock',
socketgroup => 'root',
}
EOS
# Run 3 times since the collectd_version
# fact is impossible until collectd is
# installed.
apply_manifest(pp, catch_failures: false)
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# Wait to get some data
shell('sleep 10')
end
describe service('collectd') do
it { is_expected.to be_running }
end
describe command('collectdctl -s /var/run/collectd-sock listval') do
its(:exit_status) { is_expected.to eq 0 }
# https://github.com/voxpupuli/puppet-collectd/issues/901
# following will fail once 5.9.1 is released in EPEL8
if fact('osfamily') == 'RedHat' && fact('os.release.major') == '8' ||
fact('osfamily') == 'Debian' && fact('os.release.major') == '8'
its(:stdout) { is_expected.not_to match %r{load/load-relative$} }
its(:stdout) { is_expected.to match %r{load/load$} }
else
its(:stdout) { is_expected.to match %r{load/load-relative$} }
its(:stdout) { is_expected.not_to match %r{load/load$} }
end
end
end
end