File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
monitoring/snippets/v3/alerts-client Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -123,11 +123,20 @@ def pochan():
123123
124124
125125def test_list_alert_policies (capsys , pochan ):
126- snippets .list_alert_policies (pochan .project_name )
127- out , _ = capsys .readouterr ()
128- # Only check up to the first 20 characters of the display name
129- # as long strings printed to the console are truncated.
130- assert pochan .alert_policy .display_name [0 :20 ] in out
126+ # Query snippets.list_alert_policies() for up to 5 seconds
127+ # to allow the newly created policy to appear in the list.
128+ retry = 5
129+ while retry :
130+ snippets .list_alert_policies (pochan .project_name )
131+ out , _ = capsys .readouterr ()
132+ # Only check up to the first 20 characters of the display name
133+ # as long strings printed to the console are truncated.
134+ if pochan .alert_policy .display_name [0 :20 ] in out :
135+ break
136+ retry = retry - 1
137+ time .sleep (1 )
138+
139+ assert retry > 0
131140
132141
133142@pytest .mark .flaky (rerun_filter = delay_on_aborted , max_runs = 5 )
You can’t perform that action at this time.
0 commit comments