Skip to content

CDRIVER-4538 Automatically retry on 502 Bad Gateway in /http tests #1179

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

Merged
merged 1 commit into from
Jan 13, 2023
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
20 changes: 20 additions & 0 deletions src/libmongoc/tests/test-mongoc-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ test_mongoc_http_get (void *unused)
req.port = 80;
r = _mongoc_http_send (&req, 10000, false, NULL, &res, &error);
ASSERT_OR_PRINT (r, error);

if (res.status == 502) {
// This test occasionally fails due to 502 Bad Gateway.
// Automatically attempt a retry and hope the issue resolved itself.
// ¯\_(ツ)_/¯
_mongoc_http_response_cleanup (&res);
r = _mongoc_http_send (&req, 10000, false, NULL, &res, &error);
ASSERT_OR_PRINT (r, error);
}

ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
Expand Down Expand Up @@ -70,6 +80,16 @@ test_mongoc_http_post (void *unused)
req.port = 80;
r = _mongoc_http_send (&req, 10000, false, NULL, &res, &error);
ASSERT_OR_PRINT (r, error);

if (res.status == 502) {
// This test occasionally fails due to 502 Bad Gateway.
// Automatically attempt a retry and hope the issue resolved itself.
// ¯\_(ツ)_/¯
_mongoc_http_response_cleanup (&res);
r = _mongoc_http_send (&req, 10000, false, NULL, &res, &error);
ASSERT_OR_PRINT (r, error);
}

ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
Expand Down