Skip to content

Commit f68373f

Browse files
RUST-1273 Increase timeout for retry pool cleared tests (#827)
1 parent 43cc782 commit f68373f

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

src/runtime/join_handle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) enum AsyncJoinHandle<T> {
2121
}
2222

2323
impl<T> Future for AsyncJoinHandle<T> {
24-
// tokio wraps the Output of its JoinHandle in a Result that conatins an error if the task
24+
// tokio wraps the Output of its JoinHandle in a Result that contains an error if the task
2525
// panicked, while async-std does not.
2626
//
2727
// Given that async-std will panic or abort the task in this scenario, there is not a

src/test/spec/retryable_reads.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async fn retry_read_pool_cleared() {
130130
.await
131131
.into_iter()
132132
.collect::<Result<Vec<_>>>()
133-
.expect("all should succeeed");
133+
.expect("all should succeed");
134134

135135
let _ = subscriber
136136
.wait_for_event(Duration::from_millis(500), |event| {
@@ -146,15 +146,25 @@ async fn retry_read_pool_cleared() {
146146
.await
147147
.expect("pool clear should occur");
148148

149-
let _ = subscriber
150-
.wait_for_event(Duration::from_millis(500), |event| match event {
151-
Event::Cmap(CmapEvent::ConnectionCheckoutFailed(e)) => {
152-
matches!(e.reason, ConnectionCheckoutFailedReason::ConnectionError)
153-
}
149+
let next_cmap_events = subscriber
150+
.collect_events(Duration::from_millis(1000), |event| match event {
151+
Event::Cmap(_) => true,
154152
_ => false,
155153
})
156-
.await
157-
.expect("second checkout should fail");
154+
.await;
155+
156+
if !next_cmap_events.iter().any(|event| match event {
157+
Event::Cmap(CmapEvent::ConnectionCheckoutFailed(e)) => {
158+
matches!(e.reason, ConnectionCheckoutFailedReason::ConnectionError)
159+
}
160+
_ => false,
161+
}) {
162+
panic!(
163+
"Expected second checkout to fail, but no ConnectionCheckoutFailed event observed. \
164+
CMAP events:\n{:?}",
165+
next_cmap_events
166+
);
167+
}
158168

159169
assert_eq!(handler.get_command_started_events(&["find"]).len(), 3);
160170
}

src/test/spec/retryable_writes/mod.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,25 @@ async fn retry_write_pool_cleared() {
478478
.await
479479
.expect("pool clear should occur");
480480

481-
let _ = subscriber
482-
.wait_for_event(Duration::from_millis(500), |event| match event {
483-
Event::Cmap(CmapEvent::ConnectionCheckoutFailed(e)) => {
484-
matches!(e.reason, ConnectionCheckoutFailedReason::ConnectionError)
485-
}
481+
let next_cmap_events = subscriber
482+
.collect_events(Duration::from_millis(1000), |event| match event {
483+
Event::Cmap(_) => true,
486484
_ => false,
487485
})
488-
.await
489-
.expect("second checkout should fail");
486+
.await;
487+
488+
if !next_cmap_events.iter().any(|event| match event {
489+
Event::Cmap(CmapEvent::ConnectionCheckoutFailed(e)) => {
490+
matches!(e.reason, ConnectionCheckoutFailedReason::ConnectionError)
491+
}
492+
_ => false,
493+
}) {
494+
panic!(
495+
"Expected second checkout to fail, but no ConnectionCheckoutFailed event observed. \
496+
CMAP events:\n{:?}",
497+
next_cmap_events
498+
);
499+
}
490500

491501
assert_eq!(handler.get_command_started_events(&["insert"]).len(), 3);
492502
}

0 commit comments

Comments
 (0)