Commit f9167cf
committed
test: drain multicast queues before TOCTOU race assertion
`test_service_info_async_request` patches `_is_complete` to False
to keep the loop running. With `quick_timing` registrations
complete within ~30ms, leaving multicast responses pending in
`out_queue` / `out_delay_queue` that snapshot the records as
they were *before* `async_update_service` swapped the registry
to `new_info`. When those stale answers flush after
`_clear_cache`, they re-cache `xxxyyy._test1-srvc-type._tcp.local.
-> ash-1.local. -> 10.0.1.2` and set the AsyncServiceInfo's
server to `ash-1.local.`. The patched `_is_complete=False` loop
then keeps asking for A records for `ash-1.local.`, which nothing
in the registry answers, so the assertion fails:
AssertionError: assert [b'\\n\\x00\\x01\\x02'] == [b'\\n\\x00\\x01\\x03']
Sleep 1.5s before clearing the cache so both queues drain (max
~620ms for `out_queue` and ~1320ms for `out_delay_queue`) and
only the up-to-date registry state is left for the loop to
observe.1 parent dd341a3 commit f9167cf
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
698 | 708 | | |
699 | 709 | | |
700 | 710 | | |
| |||
0 commit comments