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

linkcheck tests: test webservers: enable HTTP/1.1 protocol #11392

Merged

Conversation

jayaddison
Copy link
Contributor

@jayaddison jayaddison commented May 3, 2023

Feature or Bugfix

  • Refactoring

Purpose

Detail

Relates

@jayaddison jayaddison force-pushed the issue-11324-prep/linkcheck-tests-http-1.1 branch from dfca731 to a4667b5 Compare May 8, 2023 13:17
@jayaddison
Copy link
Contributor Author

I'm having difficulty replicating the unit test failures here (mostly timeouts) on Python 3.11.2.

To try to reduce the differences between my local env and the GitHub workflow, I've used python -m pytest -vv --durations 25, and have graphviz installed.

@jayaddison jayaddison force-pushed the issue-11324-prep/linkcheck-tests-http-1.1 branch from a4667b5 to 824202e Compare May 9, 2023 17:48
@jayaddison
Copy link
Contributor Author

After installing a 2.x version of urllib3 (not yet supported by requests, but installed during the tests), I'm able to replicate the timeout failures that occur during these tests.

Given the unsupported-mix between requests 2.x and urllib3 2.x, perhaps it would make sense to pin urllib3<2.0.0.

@jayaddison

This comment was marked as outdated.

@@ -19,7 +19,7 @@
class HttpServerThread(threading.Thread):
def __init__(self, handler, *args, **kwargs):
super().__init__(*args, **kwargs)
self.server = http.server.HTTPServer(("localhost", 7777), handler)
self.server = http.server.ThreadingHTTPServer(("localhost", 7777), handler)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note for reviewers: without threaded webservers, HTTP1.1's ability to leave connections open causes difficulty for the Sphinx unit tests in combination with urllib3 commit urllib3/urllib3@a80c248 - a connection-pool thread safety fix, included from v2.0.0 of that library onwards.

@AA-Turner
Copy link
Member

Looks like timeout errors on CI:

test_auth_header_uses_first_match

>       assert f"Authorization: Basic {encoded_auth}\n" in stdout
E       AssertionError: assert 'Authorization: Basic dXNlcjE6cGFzc3dvcmQ=\n' in ''

(           index: line    1) broken    http://localhost:7777/ - HTTPConnectionPool(host='localhost', port=7777): Read timed out. (read timeout=0.05)

@jayaddison
Copy link
Contributor Author

Can you link to an example build log? That test is definitely troublesome, I'm not certain I've figured out exactly why it fails though (so any more context could be useful).

@jayaddison

This comment was marked as outdated.

@jayaddison

This comment was marked as outdated.

@jayaddison

This comment was marked as outdated.

@jayaddison

This comment was marked as outdated.

@jayaddison
Copy link
Contributor Author

After thinking about the previous few comments (one, two, three) (apologies for the stream-of-consciousness) related to test_auth_header_uses_first_match, I've written up #11426 as a possible changeset.

The test failure in test_too_many_requests_user_timeout remains a puzzle to me; I hadn't seen that before. Perhaps it was exposed when 0817ade was added? Or is it unrelated?

Increasing the timeouts again (as in d8f15c7) could work around it short-term - but if possible I'd like to spend time figuring out whether there's a deeper problem and solution, because if there is, then I think the time spent investigating should be recovered during the application's usage on aggregate.

@jayaddison

This comment was marked as outdated.

@jayaddison
Copy link
Contributor Author

Nope, I'm stuck re: test_too_many_requests_user_timeout.

I'm going to remove the daemon_threads modification, moving this branch back to 94644fd, and will run the tests a few more times from there to see if the failure (or similar ones) continue to occur.

@jayaddison

This comment was marked as outdated.

@jayaddison

This comment was marked as outdated.

@jayaddison
Copy link
Contributor Author

Looks like timeout errors on CI:

test_auth_header_uses_first_match

>       assert f"Authorization: Basic {encoded_auth}\n" in stdout
E       AssertionError: assert 'Authorization: Basic dXNlcjE6cGFzc3dvcmQ=\n' in ''

(           index: line    1) broken    http://localhost:7777/ - HTTPConnectionPool(host='localhost', port=7777): Read timed out. (read timeout=0.05)

Taking a break from this until next week. So far from jayaddison#3 I'm hopeful that #11426 resolves the test flakiness observed here, but also note that there was at least one unrelated timeout that occurred.

@jayaddison
Copy link
Contributor Author

Taking a break from this until next week. So far from jayaddison#3 I'm hopeful that #11426 resolves the test flakiness observed here, but also note that there was at least one unrelated timeout that occurred.

An update: I do think that the refactor from #11426 eliminates the test_auth_header_uses_first_match test flakiness.

@jayaddison
Copy link
Contributor Author

@AA-Turner @francoisfreitag I'd like to apologise for my extremely verbose communication while developing a bunch of the changes offered for Sphinx. I think that was quite verbose and distracting.

When you have time, could you let me know whether the pull requests I currently have open are worth progressing, and whether further changes by me would be considered? If not, that's OK - I'd prefer not to consume your and my own time if further changes from me are unlikely to be accepted.

Thanks you in advance - and I'll try to improve my communication style and approach; I'd be glad for any feedback. You've both been supportive collaboratively and helpful technically in terms of finding problems in the pull requests so far.

Copy link
Contributor

@francoisfreitag francoisfreitag left a comment

Choose a reason for hiding this comment

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

HTTP/1.1 is probably used more often than 1.0, so might as well use that in tests. 👍

@jayaddison
Copy link
Contributor Author

Thanks again @francoisfreitag 👍

My perspective is that HTTP 1.1 is a more widely-used protocol than HTTP 1.0 nowadays, although I fully admit that that could be biased - and I didn't find statistics comparing those two protocol versions on the HTTP Archive website when I looked a few moments ago.

In some ways HTTP 1.0 seems to me to be more robust against unusual failure modes than HTTP 1.1 -- but I think that the motivating factors for it - namely more efficient use of network resources, particlarly for websites that receive high volumes of traffic - were reasonable.

@AA-Turner
Copy link
Member

@jayaddison please could you resolve conflicts from #11426?

A

@jayaddison
Copy link
Contributor Author

@jayaddison please could you resolve conflicts from #11426?

Done; it looks like there may be one or two more Content-Length response headers that I missed during the conflict resolution, though; checking..

@jayaddison
Copy link
Contributor Author

@jayaddison please could you resolve conflicts from #11426?

Done; it looks like there may be one or two more Content-Length response headers that I missed during the conflict resolution, though; checking..

Ok, the missed content-length header has also been resolved. There was only one codesite that required updating. The other that I had been considering was this send_error call -- it turns out that for versions of Python 3.4 onwards, calling send_error will cause a content-length header to be transmitted to the client.

@AA-Turner AA-Turner merged commit 566e4e7 into sphinx-doc:master Jul 22, 2023
27 checks passed
@AA-Turner
Copy link
Member

Thanks @jayaddison!

A

@jayaddison
Copy link
Contributor Author

Thank you!

@jayaddison jayaddison deleted the issue-11324-prep/linkcheck-tests-http-1.1 branch July 22, 2023 20:28
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants