File tree 3 files changed +51
-9
lines changed
3 files changed +51
-9
lines changed Original file line number Diff line number Diff line change 6
6
$mysql_monitor_hostname
7
7
) {
8
8
9
- Class[' mysql::server' ] -> Class[' mysql::server::monitor' ]
10
-
11
- mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}" :
9
+ mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}" :
12
10
ensure => present ,
13
11
password_hash => mysql_password($mysql_monitor_password ),
12
+ require => Class[' mysql::config' ],
14
13
}
15
14
16
- mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}" :
15
+ mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}/*.* " :
17
16
ensure => present ,
18
17
user => " ${mysql_monitor_username} @${mysql_monitor_hostname} " ,
19
18
table => ' *.*' ,
20
- privileges => [ ' PROCESS_PRIV ' , ' SUPER_PRIV ' ],
19
+ privileges => [ ' PROCESS ' , ' SUPER ' ],
21
20
require => Mysql_user[" ${mysql_monitor_username} @${mysql_monitor_hostname} " ],
22
21
}
23
22
Original file line number Diff line number Diff line change 6
6
let :pre_condition do
7
7
"include 'mysql::server'"
8
8
end
9
- let :params do
9
+
10
+ let :default_params do
10
11
{
11
- :mysql_monitor_username => 'monitoruser' ,
12
- :mysql_monitor_password => 'monitorpass' ,
13
- :mysql_monitor_hostname => 'monitorhost'
12
+ :mysql_monitor_username => 'monitoruser' ,
13
+ :mysql_monitor_password => 'monitorpass' ,
14
+ :mysql_monitor_hostname => 'monitorhost' ,
14
15
}
15
16
end
16
17
18
+ let :params do
19
+ default_params
20
+ end
21
+
17
22
it { should contain_mysql_user ( 'monitoruser@monitorhost' ) }
23
+
24
+ it { should contain_mysql_grant ( 'monitoruser@monitorhost/*.*' ) . with (
25
+ :ensure => 'present' ,
26
+ :user => 'monitoruser@monitorhost' ,
27
+ :table => '*.*' ,
28
+ :privileges => [ "PROCESS" , "SUPER" ] ,
29
+ :require => 'Mysql_user[monitoruser@monitorhost]'
30
+ ) }
18
31
end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper_system'
2
+
3
+ describe 'mysql::server::monitor class' do
4
+ context 'should work with no errors' do
5
+ pp = <<-EOS
6
+ class { 'mysql::server': config_hash => { 'root_password' => 'foo' } }
7
+
8
+ class { 'mysql::server::monitor':
9
+ mysql_monitor_username => 'monitoruser',
10
+ mysql_monitor_password => 'monitorpass',
11
+ mysql_monitor_hostname => 'localhost',
12
+ }
13
+ EOS
14
+
15
+ context puppet_apply ( pp ) do
16
+ its ( :stderr ) { should be_empty }
17
+ its ( :exit_code ) { should_not == 1 }
18
+ its ( :refresh ) { should be_nil }
19
+ its ( :stderr ) { should be_empty }
20
+ its ( :exit_code ) { should be_zero }
21
+ end
22
+
23
+ context 'should run mysqladmin ping with no errors' do
24
+ describe command ( "mysqladmin -u monitoruser -pmonitorpass -h localhost ping" ) do
25
+ it { should return_stdout /mysqld is alive/ }
26
+ it { should return_exit_status 0 }
27
+ end
28
+ end
29
+ end
30
+ end
You can’t perform that action at this time.
0 commit comments