Skip to content

Use httpbin.org instead of example.com for /http tests #1161

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 3 commits into from
Dec 13, 2022

Conversation

eramongodb
Copy link
Contributor

Resolves CDRIVER-4538. Verified by this patch.

The /http test has been split into /http/get and /http/post and uses httpbin.org instead of example.org.

As a drive-by fix, this PR also resolves CDRIVER-4537 by ensure calls to abort() in the test suite are preceeded by both fflush (stdout) and fflush (stderr) to improve the quality of test output on failures.

@eramongodb eramongodb requested a review from kevinAlbs December 13, 2022 18:35
@eramongodb eramongodb self-assigned this Dec 13, 2022
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with an assertion swap.

If httpbin.org is not reliable, another alternative may be needed. Perhaps a local HTTP server in Python?

Comment on lines 41 to 48
ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
"%s"
"RESPONSE BODY END\n",
res.status,
res.body_len > 0 ? res.body : "");
ASSERT_OR_PRINT (r, error);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
"%s"
"RESPONSE BODY END\n",
res.status,
res.body_len > 0 ? res.body : "");
ASSERT_OR_PRINT (r, error);
ASSERT_OR_PRINT (r, error);
ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
"%s"
"RESPONSE BODY END\n",
res.status,
res.body_len > 0 ? res.body : "");

Suggest checking for an error first. An error in socket connection may result in res.status being 0. The error may have more useful information.

Comment on lines 72 to 79
ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
"%s"
"RESPONSE BODY END\n",
res.status,
res.body_len > 0 ? res.body : "");
ASSERT_OR_PRINT (r, error);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
"%s"
"RESPONSE BODY END\n",
res.status,
res.body_len > 0 ? res.body : "");
ASSERT_OR_PRINT (r, error);
ASSERT_OR_PRINT (r, error);
ASSERT_WITH_MSG (res.status == 200,
"unexpected status code %d\n"
"RESPONSE BODY BEGIN\n"
"%s"
"RESPONSE BODY END\n",
res.status,
res.body_len > 0 ? res.body : "");

@eramongodb eramongodb requested a review from kevinAlbs December 13, 2022 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants