diff options
Diffstat (limited to 'molecule/default/tests/test_systemd.py')
| -rw-r--r-- | molecule/default/tests/test_systemd.py | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/molecule/default/tests/test_systemd.py b/molecule/default/tests/test_systemd.py index 7b7b2ab..b713c27 100644 --- a/molecule/default/tests/test_systemd.py +++ b/molecule/default/tests/test_systemd.py @@ -2,7 +2,7 @@ import pytest -testinfra_hosts = ['borg-client', 'borg-client-2', 'borg-client-multi', 'borg-client-nonroot'] +testinfra_hosts = ['borg-client', 'borg-client-2', 'borg-client-multi', 'borg-client-nonroot', 'borg-client-multi-keys'] CLIENT_USER_MAP = { @@ -10,6 +10,7 @@ CLIENT_USER_MAP = { 'borg-client-2': 'root', 'borg-client-multi': 'root', 'borg-client-nonroot': 'backupuser', + 'borg-client-multi-keys': 'root', } @@ -31,6 +32,15 @@ class TestSystemdServiceFile: assert service2.exists assert service2.user == 'root' assert service2.group == 'root' + elif hostname == 'borg-client-multi-keys': + service1 = host.file('/etc/systemd/system/borg_backup@configs-keys.service') + service2 = host.file('/etc/systemd/system/borg_backup@home-data-keys.service') + assert service1.exists + assert service1.user == 'root' + assert service1.group == 'root' + assert service2.exists + assert service2.user == 'root' + assert service2.group == 'root' elif hostname == 'borg-client-nonroot': service = host.file('/etc/systemd/system/borg_backup@borg-server.service') assert service.exists @@ -57,6 +67,14 @@ class TestSystemdServiceFile: assert service.contains('[Service]') assert service.contains('[Install]') assert service.contains('Type=oneshot') + elif hostname == 'borg-client-multi-keys': + service1 = host.file('/etc/systemd/system/borg_backup@configs-keys.service') + service2 = host.file('/etc/systemd/system/borg_backup@home-data-keys.service') + for service in [service1, service2]: + assert service.contains('[Unit]') + assert service.contains('[Service]') + assert service.contains('[Install]') + assert service.contains('Type=oneshot') elif hostname == 'borg-client-nonroot': service = host.file('/etc/systemd/system/borg_backup@borg-server.service') assert service.contains('[Unit]') @@ -84,6 +102,12 @@ class TestSystemdServiceFile: for service in [service1, service2]: assert service.contains(f'User={client_user}') assert service.contains(f'Group={client_user}') + elif hostname == 'borg-client-multi-keys': + service1 = host.file('/etc/systemd/system/borg_backup@configs-keys.service') + service2 = host.file('/etc/systemd/system/borg_backup@home-data-keys.service') + for service in [service1, service2]: + assert service.contains(f'User={client_user}') + assert service.contains(f'Group={client_user}') elif hostname in ('borg-client', 'borg-client-2', 'borg-client-nonroot'): service = host.file('/etc/systemd/system/borg_backup@borg-server.service') assert service.contains(f'User={client_user}') @@ -93,7 +117,7 @@ class TestSystemdServiceFile: def test_success_exit_status(self, host): hostname = host.backend.get_hostname() - if hostname in ('borg-client-multi', 'borg-client-nonroot'): + if hostname in ('borg-client-multi', 'borg-client-nonroot', 'borg-client-multi-keys'): return service = host.file('/etc/systemd/system/borg_backup@borg-server.service') @@ -123,6 +147,11 @@ class TestSystemdTimerFile: timer2 = host.file('/etc/systemd/system/borg_backup@home-data.timer') assert timer1.exists assert timer2.exists + elif hostname == 'borg-client-multi-keys': + timer1 = host.file('/etc/systemd/system/borg_backup@configs-keys.timer') + timer2 = host.file('/etc/systemd/system/borg_backup@home-data-keys.timer') + assert timer1.exists + assert timer2.exists elif hostname in ('borg-client', 'borg-client-2', 'borg-client-nonroot'): timer = host.file('/etc/systemd/system/borg_backup@borg-server.timer') assert timer.exists @@ -144,6 +173,15 @@ class TestSystemdTimerFile: assert timer.contains('[Install]') assert timer.contains('OnCalendar=') assert timer.contains('AccuracySec=') + elif hostname == 'borg-client-multi-keys': + timer1 = host.file('/etc/systemd/system/borg_backup@configs-keys.timer') + timer2 = host.file('/etc/systemd/system/borg_backup@home-data-keys.timer') + for timer in [timer1, timer2]: + assert timer.contains('[Unit]') + assert timer.contains('[Timer]') + assert timer.contains('[Install]') + assert timer.contains('OnCalendar=') + assert timer.contains('AccuracySec=') elif hostname in ('borg-client', 'borg-client-2', 'borg-client-nonroot'): timer = host.file('/etc/systemd/system/borg_backup@borg-server.timer') assert timer.contains('[Unit]') @@ -162,6 +200,11 @@ class TestSystemdTimerFile: timer2 = host.file('/etc/systemd/system/borg_backup@home-data.timer') assert 'OnCalendar=*-*-* 02:00:00' in timer1.content_string assert 'OnCalendar=*-*-* 04:00:00' in timer2.content_string + elif hostname == 'borg-client-multi-keys': + timer1 = host.file('/etc/systemd/system/borg_backup@configs-keys.timer') + timer2 = host.file('/etc/systemd/system/borg_backup@home-data-keys.timer') + assert 'OnCalendar=*-*-* 02:00:00' in timer1.content_string + assert 'OnCalendar=*-*-* 04:00:00' in timer2.content_string elif hostname == 'borg-client-2': timer = host.file('/etc/systemd/system/borg_backup@borg-server.timer') assert 'OnCalendar=*-*-* 03:00:00' in timer.content_string @@ -183,6 +226,13 @@ class TestSystemdState: assert c1.stdout.strip() == 'enabled' assert c2.rc == 0 assert c2.stdout.strip() == 'enabled' + elif hostname == 'borg-client-multi-keys': + c1 = host.run('systemctl is-enabled borg_backup@configs-keys.timer') + c2 = host.run('systemctl is-enabled borg_backup@home-data-keys.timer') + assert c1.rc == 0 + assert c1.stdout.strip() == 'enabled' + assert c2.rc == 0 + assert c2.stdout.strip() == 'enabled' elif hostname in ('borg-client', 'borg-client-2', 'borg-client-nonroot'): timer_name = 'borg_backup@borg-server.timer' c = host.run(f"systemctl is-enabled {timer_name}") @@ -199,6 +249,11 @@ class TestSystemdState: c2 = host.run('systemctl is-active borg_backup@home-data.timer') assert c1.rc == 0 assert c2.rc == 0 + elif hostname == 'borg-client-multi-keys': + c1 = host.run('systemctl is-active borg_backup@configs-keys.timer') + c2 = host.run('systemctl is-active borg_backup@home-data-keys.timer') + assert c1.rc == 0 + assert c2.rc == 0 elif hostname in ('borg-client', 'borg-client-2', 'borg-client-nonroot'): timer_name = 'borg_backup@borg-server.timer' c = host.run(f"systemctl is-active {timer_name}") |