diff --git a/tests/test_backup.py b/tests/test_backup.py index cfea1332c8c91d08513ed9a5659c568bad3c53be..9648d2b8810503686a158e135dbd99bf225037a3 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -55,8 +55,10 @@ def test_last_backup_is_recent(server): return False -def test_backup_space(server): - cmd = 'ssh -o StrictHostKeyChecking=no %s df -h /backup | tail -n 1' % (server) +def test_backup_space(server=None, path="/backup"): + cmd = 'df -h %s | tail -n 1' % path + if server: + cmd = 'ssh -o StrictHostKeyChecking=no %s ' % server + cmd status, out = subprocess.getstatusoutput(cmd) if status == 0: dev, total, used, free, used_perc, mount = out.strip().split() @@ -71,7 +73,6 @@ def test_backup_space(server): print('Failed to check backup space') return False - def check_local_backup(path): all_ok = True backup_folder = os.path.dirname(path) @@ -106,6 +107,7 @@ def check_local_backups(paths): status, out = subprocess.getstatusoutput(cmd) for bf in out.split('\n'): all_ok = min(check_local_backup(bf), all_ok) + all_ok = min(test_backup_space(path=f), all_ok) return all_ok @@ -123,7 +125,7 @@ if os.path.isfile('../utils.py'): if not test_last_backup_is_recent(BACKUP_SERVER): sys.exit(1) else: - if not test_backup_space(BACKUP_SERVER): + if not test_backup_space(server=BACKUP_SERVER): sys.exit(1) else: sys.exit(0)