You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tests/test_builders/test_build_linkcheck.py::test_defaults flaky for docutils HEAD CI #12159
changed the title [-]tests/test_builders/test_build_linkcheck.py::test_defaults is flaky with docutils HEAD[/-][+]tests/test_builders/test_build_linkcheck.py::test_defaults fails for docutils HEAD CI[/+]on Mar 21, 2024
changed the title [-]tests/test_builders/test_build_linkcheck.py::test_defaults fails for docutils HEAD CI[/-][+]tests/test_builders/test_build_linkcheck.py::test_defaults flaky for docutils HEAD CI[/+]on Mar 21, 2024
or should we temporarily disable the test for Docutils HEAD?
Maybe. Has anyone taken a look at the latest changes in docutils to see whether there is something relevant?
Under some circumstances, docutils does make HTTP network requests while processing documents; but I can't initially think of any reason why that would affect test_defaults in particular.
The other possibility is that this is somehow contention-related; we and/or GitHub may be more active than usual, or the runners may be lower-performance or constrained for some reasoning, producing timeouts. But for that to only seem to affect the docutils HEAD jobs would seem unusual.
I'm going to reluctantly suggest (with accompanying pull request) that we increase the timeouts for the linkcheck tests.
Although #12126 doesn't fix the timeouts, it does unlock running the linkcheck tests in parallel, and that should reduce the end-to-end time-to-complete for the test suite.
FWIW: I really dislike workarounds when it feels possible to resolve a root cause. But something I dislike more is disorder in continuous integration results and the surrounding collaboration problems that causes.
Also I have to admit that despite working on these tests for a while, I don't feel any closer to having been able to pinpoint the problem. I could make an excuse and say that that's due to not having access to profiling/tracing on the runner hosts.. it certainly makes things more difficult, but I feel like there would be a way to achieve better network/performance tracing using GitHub Actions with a bit of determined effort.
Although #12126 doesn't fix the timeouts, it does unlock running the linkcheck tests in parallel, and that should reduce the end-to-end time-to-complete for the test suite.
Also I have to admit that despite working on these tests for a while, I don't feel any closer to having been able to pinpoint the problem. I could make an excuse and say that that's due to not having access to profiling/tracing on the runner hosts.. it certainly makes things more difficult, but I feel like there would be a way to achieve better network/performance tracing using GitHub Actions with a bit of determined effort.
I wanted to check myself about this claim that parallelism should reduce the linkcheck tests time-to-completion. It seems not true on my machine when running pytest -n auto tests/test_builders/test_build_linkcheck.py with pytest-xdist when compared to a simple pytest tests/test_builders/test_build_linkcheck.py (2s vs 1.5s).
I understand that the parallelism may consume some more resources and require some more setup time, so that may be the reason. In theory it could still be beneficial to allow more of these tests to run in parallel and isolated.. but let's be cautious anyway.
This did help me to find the --durations parameter to pytest. It seems that the setup time for the firstlinkcheck test to run takes longer than the others. When running in serial, that first test is currently test_defaults -- the one that generally fails due to timeouts.
$ pytest --durations=0 tests/test_builders/test_build_linkcheck.py # without pytest-randomly installed
...
============================================= slowest durations ==============================================
0.09s setup tests/test_builders/test_build_linkcheck.py::test_defaults
0.08s call tests/test_builders/test_build_linkcheck.py::test_defaults
0.08s call tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_verify_false
0.06s call tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_with_requests_env_var
0.06s call tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_cacerts
...
0.01s setup tests/test_builders/test_build_linkcheck.py::test_requests_timeout
0.01s setup tests/test_builders/test_build_linkcheck.py::test_linkcheck_request_headers_no_slash
0.01s setup tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_cacerts
(44 durations < 0.005s hidden. Use -vv to show these durations.)
============================================= 39 passed in 1.46s =============================================
$ pytest --durations=0 tests/test_builders/test_build_linkcheck.py # with pytest-randomly installed
...
============================================= slowest durations ==============================================
0.11s setup tests/test_builders/test_build_linkcheck.py::test_limit_rate_user_max_delay
0.07s call tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_verify_false
0.07s call tests/test_builders/test_build_linkcheck.py::test_defaults
0.06s call tests/test_builders/test_build_linkcheck.py::test_connection_contention
0.06s call tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_cacerts
...
0.01s setup tests/test_builders/test_build_linkcheck.py::test_requests_timeout
0.01s setup tests/test_builders/test_build_linkcheck.py::test_unauthorized_broken
0.01s setup tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_nonexistent_cert_file
0.01s setup tests/test_builders/test_build_linkcheck.py::test_connect_to_selfsigned_fails
(44 durations < 0.005s hidden. Use -vv to show these durations.)
============================================= 39 passed in 1.47s =============================================
Those timings are not relevant in general because 0.02s of difference for setting up is essentially the time for your OS to setup resources. Then after the resources were once inintialized some of them could be cached (e.g., some of them could be in the L1/L2 or L3 cache).
Also, don't forget that the setup could also have import statements and thus you'll have more time just because of imports. But afterwards, modules are in sys.modules and you don't need to import them anymore.
You should worry if you have seconds of differences but not anything below 1s IMO.
Isolating tests and parallelizing them - for these, I agree that small time variances are not hugely relevant.
Figuring out the cause of timeouts within the linkcheck tests -- where we had 0.05s timeouts, and have increased those to 0.25s.
Although I think the setup phase in each test should occur strictly before the HTTP client begins waiting for the linkcheck_timeout duration, it seems relevant for me to investigate.
Activity
picnixz commentedon Mar 21, 2024
chrisjsewell commentedon Mar 21, 2024
changed, but yeh it seems once it happens once it just will not fix itself
picnixz commentedon Mar 21, 2024
Better to fix it then. Maybe it has something to do with caching actually?
chrisjsewell commentedon Mar 21, 2024
and its only for
Docutils HEAD; I don't know if there is a change in dependencieschrisjsewell commentedon Mar 21, 2024
Probably, it's ludicrous I literally can't get #12153 to pass anymore, and now #12154 as well 😒
chrisjsewell commentedon Mar 21, 2024
I think it is now failing every time: sphinx-doc/sphinx/actions/runs/8376347449/job/22935843069
[-]tests/test_builders/test_build_linkcheck.py::test_defaults is flaky with docutils HEAD[/-][+]tests/test_builders/test_build_linkcheck.py::test_defaults fails for docutils HEAD CI[/+][-]tests/test_builders/test_build_linkcheck.py::test_defaults fails for docutils HEAD CI[/-][+]tests/test_builders/test_build_linkcheck.py::test_defaults flaky for docutils HEAD CI[/+]jayaddison commentedon Mar 21, 2024
It seems not, nope - I've encountered one of these failures for the test-HTTP-port-isolation branch, the only branch I expected might affect this: https://github.com/sphinx-doc/sphinx/actions/runs/8379421681/job/22946289546?pr=12126
Maybe. Has anyone taken a look at the latest changes in
docutilsto see whether there is something relevant?Under some circumstances,
docutilsdoes make HTTP network requests while processing documents; but I can't initially think of any reason why that would affecttest_defaultsin particular.The other possibility is that this is somehow contention-related; we and/or GitHub may be more active than usual, or the runners may be lower-performance or constrained for some reasoning, producing timeouts. But for that to only seem to affect the
docutils HEADjobs would seem unusual.jayaddison commentedon Mar 21, 2024
I'm going to reluctantly suggest (with accompanying pull request) that we increase the timeouts for the linkcheck tests.
Although #12126 doesn't fix the timeouts, it does unlock running the
linkchecktests in parallel, and that should reduce the end-to-end time-to-complete for the test suite.jayaddison commentedon Mar 21, 2024
FWIW: I really dislike workarounds when it feels possible to resolve a root cause. But something I dislike more is disorder in continuous integration results and the surrounding collaboration problems that causes.
Also I have to admit that despite working on these tests for a while, I don't feel any closer to having been able to pinpoint the problem. I could make an excuse and say that that's due to not having access to profiling/tracing on the runner hosts.. it certainly makes things more difficult, but I feel like there would be a way to achieve better network/performance tracing using GitHub Actions with a bit of determined effort.
jayaddison commentedon Mar 22, 2024
I wanted to check myself about this claim that parallelism should reduce the
linkchecktests time-to-completion. It seems not true on my machine when runningpytest -n auto tests/test_builders/test_build_linkcheck.pywithpytest-xdistwhen compared to a simplepytest tests/test_builders/test_build_linkcheck.py(2s vs 1.5s).I understand that the parallelism may consume some more resources and require some more setup time, so that may be the reason. In theory it could still be beneficial to allow more of these tests to run in parallel and isolated.. but let's be cautious anyway.
This did help me to find the
--durationsparameter topytest. It seems that the setup time for the firstlinkchecktest to run takes longer than the others. When running in serial, that first test is currentlytest_defaults-- the one that generally fails due to timeouts.picnixz commentedon Mar 22, 2024
Those timings are not relevant in general because 0.02s of difference for setting up is essentially the time for your OS to setup resources. Then after the resources were once inintialized some of them could be cached (e.g., some of them could be in the L1/L2 or L3 cache).
Also, don't forget that the setup could also have import statements and thus you'll have more time just because of imports. But afterwards, modules are in
sys.modulesand you don't need to import them anymore.You should worry if you have seconds of differences but not anything below
1sIMO.jayaddison commentedon Mar 22, 2024
@picnixz there are two lines of exploration here:
linkchecktests -- where we had0.05stimeouts, and have increased those to0.25s.Although I think the
setupphase in each test should occur strictly before the HTTP client begins waiting for thelinkcheck_timeoutduration, it seems relevant for me to investigate.picnixz commentedon Mar 22, 2024
The
setupshould only concerns the pytest fixtures initializations.