Skip to content

Commit 6c22a52

Browse files
committed
RHEL9 Fixes
Prior to this commit, xtrabackup acceptance tests would fail when the OS was RHEL 9. This is because xtrabackup is not currently supported for RHEL 9. This commit moves the xtrabackup acceptance tests in to their own spec file and adds conditions to the tests that ensure they are only executed on supported OSes.
1 parent 25da797 commit 6c22a52

File tree

3 files changed

+222
-209
lines changed

3 files changed

+222
-209
lines changed

spec/acceptance/04_mysql_backup_spec.rb

Lines changed: 0 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -129,213 +129,4 @@ class { 'mysql::server::backup':
129129
end
130130
end
131131
end
132-
133-
context 'with xtrabackup enabled' do
134-
context 'should work with no errors', if: ((os[:family] == 'debian') || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do
135-
pp = <<-MANIFEST
136-
class { 'mysql::server': root_password => 'password' }
137-
mysql::db { [
138-
'backup1',
139-
'backup2'
140-
]:
141-
user => 'backup',
142-
password => 'secret',
143-
charset => '#{fetch_charset}',
144-
collate => '#{fetch_charset}_general_ci',
145-
}
146-
case $facts['os']['family'] {
147-
/Debian/: {
148-
$source_url = "http://repo.percona.com/apt/percona-release_latest.${facts['os']['distro']['codename']}_all.deb"
149-
150-
file { '/tmp/percona-release_latest.deb':
151-
ensure => present,
152-
source => $source_url,
153-
}
154-
ensure_packages('gnupg')
155-
ensure_packages('gnupg2')
156-
ensure_packages('curl')
157-
ensure_packages('percona-release',{
158-
ensure => present,
159-
provider => 'dpkg',
160-
source => '/tmp/percona-release_latest.deb',
161-
notify => Exec['apt-get update'],
162-
})
163-
exec { 'apt-get update':
164-
path => '/usr/bin:/usr/sbin:/bin:/sbin',
165-
refreshonly => true,
166-
}
167-
}
168-
/RedHat/: {
169-
# RHEL/CentOS 5 is no longer supported by Percona, but older versions
170-
# of the repository are still available.
171-
if versioncmp($::operatingsystemmajrelease, '6') >= 0 {
172-
$percona_url = 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm'
173-
$epel_url = "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm"
174-
} else {
175-
$percona_url = 'http://repo.percona.com/yum/release/5/os/noarch/percona-release-0.1-3.noarch.rpm'
176-
$epel_url = 'https://archives.fedoraproject.org/pub/archive/epel/epel-release-latest-5.noarch.rpm'
177-
}
178-
ensure_packages('percona-release',{
179-
ensure => present,
180-
provider => 'rpm',
181-
source => $percona_url,
182-
})
183-
ensure_packages('epel-release',{
184-
ensure => present,
185-
provider => 'rpm',
186-
source => $epel_url,
187-
})
188-
if ($facts['os']['name'] == 'Scientific') {
189-
# $releasever resolves to '6.10' instead of '6' which breaks Percona repos
190-
file { '/etc/yum/vars/releasever':
191-
ensure => present,
192-
content => '6',
193-
}
194-
}
195-
}
196-
default: { }
197-
}
198-
class { 'mysql::server::backup':
199-
backupuser => 'myuser',
200-
backuppassword => 'mypassword',
201-
backupdir => '/tmp/xtrabackups',
202-
provider => 'xtrabackup',
203-
execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
204-
}
205-
MANIFEST
206-
it 'when configuring mysql backup' do
207-
idempotent_apply(pp)
208-
end
209-
end
210-
211-
describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
212-
it 'runs xtrabackup.sh full backup with no errors' do
213-
run_shell('/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/xtrabackups/$(date +%F)_full --backup 2>&1 | tee /tmp/xtrabackup_full.log') do |r|
214-
expect(r.exit_code).to be_zero
215-
end
216-
end
217-
218-
it 'xtrabackup reports success for the full backup' do
219-
# NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead.
220-
run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup_full.log') do |r|
221-
expect(r.exit_code).to be_zero
222-
end
223-
end
224-
225-
it 'creates a subdirectory for the full backup' do
226-
run_shell('find /tmp/xtrabackups -mindepth 1 -maxdepth 1 -type d -name $(date +%Y)\*full | wc -l') do |r|
227-
expect(r.stdout).to match(%r{1})
228-
expect(r.exit_code).to be_zero
229-
end
230-
end
231-
232-
it 'runs xtrabackup.sh incremental backup with no errors' do
233-
run_shell('sleep 1')
234-
run_shell('/usr/local/sbin/xtrabackup.sh --incremental-basedir=/tmp/xtrabackups/$(date +%F)_full --target-dir=/tmp/xtrabackups/$(date +%F_%H-%M-%S) --backup 2>&1 | tee /tmp/xtrabackup_inc.log') do |r| # rubocop:disable Layout/LineLength
235-
expect(r.exit_code).to be_zero
236-
end
237-
end
238-
239-
it 'xtrabackup reports success for the incremental backup' do
240-
# NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead.
241-
run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup_inc.log') do |r|
242-
expect(r.exit_code).to be_zero
243-
end
244-
end
245-
246-
it 'creates a new subdirectory for each backup' do
247-
run_shell('find /tmp/xtrabackups -mindepth 1 -maxdepth 1 -type d -name $(date +%Y)\* | wc -l') do |r|
248-
expect(r.stdout).to match(%r{2})
249-
expect(r.exit_code).to be_zero
250-
end
251-
end
252-
end
253-
end
254-
255-
context 'with xtrabackup enabled and incremental backups disabled' do
256-
context 'should work with no errors', if: ((os[:family] == 'debian') || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do
257-
pp = <<-MANIFEST
258-
class { 'mysql::server': root_password => 'password' }
259-
mysql::db { [
260-
'backup1',
261-
'backup2'
262-
]:
263-
user => 'backup',
264-
password => 'secret',
265-
charset => '#{fetch_charset}',
266-
collate => '#{fetch_charset}_general_ci',
267-
}
268-
case $facts['os']['family'] {
269-
/Debian/: {
270-
$source_url = "http://repo.percona.com/apt/percona-release_1.0-22.generic_all.deb"
271-
272-
file { '/tmp/percona-release_latest.deb':
273-
ensure => present,
274-
source => $source_url,
275-
}
276-
ensure_packages('gnupg')
277-
ensure_packages('gnupg2')
278-
ensure_packages('percona-release',{
279-
ensure => present,
280-
provider => 'dpkg',
281-
source => '/tmp/percona-release_latest.deb',
282-
notify => Exec['apt-get update'],
283-
})
284-
exec { 'apt-get update':
285-
path => '/usr/bin:/usr/sbin:/bin:/sbin',
286-
refreshonly => true,
287-
}
288-
}
289-
/RedHat/: {
290-
$percona_url = 'http://repo.percona.com/yum/percona-release-latest.noarch.rpm'
291-
$epel_url = "https://download.fedoraproject.org/pub/epel/epel-release-latest-${facts['os']['release']['major']}.noarch.rpm"
292-
ensure_packages('percona-release',{
293-
ensure => present,
294-
provider => 'rpm',
295-
source => $percona_url,
296-
})
297-
ensure_packages('epel-release',{
298-
ensure => present,
299-
provider => 'rpm',
300-
source => $epel_url,
301-
})
302-
if ($facts['os']['name'] == 'Scientific') {
303-
# $releasever resolves to '6.10' instead of '6' which breaks Percona repos
304-
file { '/etc/yum/vars/releasever':
305-
ensure => present,
306-
content => '6',
307-
}
308-
}
309-
}
310-
default: { }
311-
}
312-
class { 'mysql::server::backup':
313-
backupuser => 'myuser',
314-
backuppassword => 'mypassword',
315-
backupdir => '/tmp/xtrabackups',
316-
provider => 'xtrabackup',
317-
incremental_backups => false,
318-
execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
319-
}
320-
MANIFEST
321-
it 'when configuring mysql backup' do
322-
idempotent_apply(pp)
323-
end
324-
end
325-
326-
describe 'xtrabackup.sh', if: Gem::Version.new(mysql_version) < Gem::Version.new('5.7.0') && ((os[:family] == 'debian' && os[:release].to_i >= 9) || (os[:family] == 'ubuntu') || (os[:family] == 'redhat' && os[:release].to_i > 7)) do # rubocop:disable Layout/LineLength
327-
it 'runs xtrabackup.sh with no errors' do
328-
run_shell('/usr/local/sbin/xtrabackup.sh --target-dir=/tmp/xtrabackups/$(date +%F_%H-%M-%S) --backup 2>&1 | tee /tmp/xtrabackup.log') do |r|
329-
expect(r.exit_code).to be_zero
330-
end
331-
end
332-
333-
it 'xtrabackup reports success for the backup' do
334-
# NOTE: Once support for CentOS 6 is dropped, we should check for "completed OK" instead.
335-
run_shell('grep "xtrabackup: Transaction log of lsn" /tmp/xtrabackup.log') do |r|
336-
expect(r.exit_code).to be_zero
337-
end
338-
end
339-
end
340-
end
341132
end

0 commit comments

Comments
 (0)