|
2 | 2 |
|
3 | 3 | describe 'mysql::backup' do
|
4 | 4 |
|
5 |
| - let(:params) { |
| 5 | + let(:default_params) { |
6 | 6 | { 'backupuser' => 'testuser',
|
7 | 7 | 'backuppassword' => 'testpass',
|
8 | 8 | 'backupdir' => '/tmp',
|
9 | 9 | }
|
10 | 10 | }
|
11 |
| - |
12 |
| - it { should contain_database_user('testuser@localhost')} |
13 |
| - |
14 |
| - it { should contain_database_grant('testuser@localhost').with( |
15 |
| - :privileges => [ 'Select_priv', 'Reload_priv', 'Lock_tables_priv', 'Show_view_priv' ] |
16 |
| - )} |
17 |
| - |
18 |
| - it { should contain_cron('mysql-backup').with( |
19 |
| - :command => '/usr/local/sbin/mysqlbackup.sh', |
20 |
| - :ensure => 'present' |
21 |
| - )} |
22 |
| - |
23 |
| - it { should contain_file('mysqlbackup.sh').with( |
24 |
| - :path => '/usr/local/sbin/mysqlbackup.sh', |
25 |
| - :ensure => 'present' |
26 |
| - )} |
27 |
| - |
28 |
| - it { should contain_file('mysqlbackupdir').with( |
29 |
| - :path => '/tmp', |
30 |
| - :ensure => 'directory' |
31 |
| - )} |
32 |
| - |
| 11 | + context "standard conditions" do |
| 12 | + let(:params) { default_params } |
| 13 | + |
| 14 | + it { should contain_database_user('testuser@localhost')} |
| 15 | + |
| 16 | + it { should contain_database_grant('testuser@localhost').with( |
| 17 | + :privileges => [ 'Select_priv', 'Reload_priv', 'Lock_tables_priv', 'Show_view_priv' ] |
| 18 | + )} |
| 19 | + |
| 20 | + it { should contain_cron('mysql-backup').with( |
| 21 | + :command => '/usr/local/sbin/mysqlbackup.sh', |
| 22 | + :ensure => 'present' |
| 23 | + )} |
| 24 | + |
| 25 | + it { should contain_file('mysqlbackup.sh').with( |
| 26 | + :path => '/usr/local/sbin/mysqlbackup.sh', |
| 27 | + :ensure => 'present' |
| 28 | + ) } |
| 29 | + |
| 30 | + it { should contain_file('mysqlbackupdir').with( |
| 31 | + :path => '/tmp', |
| 32 | + :ensure => 'directory' |
| 33 | + )} |
| 34 | + |
| 35 | + it 'should have compression by default' do |
| 36 | + verify_contents(subject, 'mysqlbackup.sh', [ |
| 37 | + ' --all-databases | bzcat -zc > ${DIR}/mysql_backup_`date +%Y%m%d-%H%M%S`.sql.bz2', |
| 38 | + ]) |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + context "with compression disabled" do |
| 43 | + let(:params) do |
| 44 | + { :backupcompress => false }.merge(default_params) |
| 45 | + end |
| 46 | + |
| 47 | + it { should contain_file('mysqlbackup.sh').with( |
| 48 | + :path => '/usr/local/sbin/mysqlbackup.sh', |
| 49 | + :ensure => 'present' |
| 50 | + ) } |
| 51 | + |
| 52 | + it 'should be able to disable compression' do |
| 53 | + verify_contents(subject, 'mysqlbackup.sh', [ |
| 54 | + ' --all-databases > ${DIR}/mysql_backup_`date +%Y%m%d-%H%M%S`.sql', |
| 55 | + ]) |
| 56 | + end |
| 57 | + end |
33 | 58 | end
|
0 commit comments