From f295c5520fd7d287d194dc7fdb57be6b8f37b1e9 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Wed, 8 Apr 2020 15:41:10 -0700 Subject: [PATCH] use retry for enable_alert test --- monitoring/api/v3/alerts-client/snippets_test.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/monitoring/api/v3/alerts-client/snippets_test.py b/monitoring/api/v3/alerts-client/snippets_test.py index 31a875b05fe3..8b02e76b9c1b 100644 --- a/monitoring/api/v3/alerts-client/snippets_test.py +++ b/monitoring/api/v3/alerts-client/snippets_test.py @@ -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