|
|
|
@ -16,9 +16,9 @@ import os.path
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
testinfra_hosts = ['borg-backup01.region.provider.opendev.org',
|
|
|
|
|
'borg-backup-test01.opendev.org',
|
|
|
|
|
'borg-backup-test02.opendev.org',
|
|
|
|
|
'borg-backup-test03.opendev.org']
|
|
|
|
|
'borg-backup-bionic.opendev.org',
|
|
|
|
|
'borg-backup-focal.opendev.org',
|
|
|
|
|
'borg-backup-jammy.opendev.org']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_borg_installed(host):
|
|
|
|
@ -33,12 +33,12 @@ def test_borg_installed(host):
|
|
|
|
|
|
|
|
|
|
def test_borg_server_users(host):
|
|
|
|
|
hostname = host.backend.get_hostname()
|
|
|
|
|
if hostname.startswith('borg-backup-test'):
|
|
|
|
|
if hostname != 'borg-backup01.region.provider.opendev.org':
|
|
|
|
|
pytest.skip()
|
|
|
|
|
|
|
|
|
|
for username in ('borg-borg-backup-test01',
|
|
|
|
|
'borg-borg-backup-test02',
|
|
|
|
|
'borg-borg-backup-test03'):
|
|
|
|
|
for username in ('borg-borg-backup-bionic',
|
|
|
|
|
'borg-borg-backup-focal',
|
|
|
|
|
'borg-borg-backup-jammy'):
|
|
|
|
|
homedir = os.path.join('/opt/backups/', username)
|
|
|
|
|
borg_repo = os.path.join(homedir, 'backup')
|
|
|
|
|
authorized_keys = os.path.join(homedir, '.ssh', 'authorized_keys')
|
|
|
|
@ -85,8 +85,8 @@ def test_borg_backup(host):
|
|
|
|
|
|
|
|
|
|
cmd = host.run('ls /opt/backups')
|
|
|
|
|
# this directory should now have a directory
|
|
|
|
|
# borg-backup-test0X-YYYY-MM-DDT...
|
|
|
|
|
assert 'borg-backup-test' in cmd.stdout
|
|
|
|
|
# borg-backup-<distro>-YYYY-MM-DDT...
|
|
|
|
|
assert hostname.split('.')[0] in cmd.stdout
|
|
|
|
|
|
|
|
|
|
# unmount it for sanity
|
|
|
|
|
cmd = host.run('umount /opt/backups')
|
|
|
|
@ -94,7 +94,7 @@ def test_borg_backup(host):
|
|
|
|
|
|
|
|
|
|
def test_borg_server_prune(host):
|
|
|
|
|
hostname = host.backend.get_hostname()
|
|
|
|
|
if hostname.startswith('borg-backup-test'):
|
|
|
|
|
if hostname != 'borg-backup01.region.provider.opendev.org':
|
|
|
|
|
pytest.skip()
|
|
|
|
|
|
|
|
|
|
cmd = host.run('echo "prune" | /usr/local/bin/prune-borg-backups &> /var/log/prune-borg-backups.log')
|
|
|
|
@ -102,7 +102,7 @@ def test_borg_server_prune(host):
|
|
|
|
|
|
|
|
|
|
def test_borg_server_verify(host):
|
|
|
|
|
hostname = host.backend.get_hostname()
|
|
|
|
|
if hostname.startswith('borg-backup-test'):
|
|
|
|
|
if hostname != 'borg-backup01.region.provider.opendev.org':
|
|
|
|
|
pytest.skip()
|
|
|
|
|
|
|
|
|
|
cmd = host.run('/usr/local/bin/verify-borg-backups &> /var/log/verify-borg-backups.log')
|
|
|
|
|