Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix flaky snap test by adding multiple retries #141

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions tests/integration/test_snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,18 @@ def test_snap_refresh():
def test_snap_set_and_get_with_typed():
cache = snap.SnapCache()
lxd = cache["lxd"]
try:
lxd.ensure(snap.SnapState.Latest, channel="latest")
except snap.SnapError:
time.sleep(60)
lxd.ensure(snap.SnapState.Latest, channel="latest")

def try_ensure_snap(retries: int) -> None:
try:
lxd.ensure(snap.SnapState.Latest, channel="latest")
except snap.SnapError:
if retries <= 0:
raise
time.sleep(20)
try_ensure_snap(retries=retries - 1)

try_ensure_snap(retries=10)

configs = {
"true": True,
"false": False,
Expand Down