File tree Expand file tree Collapse file tree 3 files changed +36
-16
lines changed Expand file tree Collapse file tree 3 files changed +36
-16
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ pub(crate) enum AsyncJoinHandle<T> {
21
21
}
22
22
23
23
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
25
25
// panicked, while async-std does not.
26
26
//
27
27
// Given that async-std will panic or abort the task in this scenario, there is not a
Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ async fn retry_read_pool_cleared() {
130
130
. await
131
131
. into_iter ( )
132
132
. collect :: < Result < Vec < _ > > > ( )
133
- . expect ( "all should succeeed " ) ;
133
+ . expect ( "all should succeed " ) ;
134
134
135
135
let _ = subscriber
136
136
. wait_for_event ( Duration :: from_millis ( 500 ) , |event| {
@@ -146,15 +146,25 @@ async fn retry_read_pool_cleared() {
146
146
. await
147
147
. expect ( "pool clear should occur" ) ;
148
148
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 ,
154
152
_ => false ,
155
153
} )
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
+ }
158
168
159
169
assert_eq ! ( handler. get_command_started_events( & [ "find" ] ) . len( ) , 3 ) ;
160
170
}
Original file line number Diff line number Diff line change @@ -478,15 +478,25 @@ async fn retry_write_pool_cleared() {
478
478
. await
479
479
. expect ( "pool clear should occur" ) ;
480
480
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 ,
486
484
_ => false ,
487
485
} )
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
+ }
490
500
491
501
assert_eq ! ( handler. get_command_started_events( & [ "insert" ] ) . len( ) , 3 ) ;
492
502
}
You can’t perform that action at this time.
0 commit comments