2013-07-19 21:03:42 +02:00
|
|
|
require 'spec_helper_system'
|
|
|
|
|
|
|
|
describe 'mysql class' do
|
|
|
|
case node.facts['osfamily']
|
|
|
|
when 'RedHat'
|
|
|
|
package_name = 'mysql-server'
|
|
|
|
service_name = 'mysqld'
|
2013-11-13 01:39:08 +01:00
|
|
|
mycnf = '/etc/my.cnf'
|
2013-07-19 21:03:42 +02:00
|
|
|
when 'Suse'
|
|
|
|
package_name = 'mysql-community-server'
|
|
|
|
service_name = 'mysql'
|
2013-11-13 01:39:08 +01:00
|
|
|
mycnf = '/etc/my.cnf'
|
2013-07-19 21:03:42 +02:00
|
|
|
when 'Debian'
|
|
|
|
package_name = 'mysql-server'
|
|
|
|
service_name = 'mysql'
|
2013-11-13 01:39:08 +01:00
|
|
|
mycnf = '/etc/mysql/my.cnf'
|
2013-07-19 21:03:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'running puppet code' do
|
|
|
|
# Using puppet_apply as a helper
|
|
|
|
it 'should work with no errors' do
|
|
|
|
pp = <<-EOS
|
|
|
|
class { 'mysql::server': }
|
|
|
|
EOS
|
|
|
|
|
|
|
|
# Run it twice and test for idempotency
|
|
|
|
puppet_apply(pp) do |r|
|
|
|
|
r.exit_code.should_not == 1
|
|
|
|
r.refresh
|
|
|
|
r.exit_code.should be_zero
|
|
|
|
end
|
|
|
|
end
|
2013-10-04 20:47:31 +02:00
|
|
|
|
|
|
|
describe package(package_name) do
|
|
|
|
it { should be_installed }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe service(service_name) do
|
|
|
|
it { should be_running }
|
|
|
|
it { should be_enabled }
|
|
|
|
end
|
2013-07-19 21:03:42 +02:00
|
|
|
end
|
|
|
|
|
2013-11-13 01:39:08 +01:00
|
|
|
describe 'mycnf' do
|
2013-10-04 20:47:31 +02:00
|
|
|
it 'should contain sensible values' do
|
|
|
|
pp = <<-EOS
|
|
|
|
class { 'mysql::server': }
|
|
|
|
EOS
|
|
|
|
puppet_apply(pp) do |r|
|
|
|
|
r.exit_code.should_not == 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-13 01:39:08 +01:00
|
|
|
describe file(mycnf) do
|
2013-10-04 20:47:31 +02:00
|
|
|
it { should contain 'key_buffer = 16M' }
|
|
|
|
it { should contain 'max_binlog_size = 100M' }
|
|
|
|
it { should contain 'query_cache_size = 16M' }
|
|
|
|
end
|
2013-07-19 21:03:42 +02:00
|
|
|
end
|
|
|
|
|
2013-10-04 20:47:31 +02:00
|
|
|
describe 'my.cnf changes' do
|
|
|
|
it 'sets values' do
|
|
|
|
pp = <<-EOS
|
|
|
|
class { 'mysql::server':
|
|
|
|
override_options => { 'mysqld' =>
|
|
|
|
{ 'key_buffer' => '32M',
|
|
|
|
'max_binlog_size' => '200M',
|
|
|
|
'query_cache_size' => '32M',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
puppet_apply(pp) do |r|
|
|
|
|
r.exit_code.should_not == 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-13 01:39:08 +01:00
|
|
|
describe file(mycnf) do
|
2013-10-04 20:47:31 +02:00
|
|
|
it { should contain 'key_buffer = 32M' }
|
|
|
|
it { should contain 'max_binlog_size = 200M' }
|
|
|
|
it { should contain 'query_cache_size = 32M' }
|
|
|
|
end
|
2013-07-19 21:03:42 +02:00
|
|
|
end
|
2013-10-04 20:47:31 +02:00
|
|
|
|
2013-07-19 21:03:42 +02:00
|
|
|
end
|