Skip to content

Commit

Permalink
use retry for enable_alert test
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Matsuo committed Apr 8, 2020
1 parent f578433 commit f295c55
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions monitoring/api/v3/alerts-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,23 @@ def test_list_alert_policies(capsys, pochan):
assert pochan.alert_policy.display_name in out


@pytest.mark.flaky(rerun_filter=delay_on_aborted, max_runs=5)
def test_enable_alert_policies(capsys, pochan):
@retry(wait_exponential_multiplier=1000, wait_exponential_max=10000,
stop_max_attempt_number=5, retry_on_exception=retry_if_aborted)
def invoke_sample(val):
snippets.enable_alert_policies(pochan.project_name, val)
# These sleep calls are for mitigating the following error:
# "409 Too many concurrent edits to the project configuration.
# Please try again."
# Having multiple projects will void these `sleep()` calls.
# See also #3310
time.sleep(2)
snippets.enable_alert_policies(pochan.project_name, True)
invoke_sample(True)
out, _ = capsys.readouterr()
assert "Enabled {0}".format(pochan.project_name) in out

time.sleep(2)
snippets.enable_alert_policies(pochan.project_name, False)
invoke_sample(False)
out, _ = capsys.readouterr()
assert "Disabled {}".format(pochan.project_name) in out

Expand Down

0 comments on commit f295c55

Please sign in to comment.