Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIP-8440 retry opsgenie test intermittent error #299

Merged
merged 3 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions metaflow/plugins/aip/tests/run_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,27 @@ def test_error_and_opsgenie_alert(pytestconfig) -> None:
close_alert_endpoint: str = (
f"https://api.opsgenie.com/v2/alerts/{alert_alias}/close?identifierType=alias"
)
close_alert_response: Response = requests.post(
close_alert_endpoint,
data=json.dumps(close_alert_data),
headers=opsgenie_auth_headers,
)
# Sometimes the response status code is 202, signaling
# the request has been accepted and is being queued for processing.
assert (
close_alert_response.status_code == 200
or close_alert_response.status_code == 202
)

def is_valid_status_code(close_alert_response):
# Sometimes the response status code is 202, signaling
# the request has been accepted and is being queued for processing.
return (
close_alert_response.status_code == 200
or close_alert_response.status_code == 202
)

# retry 3 times with a sleep of 3s until the alert is closed
for _ in range(3):
close_alert_response: Response = requests.post(
close_alert_endpoint,
data=json.dumps(close_alert_data),
headers=opsgenie_auth_headers,
)
if is_valid_status_code(close_alert_response):
break
time.sleep(3)

assert is_valid_status_code(close_alert_response)

# Test logging of raise_error_flow
check_error_handling_flow_cmd: str = (
Expand Down
Loading