2013-08-27 22:15:29 +02:00
|
|
|
require 'spec_helper_system'
|
|
|
|
|
2013-09-13 19:13:59 +02:00
|
|
|
describe 'mysql::server::backup class' do
|
2013-08-27 22:15:29 +02:00
|
|
|
context 'should work with no errors' do
|
|
|
|
pp = <<-EOS
|
2013-09-09 17:34:39 +02:00
|
|
|
class { 'mysql::globals': override_options => { 'root_password' => 'password' } }
|
|
|
|
class { 'mysql::server': }
|
2013-08-27 22:15:29 +02:00
|
|
|
mysql::db { 'backup1':
|
|
|
|
user => 'backup',
|
|
|
|
password => 'secret',
|
|
|
|
}
|
|
|
|
|
2013-09-13 19:13:59 +02:00
|
|
|
class { 'mysql::server::backup':
|
2013-08-27 22:15:29 +02:00
|
|
|
backupuser => 'myuser',
|
|
|
|
backuppassword => 'mypassword',
|
|
|
|
backupdir => '/tmp/backups',
|
|
|
|
backupcompress => true,
|
|
|
|
}
|
|
|
|
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 mysqlbackup.sh with no errors' do
|
|
|
|
context shell("/usr/local/sbin/mysqlbackup.sh") do
|
|
|
|
its(:exit_code) { should be_zero }
|
|
|
|
end
|
|
|
|
end
|
2013-09-09 17:34:39 +02:00
|
|
|
|
2013-08-27 22:15:29 +02:00
|
|
|
context 'should dump all databases to single file' do
|
|
|
|
describe command('ls /tmp/backups/ | grep -c "mysql_backup_[0-9][0-9]*-[0-9][0-9]*.sql.bz2"') do
|
|
|
|
it { should return_stdout /1/ }
|
|
|
|
it { should return_exit_status 0 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'should create one file per database' do
|
|
|
|
pp = <<-EOS
|
2013-09-09 17:34:39 +02:00
|
|
|
class { 'mysql::globals': override_options => { 'root_password' => 'password' } }
|
|
|
|
class { 'mysql::server': }
|
2013-08-27 22:15:29 +02:00
|
|
|
mysql::db { 'backup1':
|
|
|
|
user => 'backup',
|
|
|
|
password => 'secret',
|
|
|
|
}
|
|
|
|
|
2013-09-13 19:13:59 +02:00
|
|
|
class { 'mysql::server::backup':
|
2013-08-27 22:15:29 +02:00
|
|
|
backupuser => 'myuser',
|
|
|
|
backuppassword => 'mypassword',
|
|
|
|
backupdir => '/tmp/backups',
|
|
|
|
backupcompress => true,
|
|
|
|
file_per_database => true,
|
|
|
|
}
|
|
|
|
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 shell("/usr/local/sbin/mysqlbackup.sh") do
|
|
|
|
its(:exit_code) { should be_zero }
|
|
|
|
end
|
2013-09-09 17:34:39 +02:00
|
|
|
|
2013-08-27 22:15:29 +02:00
|
|
|
describe command('ls /tmp/backups/ | grep -c "mysql_backup_backup1_[0-9][0-9]*-[0-9][0-9]*.sql.bz2"') do
|
|
|
|
it { should return_stdout /1/ }
|
|
|
|
it { should return_exit_status 0 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|