Skip to content

Add tests for all missing parameters. #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ license 'Apache 2.0'
summary 'Mysql module'
description 'Mysql module'
project_page 'http://github.com/puppetlabs/puppetlabs-mysql'
dependency 'puppetlabs/stdlib', '>= 2.2.1'
dependency 'puppetlabs/stdlib', '>= 3.2.0'
14 changes: 9 additions & 5 deletions spec/acceptance/mysql_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
context 'should work with no errors' do
it 'when configuring mysql backups' do
pp = <<-EOS
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
class { 'mysql::server': root_password => 'password' }
mysql::db { 'backup1':
user => 'backup',
password => 'secret',
Expand All @@ -31,13 +31,14 @@ class { 'mysql::server::backup':
describe 'mysqlbackup.sh' do
it 'should run mysqlbackup.sh with no errors' do
shell("/usr/local/sbin/mysqlbackup.sh") do |r|
expect(r.stderr).to eq("")
expect(r.stderr).to eq("-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.\n")
end
end

it 'should dump all databases to single file' do
shell('ls /tmp/backups/ | grep -c "mysql_backup_backup1_[0-9][0-9]*-[0-9][0-9]*.sql.bz2"') do |r|
expect(r.stdout).to match(/\d*[13579]/)
shell('ls -l /tmp/backups/mysql_backup_*-*.sql.bz2 | wc -l') do |r|
expect(r.stdout).to match(/1/)
expect(r.exit_code).to be_zero
end
end

Expand All @@ -48,7 +49,10 @@ class { 'mysql::server::backup':
end

it 'creates at least one backup tarball' do
expect(shell('ls /tmp/backups/ | grep -c "mysql_backup_backup1_[0-9][0-9]*-[0-9][0-9]*.sql.bz2"').stdout).to match(/\d*[02468]/)
shell('ls -l /tmp/backups/mysql_backup_*-*.sql.bz2 | wc -l') do |r|
expect(r.stdout).to match(/2/)
expect(r.exit_code).to be_zero
end
end
end
end
Expand Down
103 changes: 64 additions & 39 deletions spec/acceptance/mysql_bindings_spec.rb
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
require 'spec_helper_acceptance'

describe 'mysql::bindings class' do
osfamily = fact('osfamily')
operatingsystem = fact('operatingsystem')
osfamily = fact('osfamily')
operatingsystem = fact('operatingsystem')

case osfamily
when 'RedHat'
java_package = 'mysql-connector-java'
perl_package = 'perl-DBD-MySQL'
python_package = 'MySQL-python'
ruby_package = 'ruby-mysql'
when 'Suse'
java_package = 'mysql-connector-java'
perl_package = 'perl-DBD-MySQL'
python_package = 'python-mysql'
case operatingsystem
when /OpenSuSE/
ruby_package = 'rubygem-mysql'
when /(SLES|SLED)/
ruby_package = 'ruby-mysql'
end
when 'Debian'
java_package = 'libmysql-java'
perl_package = 'libdbd-mysql-perl'
python_package = 'python-mysqldb'
ruby_package = 'libmysql-ruby'
when 'FreeBSD'
java_package = 'databases/mysql-connector-java'
perl_package = 'p5-DBD-mysql'
python_package = 'databases/py-MySQLdb'
ruby_package = 'ruby-mysql'
else
case operatingsystem
when 'Amazon'
java_package = 'mysql-connector-java'
case osfamily
when 'RedHat'
java_package = 'mysql-connector-java'
perl_package = 'perl-DBD-MySQL'
php_package = 'php-mysql'
python_package = 'MySQL-python'
ruby_package = 'ruby-mysql'
when 'Suse'
java_package = 'mysql-connector-java'
perl_package = 'perl-DBD-MySQL'
php_package = 'apache2-mod_php5'
python_package = 'python-mysql'
case operatingsystem
when /OpenSuSE/
ruby_package = 'rubygem-mysql'
when /(SLES|SLED)/
ruby_package = 'ruby-mysql'
end
when 'Debian'
java_package = 'libmysql-java'
perl_package = 'libdbd-mysql-perl'
php_package = 'php5-mysql'
python_package = 'python-mysqldb'
ruby_package = 'libmysql-ruby'
when 'FreeBSD'
java_package = 'databases/mysql-connector-java'
perl_package = 'p5-DBD-mysql'
php_package = 'php5-mysql'
python_package = 'databases/py-MySQLdb'
ruby_package = 'ruby-mysql'
else
case operatingsystem
when 'Amazon'
java_package = 'mysql-connector-java'
perl_package = 'perl-DBD-MySQL'
php_package = 'php5-mysql'
python_package = 'MySQL-python'
ruby_package = 'ruby-mysql'
end
end
end

describe 'mysql::bindings class' do

describe 'running puppet code' do
it 'should work with no errors' do
Expand All @@ -52,14 +58,29 @@ class { 'mysql::bindings': }
end
end

describe 'enabling bindings' do
describe 'all parameters' do
it 'should work with no errors' do
pp = <<-EOS
class { 'mysql::bindings':
java_enable => true,
perl_enable => true,
python_enable => true,
ruby_enable => true,
java_enable => true,
perl_enable => true,
python_enable => true,
ruby_enable => true,
java_package_ensure => present,
perl_package_ensure => present,
php_package_ensure => present,
python_package_ensure => present,
ruby_package_ensure => present,
java_package_name => #{java_package},
perl_package_name => #{perl_package},
php_package_name => #{php_package},
python_package_name => #{python_package},
ruby_package_name => #{ruby_package},
java_package_provider => undef,
perl_package_provider => undef,
php_package_provider => undef,
python_package_provider => undef,
ruby_package_provider => undef,
}
EOS

Expand All @@ -76,6 +97,10 @@ class { 'mysql::bindings':
it { should be_installed }
end

describe package(php_package) do
it { should be_installed }
end

describe package(python_package) do
it { should be_installed }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/mysql_db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Using puppet_apply as a helper
it 'should work with no errors' do
pp = <<-EOS
class { 'mysql::server': override_options => { 'root_password' => 'password' } }
class { 'mysql::server': root_password => 'password' }
mysql::db { 'spec1':
user => 'root1',
password => 'password',
Expand Down
45 changes: 45 additions & 0 deletions spec/acceptance/mysql_server_config_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'spec_helper_acceptance'

describe 'config location' do
it 'creates the file elsewhere' do
pp = <<-EOS
class { 'mysql::server':
config_file => '/etc/testmy.cnf',
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file('/etc/testmy.cnf') do
it { should be_file }
end
end

describe 'manage_config_file' do
it 'wont reset the location of my.cnf' do
pp = <<-EOS
class { 'mysql::server':
config_file => '/etc/my.cnf',
manage_config_file => false,
}
EOS
# Make sure this doesn't exist so we can test if puppet
# readded it
shell('rm /etc/my.cnf')
apply_manifest(pp, :catch_failures => true)
end

describe file('/etc/my.cnf') do
it { should_not be_file }
end
end

describe 'resets' do
it 'cleans up' do
pp = <<-EOS
class { 'mysql::server': }
EOS
apply_manifest(pp, :catch_failures => true)
shell('rm /etc/testmy.cnf')
end
end
Loading