-
-
Notifications
You must be signed in to change notification settings - Fork 272
/
collectd_plugin_ping_spec.rb
114 lines (99 loc) · 2.79 KB
/
collectd_plugin_ping_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
require 'spec_helper'
describe 'collectd::plugin::ping', type: :class do
on_supported_os(baseline_os_hash).each do |os, facts|
context "on #{os} " do
let :facts do
facts
end
let :pre_condition do
'include collectd'
end
options = os_specific_options(facts)
context ':hosts => [\'google.com\']' do
let :params do
{ hosts: ['google.com'] }
end
it "Will create #{options[:plugin_conf_dir]}/10-ping.conf" do
is_expected.to contain_file('ping.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-ping.conf",
content: %r{Host "google.com"}
)
end
end
context 'all options set' do
let :params do
{
hosts: ['google.com'],
manage_package: true,
interval: 1.23,
timeout: 0.5,
ttl: 5,
source_address: '123.123.123.123',
device: 'eth0',
max_missed: 12,
size: 5
}
end
content = <<EOS
# Generated by Puppet
<LoadPlugin ping>
Globals false
Interval 1.23
</LoadPlugin>
<Plugin ping>
Host "google.com"
Interval "1.23"
Timeout "0.5"
TTL "5"
SourceAddress "123.123.123.123"
Device "eth0"
MaxMissed "12"
Size "5"
</Plugin>
EOS
it "Will create #{options[:plugin_conf_dir]}/10-ping.conf" do
is_expected.to contain_file('ping.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-ping.conf",
content: content
)
end
end
context ':hosts => [\'google.com\', \'puppetlabs.com\']' do
let :params do
{ hosts: ['google.com', 'puppetlabs.com'] }
end
it "Will create #{options[:plugin_conf_dir]}/10-ping.conf" do
is_expected.to contain_file('ping.load').with(
ensure: 'present',
path: "#{options[:plugin_conf_dir]}/10-ping.conf"
).with_content(
%r{Host "google.com"}
).with_content(
%r{Host "puppetlabs.com"}
)
end
end
context ':ensure => absent' do
let :params do
{ hosts: ['google.com'], ensure: 'absent' }
end
it "Will not create #{options[:plugin_conf_dir]}/10-ping.conf" do
is_expected.to contain_file('ping.load').with(
ensure: 'absent',
path: "#{options[:plugin_conf_dir]}/10-ping.conf"
)
end
end
context ':hosts is not an array' do
let :params do
{ hosts: 'google.com' }
end
it 'Will raise an error about :interfaces being a String' do
is_expected.to compile.and_raise_error(%r{String})
end
end
end
end
end