2012-03-07 16:53:36 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
describe 'mysql::server' do
|
2012-03-16 18:36:12 +01:00
|
|
|
|
|
|
|
let :constant_parameter_defaults do
|
|
|
|
{:config_hash => {},
|
|
|
|
:package_ensure => 'present',
|
2012-10-05 01:27:06 +02:00
|
|
|
:enabled => true,
|
|
|
|
:manage_service => true
|
2012-03-16 18:36:12 +01:00
|
|
|
}
|
2012-03-07 16:53:36 +01:00
|
|
|
end
|
|
|
|
|
2012-03-16 23:56:04 +01:00
|
|
|
describe 'when ubuntu use upstart' do
|
|
|
|
let :facts do
|
|
|
|
{ :osfamily => 'Debian',
|
|
|
|
:operatingsystem => 'Ubuntu',
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_service('mysqld').with(
|
|
|
|
:name => 'mysql',
|
|
|
|
:ensure => 'running',
|
|
|
|
:enable => 'true',
|
|
|
|
:provider => 'upstart',
|
|
|
|
:require => 'Package[mysql-server]'
|
|
|
|
)}
|
|
|
|
end
|
|
|
|
|
2012-03-16 18:36:12 +01:00
|
|
|
describe 'with osfamily specific defaults' do
|
|
|
|
{
|
|
|
|
'Debian' => {
|
2012-05-10 06:55:16 +02:00
|
|
|
:service_name => 'mysql',
|
|
|
|
:package_name => 'mysql-server'
|
|
|
|
},
|
|
|
|
'FreeBSD' => {
|
|
|
|
:service_name => 'mysql-server',
|
|
|
|
:package_name => 'databases/mysql55-server'
|
2012-03-16 18:36:12 +01:00
|
|
|
},
|
|
|
|
'Redhat' => {
|
2012-05-10 06:55:16 +02:00
|
|
|
:service_name => 'mysqld',
|
|
|
|
:package_name => 'mysql-server'
|
2012-03-16 18:36:12 +01:00
|
|
|
}
|
|
|
|
}.each do |osfamily, osparams|
|
|
|
|
|
|
|
|
describe "when osfamily is #{osfamily}" do
|
|
|
|
|
|
|
|
let :facts do
|
2012-03-16 23:56:04 +01:00
|
|
|
{ :osfamily => osfamily }
|
2012-03-16 18:36:12 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
[
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
:package_name => 'dans_package',
|
|
|
|
:package_ensure => 'latest',
|
|
|
|
:service_name => 'dans_service',
|
2012-06-18 23:01:38 +02:00
|
|
|
:config_hash => {'root_password' => 'foo'},
|
2012-10-05 01:27:06 +02:00
|
|
|
:enabled => false,
|
|
|
|
:manage_service => false
|
2012-03-16 18:36:12 +01:00
|
|
|
}
|
|
|
|
].each do |passed_params|
|
|
|
|
|
|
|
|
describe "with #{passed_params == {} ? 'default' : 'specified'} parameters" do
|
|
|
|
|
|
|
|
let :parameter_defaults do
|
|
|
|
constant_parameter_defaults.merge(osparams)
|
|
|
|
end
|
|
|
|
|
|
|
|
let :params do
|
|
|
|
passed_params
|
|
|
|
end
|
|
|
|
|
|
|
|
let :param_values do
|
|
|
|
parameter_defaults.merge(params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should contain_package('mysql-server').with(
|
|
|
|
:name => param_values[:package_name],
|
|
|
|
:ensure => param_values[:package_ensure]
|
|
|
|
)}
|
|
|
|
|
2012-10-05 01:27:06 +02:00
|
|
|
it {
|
|
|
|
if param_values[:manage_service]
|
|
|
|
should contain_service('mysqld').with(
|
|
|
|
:name => param_values[:service_name],
|
|
|
|
:ensure => param_values[:enabled] ? 'running' : 'stopped',
|
|
|
|
:enable => param_values[:enabled],
|
|
|
|
:require => 'Package[mysql-server]'
|
|
|
|
).without_provider
|
|
|
|
else
|
|
|
|
should_not contain_service('mysqld')
|
|
|
|
end
|
|
|
|
}
|
2012-03-16 18:36:12 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-03-07 16:53:36 +01:00
|
|
|
end
|