Merge pull request #401 from apenney/restart

Restart
This commit is contained in:
Hunter Haugen 2013-12-18 12:22:21 -08:00
commit 8fbd595f89
3 changed files with 38 additions and 12 deletions

View file

@ -58,12 +58,25 @@ class mysql::server (
anchor { 'mysql::server::start': } anchor { 'mysql::server::start': }
anchor { 'mysql::server::end': } anchor { 'mysql::server::end': }
Anchor['mysql::server::start'] -> if $restart {
Class['mysql::server::install'] -> Anchor['mysql::server::start'] ->
Class['mysql::server::config'] -> Class['mysql::server::install'] ->
Class['mysql::server::service'] -> # Only difference between the blocks is that we use ~> to restart if
Class['mysql::server::root_password'] -> # restart is set to true.
Class['mysql::server::providers'] -> Class['mysql::server::config'] ~>
Anchor['mysql::server::end'] Class['mysql::server::service'] ->
Class['mysql::server::root_password'] ->
Class['mysql::server::providers'] ->
Anchor['mysql::server::end']
} else {
Anchor['mysql::server::start'] ->
Class['mysql::server::install'] ->
Class['mysql::server::config'] ->
Class['mysql::server::service'] ->
Class['mysql::server::root_password'] ->
Class['mysql::server::providers'] ->
Anchor['mysql::server::end']
}
} }

View file

@ -7,7 +7,6 @@ class mysql::server::config {
owner => 'root', owner => 'root',
group => $mysql::server::root_group, group => $mysql::server::root_group,
mode => '0400', mode => '0400',
notify => Class['mysql::server::service'],
} }
file { '/etc/mysql': file { '/etc/mysql':

View file

@ -55,7 +55,7 @@ describe 'mysql class' do
end end
describe file(mycnf) do describe file(mycnf) do
it { should contain 'key_buffer = 16M' } it { should contain 'key_buffer_size = 16M' }
it { should contain 'max_binlog_size = 100M' } it { should contain 'max_binlog_size = 100M' }
it { should contain 'query_cache_size = 16M' } it { should contain 'query_cache_size = 16M' }
end end
@ -134,15 +134,29 @@ describe 'mysql class' do
end end
describe 'restart' do describe 'restart' do
it 'stops the service restarting if set' do it 'restart => true' do
pp = <<-EOS pp = <<-EOS
class { 'mysql::server': class { 'mysql::server':
restart => false, restart => true,
override_options => { 'mysqld' => { 'test' => 'value' } } override_options => { 'mysqldump' => { 'default-character-set' => 'UTF-8' } }
} }
EOS EOS
apply_manifest(pp, :catch_failures => true) do |r| apply_manifest(pp, :catch_failures => true) do |r|
expect(r.exit_code).to eq(2)
expect(r.stdout).to match(/Scheduling refresh/)
end
end
it 'restart => false' do
pp = <<-EOS
class { 'mysql::server':
restart => false,
override_options => { 'mysqldump' => { 'default-character-set' => 'UTF-16' } }
}
EOS
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.exit_code).to eq(2)
expect(r.stdout).to_not match(/Scheduling refresh/) expect(r.stdout).to_not match(/Scheduling refresh/)
end end
end end