tests: fix flaky reckless tests by waiting for the canned github server#9306
Open
ksedgwic wants to merge 1 commit into
Open
tests: fix flaky reckless tests by waiting for the canned github server#9306ksedgwic wants to merge 1 commit into
ksedgwic wants to merge 1 commit into
Conversation
Open
Andezion
approved these changes
Jul 16, 2026
Andezion
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me! pyln.testing.utils.wait_for() already implements this poll-with-backoff pattern elsewhere in the suite - so could reuse it here instead of a hand-rolled loop?(though the custom loop works fine as-is!!)
| # first reckless invocation doesn't race it and get connection refused. | ||
| start = time.time() | ||
| while True: | ||
| assert server.poll() is None, "canned github server died" |
The canned_github_server fixture Popens a Flask server and never waits for it to start listening; the git repository setup between the Popen and the yield usually gives it enough time. Under CI load it can lose that race: a valgrind-shard failure shows test_search's first reckless invocation getting connection refused within a second of the test starting, while Flask's "Running on http://127.0.0.1:..." banner only appears in the log after the test had already failed. Wait for the port to accept connections before yielding, and fail loudly if the server process dies instead of coming up. Changelog-None
Andezion
force-pushed
the
fix-flaky-reckless-server-race
branch
from
July 16, 2026 23:20
4dbffb8 to
13cc9a2
Compare
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.
Observed on a CI run for #9286 (Valgrind Test CLN 1/12, test_search):
https://github.com/ElementsProject/lightning/actions/runs/29122024616/job/86461830290
The canned_github_server fixture starts a Flask server with Popen and
never waits for it to listen; the git repository setup between the
Popen and the yield usually gives it enough time. Under CI load it
can lose that race: in the failure above, test_search's first
reckless invocation got connection refused within a second of the
test starting, and Flask's "Running on http://127.0.0.1:39495"
banner only appears in the log after the test had already failed
(so the server did come up and bind its port -- just too late).
The fix waits for the port to accept connections before yielding, and
fails loudly if the server process dies instead of coming up.
Changelog-None