Skip to content

Commit 7616b63

Browse files
authored
[spec] just some improved test coverage (DataDog#483)
* [tomcat][spec] adding simple jmx_url test coverage * [tocat][spec] adding basic jmx_url test * [reports][spec] cleaning up hostname_extract_regex testing
1 parent b1dffa6 commit 7616b63

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

spec/classes/datadog_agent_integrations_tomcat_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@
6666
it { should contain_file(conf_file).with_content(%r{trust_store_password: hunter2}) }
6767
it { should contain_file(conf_file).with_content(%r{tags:\s+foo: bar\s+baz: bat}) }
6868
end
69+
70+
context 'with jmx_url parameter set' do
71+
let(:params) {{
72+
hostname: 'tomcat1',
73+
jmx_url: 'service:jmx:rmi:///jndi/rmi://tomcat.foo:9999/custompath',
74+
username: 'userfoo',
75+
password: 'passbar',
76+
}}
77+
it { should contain_file(conf_file).with_content(%r{host: tomcat1}) }
78+
it { should contain_file(conf_file).with_content(%r{jmx_url: "service:jmx:rmi:///jndi/rmi://tomcat.foo:9999/custompath"}) }
79+
it { should contain_file(conf_file).with_content(%r{user: userfoo}) }
80+
it { should contain_file(conf_file).with_content(%r{password: passbar}) }
81+
end
6982
end
7083
end
7184
end

spec/classes/datadog_agent_reports_spec.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
let(:params) do
66
{
77
api_key: 'notanapikey',
8-
hostname_extraction_regex: nil,
98
puppetmaster_user: 'puppet',
109
dogapi_version: 'installed',
1110
}
1211
end
12+
let(:conf_file) { '/etc/datadog-agent/datadog-reports.yaml' }
1313
ALL_OS.each do |operatingsystem|
1414
describe "datadog_agent class common actions on #{operatingsystem}" do
1515
let(:facts) do
@@ -46,23 +46,26 @@
4646
end
4747

4848
it do
49-
should contain_file('/etc/datadog-agent/datadog-reports.yaml')\
49+
should contain_file(conf_file)\
5050
.with_owner('puppet')\
5151
.with_group('root')
5252
end
5353

54+
it { should contain_file(conf_file).without_content(/hostname_extraction_regex:/) }
55+
5456
end
5557
end
5658
end
5759
context 'specific dogapi version' do
5860
let(:params) do
5961
{
6062
api_key: 'notanapikey',
61-
hostname_extraction_regex: nil,
6263
puppetmaster_user: 'puppet',
6364
dogapi_version: '1.2.2'
6465
}
6566
end
67+
let(:conf_file) { '/etc/datadog-agent/datadog-reports.yaml' }
68+
6669
describe "datadog_agent class dogapi version override" do
6770
let(:facts) do
6871
{
@@ -89,7 +92,7 @@
8992
end
9093

9194
it do
92-
should contain_file('/etc/datadog-agent/datadog-reports.yaml')\
95+
should contain_file(conf_file)\
9396
.with_owner('puppet')\
9497
.with_group('root')
9598
end
@@ -100,12 +103,13 @@
100103
let(:params) do
101104
{
102105
api_key: 'notanapikey',
103-
hostname_extraction_regex: nil,
104106
puppetmaster_user: 'puppet',
105107
dogapi_version: 'installed',
106108
datadog_site: 'datadoghq.eu',
107109
}
108110
end
111+
let(:conf_file) { '/etc/datadog-agent/datadog-reports.yaml' }
112+
109113
describe "datadog_agent class dogapi version override" do
110114
let(:facts) do
111115
{
@@ -126,11 +130,12 @@
126130
end
127131

128132
it do
129-
should contain_file('/etc/datadog-agent/datadog-reports.yaml')\
133+
should contain_file(conf_file)\
130134
.with_owner('puppet')\
131135
.with_group('root')\
132136
.with_content(/:api_url: api.datadoghq.eu/)
133137
end
138+
it { should contain_file(conf_file).without_content(/hostname_extraction_regex:/) }
134139
end
135140
end
136141
end

0 commit comments

Comments
 (0)