File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 22define collectd::plugin::mysql::database (
33 Enum['present', 'absent'] $ensure = ' present' ,
44 String $database = $name,
5- Stdlib::Host $host = ' localhost ' ,
6- Stdlib::Port $port = 3306 ,
5+ Optional[ Stdlib::Host] $host = undef ,
6+ Optional[ Stdlib::Port] $port = undef ,
77 Boolean $masterstats = false ,
88 Boolean $slavestats = false ,
99 Optional[String[1]] $username = undef ,
Original file line number Diff line number Diff line change 7575 end
7676 end
7777
78- context 'default options ' do
78+ context 'specify host and port ' do
7979 let :title do
8080 'dbname'
8181 end
8484 facts . merge ( collectd_version : '5.6' )
8585 end
8686
87+ let :params do
88+ {
89+ 'host' => 'localhost' ,
90+ 'port' => 3306 ,
91+ }
92+ end
93+
8794 it 'creates an mysql database' do
8895 content_database_file = <<EOS
8996# Generated by Puppet
96103 SlaveStats false
97104 </Database>
98105</Plugin>
106+ EOS
107+ is_expected . to compile . with_all_deps
108+ is_expected . to contain_class ( 'collectd' )
109+ is_expected . to contain_class ( 'collectd::plugin::mysql' )
110+ is_expected . to contain_file ( 'dbname.conf' ) . with (
111+ content : content_database_file ,
112+ path : "#{ options [ :plugin_conf_dir ] } /mysql-dbname.conf"
113+ )
114+ end
115+ end
116+
117+ context 'default options' do
118+ let :title do
119+ 'dbname'
120+ end
121+
122+ let :facts do
123+ facts . merge ( collectd_version : '5.6' )
124+ end
125+
126+ it 'creates an mysql database' do
127+ content_database_file = <<EOS
128+ # Generated by Puppet
129+
130+ <Plugin mysql>
131+ <Database "dbname">
132+ MasterStats false
133+ SlaveStats false
134+ </Database>
135+ </Plugin>
99136EOS
100137 is_expected . to compile . with_all_deps
101138 is_expected . to contain_class ( 'collectd' )
Original file line number Diff line number Diff line change 22
33< Plugin mysql >
44 < Database "<%= @database %> ">
5+ <%- if @host -%>
56 Host "<%= @host %> "
7+ <%- end -%>
68<%- if @username -%>
79 User "<%= @username %> "
810<%- end -%>
911<%- if @password -%>
1012 Password "<%= @password %> "
1113<%- end -%>
14+ <%- if @port -%>
1215<% if scope . function_versioncmp ( [ scope . lookupvar ( 'collectd::collectd_version_real' ) , '5.0' ] ) >= 0 -%>
1316 Port "<%= @port %> "
1417<% else -%>
1518 Port <%= @port %>
19+ <%- end -%>
1620<%- end -%>
1721 MasterStats <%= @masterstats %>
1822 SlaveStats <%= @slavestats %>
You can’t perform that action at this time.
0 commit comments