Skip to content

Commit dc43dd9

Browse files
committed
MODULES-10023 fix xtrabackup tests on CentOS 6
1 parent 0765d15 commit dc43dd9

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

manifests/params.pp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
$client_dev_package_provider = undef
3838
$daemon_dev_package_ensure = 'present'
3939
$daemon_dev_package_provider = undef
40-
$xtrabackup_package_name = 'percona-xtrabackup'
40+
$xtrabackup_package_name_default = 'percona-xtrabackup'
4141

4242

4343
case $::osfamily {
@@ -56,6 +56,7 @@
5656
$provider = 'mariadb'
5757
} else {
5858
$provider = 'mysql'
59+
$xtrabackup_package_name_override = 'percona-xtrabackup-20'
5960
}
6061
if versioncmp($::operatingsystemmajrelease, '8') >= 0 {
6162
$java_package_name = 'mariadb-java-client'
@@ -513,6 +514,12 @@
513514
},
514515
}
515516

517+
if defined('$xtrabackup_package_name_override') {
518+
$xtrabackup_package_name = pick($xtrabackup_package_name_override, $xtrabackup_package_name_default)
519+
} else {
520+
$xtrabackup_package_name = $xtrabackup_package_name_default
521+
}
522+
516523
## Additional graceful failures
517524
if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '4' and $::operatingsystem != 'Amazon' {
518525
fail(translate('Unsupported platform: puppetlabs-%{module_name} only supports RedHat 5.0 and beyond.', {'module_name' => $module_name}))

spec/acceptance/mysql_backup_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ class { 'mysql::server::backup':
203203
end
204204

205205
it 'xtrabackup reports success for the full backup' do
206-
run_shell('grep "completed OK" /tmp/xtrabackup_full.log') do |r|
206+
# NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead.
207+
run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup_full.log') do |r|
207208
expect(r.exit_code).to be_zero
208209
end
209210
end
@@ -223,7 +224,8 @@ class { 'mysql::server::backup':
223224
end
224225

225226
it 'xtrabackup reports success for the incremental backup' do
226-
run_shell('grep "completed OK" /tmp/xtrabackup_inc.log') do |r|
227+
# NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead.
228+
run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup_inc.log') do |r|
227229
expect(r.exit_code).to be_zero
228230
end
229231
end
@@ -307,7 +309,8 @@ class { 'mysql::server::backup':
307309
end
308310

309311
it 'xtrabackup reports success for the backup' do
310-
run_shell('grep "completed OK" /tmp/xtrabackup.log') do |r|
312+
# NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead.
313+
run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup.log') do |r|
311314
expect(r.exit_code).to be_zero
312315
end
313316
end

spec/classes/mysql_backup_xtrabackup_spec.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ class { 'mysql::server': }
2727
)
2828
end
2929

30+
package = if facts[:osfamily] == 'RedHat'
31+
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
32+
'percona-xtrabackup'
33+
else
34+
'percona-xtrabackup-20'
35+
end
36+
else
37+
'percona-xtrabackup'
38+
end
39+
3040
it 'contains the weekly cronjob' do
3141
is_expected.to contain_cron('xtrabackup-weekly')
3242
.with(
@@ -37,7 +47,7 @@ class { 'mysql::server': }
3747
minute: '5',
3848
weekday: '0',
3949
)
40-
.that_requires('Package[percona-xtrabackup]')
50+
.that_requires("Package[#{package}]")
4151
end
4252

4353
it 'contains the daily cronjob for weekdays 1-6' do
@@ -56,7 +66,7 @@ class { 'mysql::server': }
5666
minute: '5',
5767
weekday: '1-6',
5868
)
59-
.that_requires('Package[percona-xtrabackup]')
69+
.that_requires("Package[#{package}]")
6070
end
6171
end
6272

@@ -90,6 +100,16 @@ class { 'mysql::server': }
90100
{ additional_cron_args: '--backup --skip-ssl' }.merge(default_params)
91101
end
92102

103+
package = if facts[:osfamily] == 'RedHat'
104+
if Puppet::Util::Package.versioncmp(facts[:operatingsystemmajrelease], '7') >= 0
105+
'percona-xtrabackup'
106+
else
107+
'percona-xtrabackup-20'
108+
end
109+
else
110+
'percona-xtrabackup'
111+
end
112+
93113
dateformat = case facts[:osfamily]
94114
when 'FreeBSD', 'OpenBSD'
95115
'$(date -v-sun +\%F)_full'
@@ -107,7 +127,7 @@ class { 'mysql::server': }
107127
minute: '5',
108128
weekday: '0',
109129
)
110-
.that_requires('Package[percona-xtrabackup]')
130+
.that_requires("Package[#{package}]")
111131
end
112132

113133
it 'contains the daily cronjob for weekdays 1-6' do
@@ -120,7 +140,7 @@ class { 'mysql::server': }
120140
minute: '5',
121141
weekday: '1-6',
122142
)
123-
.that_requires('Package[percona-xtrabackup]')
143+
.that_requires("Package[#{package}]")
124144
end
125145
end
126146

0 commit comments

Comments
 (0)