Try a few times

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-11-20 13:19:28 +00:00 committed by Pedro Algarvio
parent 374cf24321
commit e19cf37a61

View file

@ -1,4 +1,5 @@
import sys
import time
import pytest
@ -8,8 +9,16 @@ def pkg_name(salt_call_cli, grains):
if sys.platform.startswith("win"):
ret = salt_call_cli.run("--local", "winrepo.update_git_repos")
assert ret.returncode == 0
ret = salt_call_cli.run("--local", "pkg.refresh_db")
assert ret.returncode == 0
attempts = 3
while attempts:
attempts -= 1
ret = salt_call_cli.run("--local", "pkg.refresh_db")
if ret.returncode:
time.sleep(5)
continue
break
else:
pytest.fail("Failed to run 'pkg.refresh_db' 3 times.")
return "putty"
elif grains["os_family"] == "RedHat":
if grains["os"] == "VMware Photon OS":