File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4747# 'username' => 'mongo_username',
4848# },
4949# {
50- # 'host' => 'localhost',
51- # 'port' => '27018',
52- # 'tags' => [],
50+ # 'host' => 'localhost',
51+ # 'port' => '27018',
52+ # 'tags' => [],
53+ # 'additional_metrics' => [],
54+ # 'collections' => [],
5355# },
5456# ]
5557# }
Original file line number Diff line number Diff line change 5959 it { should contain_file ( conf_file ) . with_content ( %r{server:.*127.0.0.1.*server:.*127.0.0.2}m ) }
6060 end
6161
62+ context 'with custom collections one mongos' do
63+ let ( :params ) { {
64+ servers : [
65+ {
66+ 'host' => '127.0.0.1' ,
67+ 'port' => '12345' ,
68+ 'tags' => %w{ foo bar baz } ,
69+ 'collections' => %w{ collection_1 collection_2 } ,
70+ } ,
71+ {
72+ 'host' => '127.0.0.2' ,
73+ 'port' => '45678' ,
74+ 'tags' => %w{ baz bat } ,
75+ 'collections' => %w{ collection_1 collection_2 } ,
76+ }
77+ ]
78+ } }
79+
80+ it { should contain_file ( conf_file ) . with_content ( %r{server: mongodb://127.0.0.1:12345/\s +tags:\s +- foo\s +- bar\s +- baz\s +collections:\s +- collection_1\s +- collection_2} ) }
81+ it { should contain_file ( conf_file ) . with_content ( %r{server: mongodb://127.0.0.2:45678/\s +tags:\s +- baz\s +- bat\s +collections:\s +- collection_1\s +- collection_2} ) }
82+
83+ end
84+
85+ context 'with custom collections multiple mongo' do
86+ let ( :params ) { {
87+ servers : [
88+ {
89+ 'host' => '127.0.0.1' ,
90+ 'port' => '12345' ,
91+ 'tags' => %w{ foo bar baz } ,
92+ 'collections' => %w{ collection_1 collection_2 } ,
93+ }
94+ ]
95+ } }
96+
97+ it { should contain_file ( conf_file ) . with_content ( %r{server: mongodb://127.0.0.1:12345/\s +tags:\s +- foo\s +- bar\s +- baz\s +collections:\s +- collection_1\s +- collection_2} ) }
98+ end
99+
100+ context 'with additional metrics' do
101+ let ( :params ) { {
102+ servers : [
103+ {
104+ 'host' => '127.0.0.1' ,
105+ 'port' => '12345' ,
106+ 'tags' => %w{ foo bar baz } ,
107+ 'additional_metrics' => %w{ top } ,
108+ }
109+ ]
110+ } }
111+
112+ it { should contain_file ( conf_file ) . with_content ( %r{server: mongodb://127.0.0.1:12345/\s +tags:\s +- foo\s +- bar\s +- baz\s +additional_metrics:\s +- top} ) }
113+ end
114+
62115 context 'without tags' do
63116 let ( :params ) { {
64117 servers : [
Original file line number Diff line number Diff line change @@ -34,4 +34,10 @@ instances:
3434 - <%= additional_metric %>
3535 <%- end -%>
3636 <%- end -%>
37+ <%- if !server['collections'].nil? && server['collections'].any? -%>
38+ collections:
39+ <%- server['collections'].each do |collection| -%>
40+ - <%= collection %>
41+ <%- end -%>
42+ <%- end -%>
3743<% end -%>
You can’t perform that action at this time.
0 commit comments