From d336f606c875d0a05868ab939f4369ffe86e8c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu> Date: Thu, 2 Mar 2017 15:55:50 +0100 Subject: [PATCH] compare last backup date with today, refs #20687 --- tests/test_backup.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_backup.py b/tests/test_backup.py index e9f7cee5..28e16dc9 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -9,6 +9,7 @@ import os import sys import subprocess import imp +from datetime import datetime os.chdir(os.path.dirname(__file__)) @@ -21,8 +22,13 @@ def test_last_backup_is_recent(server, client): cmd = 'ssh %s ls -l %s | grep current' % (server, path) status, out = subprocess.getstatusoutput(cmd) if status == 0: - date = out.strip().split(' ')[-1] - print(date) + date = out.strip().split(' ')[-2] + pdate = datetime.strptime(date, '%Y-%m-%d') + if datetime.now() - pdate > 2: + print('Backup is older than 2 days') + return False + else: + return True else: return False -- GitLab