Port of a6101dc (mysql::server::monitor fix) to 2.x.

This commit is contained in:
Ashley Penney 2013-10-07 09:55:13 -04:00
parent 8eaa915064
commit 5d17f10f93
3 changed files with 51 additions and 7 deletions

View file

@ -7,16 +7,17 @@ class mysql::server::monitor (
Anchor['mysql::server::end'] -> Class['mysql::server::monitor']
mysql_user{ "${mysql_monitor_username}@${mysql_monitor_hostname}":
mysql_user { "${mysql_monitor_username}@${mysql_monitor_hostname}":
ensure => present,
password_hash => mysql_password($mysql_monitor_password),
require => Class['mysql::server::service'],
}
mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}":
mysql_grant { "${mysql_monitor_username}@${mysql_monitor_hostname}/*.*":
ensure => present,
user => "${mysql_monitor_username}@${mysql_monitor_hostname}",
table => '*.*',
privileges => [ 'PROCESS_PRIV', 'SUPER_PRIV' ],
privileges => [ 'PROCESS', 'SUPER' ],
require => Mysql_user["${mysql_monitor_username}@${mysql_monitor_hostname}"],
}

View file

@ -6,13 +6,26 @@ describe 'mysql::server::monitor' do
let :pre_condition do
"include 'mysql::server'"
end
let :params do
let :default_params do
{
:mysql_monitor_username => 'monitoruser',
:mysql_monitor_password => 'monitorpass',
:mysql_monitor_hostname => 'monitorhost'
:mysql_monitor_hostname => 'monitorhost',
}
end
let :params do
default_params
end
it { should contain_mysql_user('monitoruser@monitorhost')}
it { should contain_mysql_grant('monitoruser@monitorhost/*.*').with(
:ensure => 'present',
:user => 'monitoruser@monitorhost',
:table => '*.*',
:privileges => ["PROCESS", "SUPER"],
:require => 'Mysql_user[monitoruser@monitorhost]'
)}
end

View file

@ -0,0 +1,30 @@
require 'spec_helper_system'
describe 'mysql::server::monitor class' do
context 'should work with no errors' do
pp = <<-EOS
class { 'mysql::server': root_password => 'foo' }
class { 'mysql::server::monitor':
mysql_monitor_username => 'monitoruser',
mysql_monitor_password => 'monitorpass',
mysql_monitor_hostname => 'localhost',
}
EOS
context puppet_apply(pp) do
its(:stderr) { should be_empty }
its(:exit_code) { should_not == 1 }
its(:refresh) { should be_nil }
its(:stderr) { should be_empty }
its(:exit_code) { should be_zero }
end
context 'should run mysqladmin ping with no errors' do
describe command("mysqladmin -u monitoruser -pmonitorpass -h localhost ping") do
it { should return_stdout /mysqld is alive/ }
it { should return_exit_status 0 }
end
end
end
end