@@ -380,6 +380,11 @@ public function testMaxAwaitTimeMS()
380380 * ensure we see the write. */
381381 $ maxAwaitTimeMS = 100 ;
382382
383+ /* Calculate an approximate pivot to use for time assertions. We will
384+ * assert that the duration of blocking responses is greater than this
385+ * value, and vice versa. */
386+ $ pivot = ($ maxAwaitTimeMS * 0.001 ) * 0.9 ;
387+
383388 $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], ['maxAwaitTimeMS ' => $ maxAwaitTimeMS ]);
384389 $ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
385390
@@ -391,7 +396,7 @@ public function testMaxAwaitTimeMS()
391396 $ startTime = microtime (true );
392397 $ changeStream ->rewind ();
393398 $ duration = microtime (true ) - $ startTime ;
394- $ this ->assertGreaterThanOrEqual ( $ maxAwaitTimeMS * 0.001 , $ duration );
399+ $ this ->assertGreaterThan ( $ pivot , $ duration );
395400 $ this ->assertLessThan (0.5 , $ duration );
396401
397402 $ this ->assertFalse ($ changeStream ->valid ());
@@ -401,7 +406,7 @@ public function testMaxAwaitTimeMS()
401406 $ startTime = microtime (true );
402407 $ changeStream ->next ();
403408 $ duration = microtime (true ) - $ startTime ;
404- $ this ->assertGreaterThanOrEqual ( $ maxAwaitTimeMS * 0.001 , $ duration );
409+ $ this ->assertGreaterThan ( $ pivot , $ duration );
405410 $ this ->assertLessThan (0.5 , $ duration );
406411
407412 $ this ->assertFalse ($ changeStream ->valid ());
@@ -413,7 +418,7 @@ public function testMaxAwaitTimeMS()
413418 $ startTime = microtime (true );
414419 $ changeStream ->next ();
415420 $ duration = microtime (true ) - $ startTime ;
416- $ this ->assertLessThan ($ maxAwaitTimeMS * 0.001 , $ duration );
421+ $ this ->assertLessThan ($ pivot , $ duration );
417422 $ this ->assertTrue ($ changeStream ->valid ());
418423 }
419424
0 commit comments