diff options
Diffstat (limited to 'molecule/default/tests/test_manual_backup.py')
| -rw-r--r-- | molecule/default/tests/test_manual_backup.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/molecule/default/tests/test_manual_backup.py b/molecule/default/tests/test_manual_backup.py index 31a8693..b4068bc 100644 --- a/molecule/default/tests/test_manual_backup.py +++ b/molecule/default/tests/test_manual_backup.py @@ -1,7 +1,13 @@ import pytest from datetime import datetime -testinfra_hosts = ['borg-client'] +testinfra_hosts = ['borg-client', 'borg-client-2'] + + +def get_server_info(hostname): + if hostname == 'borg-client-2': + return ('backupserver', 'borg-server-2', '/var/backups') + return ('borg', 'borg-server', '/opt/borg') compression_types = [ @@ -20,8 +26,11 @@ host""" @pytest.mark.parametrize('compression', compression_types) def test_backup_push(host, compression): + hostname = host.backend.get_hostname() + server_user, server_host, server_path = get_server_info(hostname) + c = host.run( - f'borg create -C "{compression}" borg@borg-server:/opt/borg/borg-client::testinfra-{{now:%S.%f}} /etc' + f'borg create -C "{compression}" {server_user}@{server_host}:{server_path}/{hostname}::testinfra-{{now:%S.%f}} /etc' ) assert c.rc == 0 assert c.stdout == '' @@ -30,12 +39,14 @@ def test_backup_push(host, compression): @pytest.mark.parametrize('compression', compression_types) def test_backup_restore(host, compression): + hostname = host.backend.get_hostname() + server_user, server_host, server_path = get_server_info(hostname) timestamp = datetime.now().strftime('%Y%m%d-%H%M%S-%f') archive_name = f"testinfra-backup-restore-{compression}-{timestamp}" # Create backup c = host.run( - f'borg create -C "{compression}" borg@borg-server:/opt/borg/borg-client::{archive_name} /etc' + f'borg create -C "{compression}" {server_user}@{server_host}:{server_path}/{hostname}::{archive_name} /etc' ) assert c.rc == 0 assert c.stdout == '' @@ -43,7 +54,7 @@ def test_backup_restore(host, compression): # Restore Backup c = host.run( - f"cd /mnt && borg extract borg@borg-server:/opt/borg/borg-client::{archive_name}" + f"cd /mnt && borg extract {server_user}@{server_host}:{server_path}/{hostname}::{archive_name}" ) assert c.rc == 0 assert c.stdout == '' @@ -67,7 +78,7 @@ def test_backup_restore(host, compression): assert c.stderr == '' # Delete backup - c = host.run(f"borg delete borg@borg-server:/opt/borg/borg-client::{archive_name}") + c = host.run(f"borg delete {server_user}@{server_host}:{server_path}/{hostname}::{archive_name}") assert c.rc == 0 assert c.stdout == '' assert c.stderr == '' |