Skip to content

Commit

Permalink
tests: fix flaky snap test by adding multiple retries (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
james-garner-canonical authored Jan 8, 2025
1 parent d58cced commit e20e313
Showing 1 changed file with 12 additions and 5 deletions.
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

0 comments on commit e20e313

Please sign in to comment.