Skip to content
Snippets Groups Projects
Commit 7f9ab1dc authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

fix(test): handle more backup use cases

parent 59e03ecf
No related branches found
No related tags found
No related merge requests found
...@@ -73,8 +73,10 @@ def test_last_backup_is_recent(server: str) -> bool: ...@@ -73,8 +73,10 @@ def test_last_backup_is_recent(server: str) -> bool:
# set backup potential directories path # set backup potential directories path
paths = [ paths = [
"/backup/{}/home/latest".format(client), "/backup/{}/".format(client),
"/backup/data/latest", "/backup/data/",
"/backup/nas*/",
"/backup/ms*/",
] ]
# test each possible path # test each possible path
...@@ -82,14 +84,16 @@ def test_last_backup_is_recent(server: str) -> bool: ...@@ -82,14 +84,16 @@ def test_last_backup_is_recent(server: str) -> bool:
# build and run commands # build and run commands
find = "find -L {} {} {} {} {}".format( find = "find -L {} {} {} {} {}".format(
path, path,
"-maxdepth 0", "-maxdepth 1",
"-xtype l", "-xtype l",
"-name latest", "-name latest",
"-exec realpath {} +" # must always be last arg "-exec realpath {} +" # must always be last arg
) )
cmd = "ssh -o StrictHostKeyChecking=no {} '{}'".format(server, find) cmd = "ssh -o StrictHostKeyChecking=no {} '{}'".format(server, find)
status, out = subprocess.getstatusoutput(cmd) status, out = subprocess.getstatusoutput(cmd)
if status == 0: # TODO: check all backups found instead of only the last of the list
# maybe do a `split()` and `if len(lst) > 1`…
if status == 0 and out != "":
# get directory name and convert to datetime # get directory name and convert to datetime
last = out.strip().split("/")[-1] last = out.strip().split("/")[-1]
date = datetime.strptime(last, "%Y-%m-%d-%H%M%S") date = datetime.strptime(last, "%Y-%m-%d-%H%M%S")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment