Skip to content

Commit 6639efc

Browse files
committed
Merge pull request #711 from cyberious/master
(fix) - Change default for mysql::server::backup to ignore_triggers =…
2 parents 61c5372 + d3901f2 commit 6639efc

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

manifests/server/backup.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$backupdatabases = [],
1414
$file_per_database = false,
1515
$include_routines = false,
16-
$include_triggers = true,
16+
$include_triggers = false,
1717
$ensure = 'present',
1818
$time = ['23', '5'],
1919
$postscript = false,

spec/acceptance/mysql_backup_spec.rb

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
require 'spec_helper_acceptance'
2+
require 'puppet'
3+
require 'puppet/util/package'
24

35
describe 'mysql::server::backup class' do
6+
7+
def pre_run
8+
apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true)
9+
@mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0]
10+
end
11+
12+
def version_is_greater_than(version)
13+
return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0
14+
end
15+
416
context 'should work with no errors' do
517
it 'when configuring mysql backups' do
618
pp = <<-EOS
@@ -132,6 +144,7 @@ class { 'mysql::server::backup':
132144

133145
context 'with triggers and routines' do
134146
it 'when configuring mysql backups with triggers and routines' do
147+
pre_run
135148
pp = <<-EOS
136149
class { 'mysql::server': root_password => 'password' }
137150
mysql::db { [
@@ -150,7 +163,7 @@ class { 'mysql::server::backup':
150163
backupdir => '/tmp/backups',
151164
backupcompress => true,
152165
file_per_database => true,
153-
include_triggers => true,
166+
include_triggers => #{version_is_greater_than('5.1.5')},
154167
include_routines => true,
155168
postscript => [
156169
'rm -rf /var/tmp/mysqlbackups',

spec/classes/mysql_server_backup_spec.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
:require => 'Class[Mysql::Server::Root_password]') }
2525

2626
it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with(
27-
:privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER']
27+
:privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS']
2828
).that_requires('Mysql_user[testuser@localhost]') }
2929

30-
context 'with triggers excluded' do
30+
context 'with triggers included' do
3131
let(:params) do
32-
{ :include_triggers => false }.merge(default_params)
32+
{ :include_triggers => true }.merge(default_params)
3333
end
3434
it { is_expected.to contain_mysql_grant('testuser@localhost/*.*').with(
35-
:privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS']
35+
:privileges => ['SELECT', 'RELOAD', 'LOCK TABLES', 'SHOW VIEW', 'PROCESS', 'TRIGGER']
3636
).that_requires('Mysql_user[testuser@localhost]') }
3737
end
3838

@@ -153,9 +153,9 @@
153153
)
154154
end
155155

156-
it 'should backup triggers by default' do
156+
it 'should skip backup triggers by default' do
157157
is_expected.to contain_file('mysqlbackup.sh').with_content(
158-
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/
158+
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/
159159
)
160160
end
161161

@@ -250,9 +250,9 @@
250250
end
251251
end
252252

253-
it 'should backup triggers by default' do
253+
it 'should skip backup triggers by default' do
254254
is_expected.to contain_file('mysqlbackup.sh').with_content(
255-
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/
255+
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/
256256
)
257257
end
258258

0 commit comments

Comments
 (0)