Skip to content

(fix) - Change default for mysql::server::backup to ignore_triggers =… #711

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 1 commit into from
May 12, 2015
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 manifests/server/backup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$backupdatabases = [],
$file_per_database = false,
$include_routines = false,
$include_triggers = true,
$include_triggers = false,
$ensure = 'present',
$time = ['23', '5'],
$postscript = false,
Expand Down
15 changes: 14 additions & 1 deletion spec/acceptance/mysql_backup_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
require 'spec_helper_acceptance'
require 'puppet'
require 'puppet/util/package'

describe 'mysql::server::backup class' do

def pre_run
apply_manifest("class { 'mysql::server': root_password => 'password' }", :catch_failures => true)
@mysql_version = (on default, 'mysql --version').output.chomp.match(/\d+\.\d+\.\d+/)[0]
end

def version_is_greater_than(version)
return Puppet::Util::Package.versioncmp(@mysql_version, version) > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we reuse this with mariadb long user/db names?

end

context 'should work with no errors' do
it 'when configuring mysql backups' do
pp = <<-EOS
Expand Down Expand Up @@ -132,6 +144,7 @@ class { 'mysql::server::backup':

context 'with triggers and routines' do
it 'when configuring mysql backups with triggers and routines' do
pre_run
pp = <<-EOS
class { 'mysql::server': root_password => 'password' }
mysql::db { [
Expand All @@ -150,7 +163,7 @@ class { 'mysql::server::backup':
backupdir => '/tmp/backups',
backupcompress => true,
file_per_database => true,
include_triggers => true,
include_triggers => #{version_is_greater_than('5.1.5')},
include_routines => true,
postscript => [
'rm -rf /var/tmp/mysqlbackups',
Expand Down
16 changes: 8 additions & 8 deletions spec/classes/mysql_server_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
:require => 'Class[Mysql::Server::Root_password]') }

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

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

Expand Down Expand Up @@ -153,9 +153,9 @@
)
end

it 'should backup triggers by default' do
it 'should skip backup triggers by default' do
is_expected.to contain_file('mysqlbackup.sh').with_content(
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/
)
end

Expand Down Expand Up @@ -250,9 +250,9 @@
end
end

it 'should backup triggers by default' do
it 'should skip backup triggers by default' do
is_expected.to contain_file('mysqlbackup.sh').with_content(
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --triggers"/
/ADDITIONAL_OPTIONS="\$ADDITIONAL_OPTIONS --skip-triggers"/
)
end

Expand Down