Skip to content

Commit d2da2f8

Browse files
authored
Fix tcp_check for multi instances (#851)
* fix tcp_check for multi instances * add test
1 parent 56a50aa commit d2da2f8

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

manifests/integrations/tcp_check.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@
8181
# }]
8282
# }
8383
class datadog_agent::integrations::tcp_check (
84-
String $check_name,
85-
String $host,
86-
String $port,
84+
Optional[String] $check_name = undef,
85+
Optional[String] $host = undef,
86+
Optional[String] $port = undef,
8787
Integer $timeout = 10,
8888
Optional[Integer] $threshold = undef,
8989
Optional[Integer] $window = undef,

spec/classes/datadog_agent_integrations_tcp_check_spec.rb

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,45 @@
112112

113113
skip('doubly undefined behavior')
114114
end
115+
116+
context 'with multiple instances' do
117+
let(:params) do
118+
{
119+
instances: [
120+
{
121+
check_name: 'foo.bar.baz',
122+
host: 'foo.bar.baz',
123+
port: '80',
124+
timeout: 123,
125+
threshold: 456,
126+
window: 789,
127+
collect_response_time: true,
128+
},
129+
{
130+
check_name: 'baz.bar.foo',
131+
host: 'baz.bar.foo',
132+
port: '8080',
133+
timeout: 456,
134+
tags: ['foo', 'bar', 'baz']
135+
},
136+
]
137+
}
138+
end
139+
140+
it { is_expected.to contain_file(conf_file).with_content(%r{name: foo.bar.baz}) }
141+
it { is_expected.to contain_file(conf_file).with_content(%r{host: foo.bar.baz}) }
142+
it { is_expected.to contain_file(conf_file).with_content(%r{port: 80}) }
143+
it { is_expected.to contain_file(conf_file).with_content(%r{timeout: 123}) }
144+
it { is_expected.to contain_file(conf_file).with_content(%r{threshold: 456}) }
145+
it { is_expected.to contain_file(conf_file).with_content(%r{window: 789}) }
146+
it { is_expected.to contain_file(conf_file).with_content(%r{collect_response_time: true}) }
147+
148+
it { is_expected.to contain_file(conf_file).with_content(%r{name: baz.bar.foo}) }
149+
it { is_expected.to contain_file(conf_file).with_content(%r{host: baz.bar.foo}) }
150+
it { is_expected.to contain_file(conf_file).with_content(%r{port: 8080}) }
151+
it { is_expected.to contain_file(conf_file).with_content(%r{timeout: 456}) }
152+
it { is_expected.to contain_file(conf_file).with_content(%r{tags:\s+- foo\s+- bar\s+- baz\s*?[^-]}m) }
153+
end
115154
end
116155
end
117156
end

0 commit comments

Comments
 (0)