Skip to content

Commit

Permalink
chore: attempt to fix flaky snippet test test_list_alert_policies (#167)
Browse files Browse the repository at this point in the history
Fixes #149 🦕
  • Loading branch information
parthea authored and dandhlee committed Nov 9, 2022
1 parent 79c5e54 commit fe0dfe7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions monitoring/snippets/v3/alerts-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,16 @@ def pochan():


def test_list_alert_policies(capsys, pochan):
# Query snippets.list_alert_policies() for up to 5 seconds
# Query snippets.list_alert_policies() for up to 50 seconds
# to allow the newly created policy to appear in the list.
retry = 5
while retry:
snippets.list_alert_policies(pochan.project_name)
out, _ = capsys.readouterr()
# Only check up to the first 20 characters of the display name
# as long strings printed to the console are truncated.
if pochan.alert_policy.display_name[0:20] in out:
if pochan.alert_policy.display_name in out:
break
retry = retry - 1
time.sleep(1)
time.sleep(10)

assert retry > 0

Expand Down

0 comments on commit fe0dfe7

Please sign in to comment.