From 473fd23f8bd1fa15b01797139d57a87156d12749 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 5 Jul 2023 16:40:22 +0100 Subject: [PATCH] tor-dirmgr: bridge descriptor tests: Fix a v. low prob. race Drain a number of events, not just one. The stream might yield many events, as explained in this new comment. This fails every time with MockExecutor::try_test_with_various(). I think it might fail with the tokio exeuctor too, but evidently not with high probability or we would have noticed. --- crates/tor-dirmgr/src/bridgedesc/bdtest.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/tor-dirmgr/src/bridgedesc/bdtest.rs b/crates/tor-dirmgr/src/bridgedesc/bdtest.rs index 717e5e84f..66de79397 100644 --- a/crates/tor-dirmgr/src/bridgedesc/bdtest.rs +++ b/crates/tor-dirmgr/src/bridgedesc/bdtest.rs @@ -362,8 +362,11 @@ async fn success() -> Result<(), anyhow::Error> { drop(hold); - // should produce a removed bridge event - let () = stream_drain_until(1, &mut events, || async { + // Check that queues become empty. + // Depending on scheduling, there may be tasks still live from the work above. + // For example, one of the requeues might be still running after we did the remove. + // So we may get a number of change events. Certainly not more than 10. + let () = stream_drain_until(10, &mut events, || async { bdm.check_consistency(Some(&bridges)); queues_are_empty(&bdm) })