diff --git a/tests/test_backup.py b/tests/test_backup.py index aea304cd0a83d0e2b33cc4c6ab56572dacc68a69..f67e50aa0e2c6c532aac4e5575c41b7c5ca4d028 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -50,6 +50,22 @@ 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) + status, out = subprocess.getstatusoutput(cmd) + if status == 0: + dev, total, used, free, used_perc, mount = out.strip().split() + used_perc = int(used_perc.replace('%','')) + if used_perc > 80: + print('There is less than 20% of available space for backups') + return False + else: + return True + else: + print('Failed to check backup space') + return False + + os.chdir(os.path.dirname(__file__)) if os.path.isfile('../utils.py'): es_utils = imp.load_source('es_utils', '../utils.py') @@ -63,7 +79,10 @@ if os.path.isfile('../utils.py'): if not test_last_backup_is_recent(BURP_SERVER): sys.exit(1) else: - sys.exit(0) + if not test_backup_space(BURP_SERVER): + sys.exit(1) + else: + sys.exit(0) else: print('No BURP_SERVER defined in config, untestable') sys.exit(2)