Repository navigation
CI: tests that failed at random on a busy runner - #83
Merged
Merged
Conversation
… and wait for the processes they start
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests in this repo failed at random in CI and passed on a re-run. This makes them deterministic.
LiveSizeTest (scores, notifications) and friends LoopTest: "Executing <Task ...> took 0.337 seconds"
Cause: asyncio's slow-callback warning measures wall time. On a busy runner the process is simply not scheduled for a while, so a 3 ms step "took" 300+ ms. Seen on #80's run, and on earlier runs on main and in PRs (Linux and Windows, 3.12 and 3.14); more tests in the same classes fail the same way under load.
Fix: new
tests/support.loop_steps_under(limit)measures the CPU time of every loop step (thread CPU time), which is the same on a quiet machine and a busy one; the wall-time warning is switched off in those tests. Thetooktimings in the same tests use CPU time too. The limits (0.05 / 0.25 s) and the checks that the whole file is never written on the loop thread are unchanged. Waits that use no CPU (a journal flush, a lock the writing thread holds, a tick that sleeps) are covered by wall-time medians: the median of the timed calls (scores, notifications) must be under 0.05 s, a new friends test takes the median of 5 ticks (under 0.25 s), and the wake-up lag check is now a median too (it was the worst one, which a descheduled process fails). A median of 25-41 calls is not moved by a few calls the runner did not schedule, but a wait on every call is; the worst single call is measured in CPU time only. In the slow-disk test a loop that waits for the writing thread now fails the test after 30 s instead of hanging.tests/core/test_loop_steps.pytests the helper.Loops (6 busy processes at nice 19, 2 runs at a time, the three classes): before 3 failures in 24 runs (with a heavier load: nearly every run); after 0 in 14 runs. With the process stopped (SIGSTOP) for 0.34 s every 0.7 s, and 0.4 s every 0.3 s, 3 runs each of the three classes pass after the change (main failed 2 of 3 in the first case). Mutations (the change made again in the server source: whole file on the loop, unguarded whole-file write, the journal flush or the friends tick blocking the loop 300 ms, the loop waiting for the checkpoint lock, the disk walk on the loop) are all caught.
test_relay_processes: "the relay did not link" (failed once on a game repo PR run, passed on re-run)
Cause: the test started the main server and the relay at once. When the main server is still starting on a slow runner, the relay's first link is lost and it retries only every 5 s, and the 30 s limit also had to cover both process starts. The child logs were thrown away, so nothing showed it.
Fix: the test waits until the main server answers /status and the relay has logged that it runs, then the 30 s link limit starts; the same after the main server's restart. The server logs are kept and printed when a wait fails. I could not make the old test fail here (52 runs under load passed), so this cause is from reading the code and the log, not proven by a failing loop; after: see the runs below.
Full suite on 3.12 and 3.14: 1271 tests OK.