test(kad_dht): de-flake dht_pair fixture with a bounded poll (#1423) - #1424
Open
yashksaini-coder wants to merge 3 commits into
Open
test(kad_dht): de-flake dht_pair fixture with a bounded poll (#1423)#1424yashksaini-coder wants to merge 3 commits into
yashksaini-coder wants to merge 3 commits into
Conversation
…1423) The dht_pair fixture waited a fixed trio.sleep(0.1) and then hard-asserted peer_in_table in both directions. The routing tables are populated by the background refresh manager (time-driven mutual FIND_NODE), so under CI load 0.1s wasn't enough and setup failed with "Node A should know about Node B". Poll until both directions land, bounded by trio.fail_after(10) so a peer that genuinely never appears still fails loud (TooSlowError). Same idiom as the libp2p#1401 / libp2p#1408 de-flakes. Closes libp2p#1423.
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.
What
The
dht_pairfixture intests/core/kad_dht/test_kad_dht.pyintermittently failed CI during setup with:It waited a fixed
trio.sleep(0.1)and then hard-assertedpeer_in_tablein both directions.Why it raced
The mutual routing-table entries aren't populated by the
find_peercalls (those short-circuit on the peerstore without writing to the routing table). They're populated by the background refresh manager — a time-driven random walk that opens mutualFIND_NODEstreams and adds each peer viahandle_stream. Under CI load that takes longer than the fixed0.1s, so the assertion fired before discovery converged.Fix
Poll
peer_in_table(both directions) until it holds, bounded bytrio.fail_after(10)so a peer that genuinely never lands still fails loud withTooSlowErrorinstead of hanging or passing. Same pattern as the already-merged de-flakes in #1401 / #1408.The fixed sleep is removed; the
find_peercalls stay as a best-effort nudge.Impact
This fixture backs ~5 tests. The same flake has tripped up two unrelated PRs recently (#1395, #1409) purely on this fixture — this unblocks both once merged.
Locally:
tests/core/kad_dht/test_kad_dht.pypasses 9/9, stable across repeated runs.Closes #1423.