Skip to content

Commit 98fe9a0

Browse files
author
Takashi Matsuo
committed
use retry for enable_alert test
1 parent ef044b7 commit 98fe9a0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

monitoring/api/v3/alerts-client/snippets_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,23 @@ def test_list_alert_policies(capsys, pochan):
118118
assert pochan.alert_policy.display_name in out
119119

120120

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

133136
time.sleep(2)
134-
snippets.enable_alert_policies(pochan.project_name, False)
137+
invoke_sample(False)
135138
out, _ = capsys.readouterr()
136139
assert "Disabled {}".format(pochan.project_name) in out
137140

0 commit comments

Comments
 (0)