1717
1818class WatchFunctionalTest extends FunctionalTestCase
1919{
20- private $ defaultOptions = ['maxAwaitTimeMS ' => 100 ];
20+ private $ defaultOptions = ['maxAwaitTimeMS ' => 500 ];
2121
2222 public function setUp ()
2323 {
@@ -380,13 +380,18 @@ public function testMaxAwaitTimeMS()
380380 /* On average, an acknowledged write takes about 20 ms to appear in a
381381 * change stream on the server so we'll use a higher maxAwaitTimeMS to
382382 * ensure we see the write. */
383- $ maxAwaitTimeMS = 100 ;
383+ $ maxAwaitTimeMS = 500 ;
384384
385385 /* Calculate an approximate pivot to use for time assertions. We will
386386 * assert that the duration of blocking responses is greater than this
387387 * value, and vice versa. */
388388 $ pivot = ($ maxAwaitTimeMS * 0.001 ) * 0.9 ;
389389
390+ /* Calculate an approximate upper bound to use for time assertions. We
391+ * will assert that the duration of blocking responses is less than this
392+ * value. */
393+ $ upperBound = ($ maxAwaitTimeMS * 0.001 ) * 1.5 ;
394+
390395 $ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], ['maxAwaitTimeMS ' => $ maxAwaitTimeMS ]);
391396 $ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
392397
@@ -399,7 +404,7 @@ public function testMaxAwaitTimeMS()
399404 $ changeStream ->rewind ();
400405 $ duration = microtime (true ) - $ startTime ;
401406 $ this ->assertGreaterThan ($ pivot , $ duration );
402- $ this ->assertLessThan (0.5 , $ duration );
407+ $ this ->assertLessThan ($ upperBound , $ duration );
403408
404409 $ this ->assertFalse ($ changeStream ->valid ());
405410
@@ -409,7 +414,7 @@ public function testMaxAwaitTimeMS()
409414 $ changeStream ->next ();
410415 $ duration = microtime (true ) - $ startTime ;
411416 $ this ->assertGreaterThan ($ pivot , $ duration );
412- $ this ->assertLessThan (0.5 , $ duration );
417+ $ this ->assertLessThan ($ upperBound , $ duration );
413418
414419 $ this ->assertFalse ($ changeStream ->valid ());
415420
0 commit comments