Skip to content

Commit 4b56b94

Browse files
committed
core: Fix flakiness in polling_monitor_cancelation test
1 parent 44ce4f9 commit 4b56b94

File tree

1 file changed

+11
-2
lines changed
  • core/src/polling_monitor

1 file changed

+11
-2
lines changed

core/src/polling_monitor/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,16 +356,25 @@ mod tests {
356356

357357
#[graph::test]
358358
async fn polling_monitor_cancelation() {
359+
const REQ: &str = "req-0";
360+
359361
// Cancelation on receiver drop, no pending request.
360362
let (mut handle, _monitor, rx) = setup();
361363
drop(rx);
362364
assert!(handle.next_request().await.is_none());
363365

364366
// Cancelation on receiver drop, with pending request.
365367
let (mut handle, monitor, rx) = setup();
366-
monitor.monitor("req-0");
368+
monitor.monitor(REQ);
367369
drop(rx);
368-
assert!(handle.next_request().await.is_none());
370+
let mut next = handle.next_request().await;
371+
if let Some((a, _)) = next {
372+
// The request may or may not have been pulled from the queue
373+
// before cancelation.
374+
assert_eq!(REQ, a);
375+
next = handle.next_request().await;
376+
}
377+
assert!(next.is_none());
369378

370379
// Cancelation on receiver drop, while queue is waiting.
371380
let (mut handle, _monitor, rx) = setup();

0 commit comments

Comments
 (0)