17
17
18
18
class WatchFunctionalTest extends FunctionalTestCase
19
19
{
20
- private $ defaultOptions = ['maxAwaitTimeMS ' => 100 ];
20
+ private $ defaultOptions = ['maxAwaitTimeMS ' => 500 ];
21
21
22
22
public function setUp ()
23
23
{
@@ -380,13 +380,18 @@ public function testMaxAwaitTimeMS()
380
380
/* On average, an acknowledged write takes about 20 ms to appear in a
381
381
* change stream on the server so we'll use a higher maxAwaitTimeMS to
382
382
* ensure we see the write. */
383
- $ maxAwaitTimeMS = 100 ;
383
+ $ maxAwaitTimeMS = 500 ;
384
384
385
385
/* Calculate an approximate pivot to use for time assertions. We will
386
386
* assert that the duration of blocking responses is greater than this
387
387
* value, and vice versa. */
388
388
$ pivot = ($ maxAwaitTimeMS * 0.001 ) * 0.9 ;
389
389
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
+
390
395
$ operation = new Watch ($ this ->manager , $ this ->getDatabaseName (), $ this ->getCollectionName (), [], ['maxAwaitTimeMS ' => $ maxAwaitTimeMS ]);
391
396
$ changeStream = $ operation ->execute ($ this ->getPrimaryServer ());
392
397
@@ -399,7 +404,7 @@ public function testMaxAwaitTimeMS()
399
404
$ changeStream ->rewind ();
400
405
$ duration = microtime (true ) - $ startTime ;
401
406
$ this ->assertGreaterThan ($ pivot , $ duration );
402
- $ this ->assertLessThan (0.5 , $ duration );
407
+ $ this ->assertLessThan ($ upperBound , $ duration );
403
408
404
409
$ this ->assertFalse ($ changeStream ->valid ());
405
410
@@ -409,7 +414,7 @@ public function testMaxAwaitTimeMS()
409
414
$ changeStream ->next ();
410
415
$ duration = microtime (true ) - $ startTime ;
411
416
$ this ->assertGreaterThan ($ pivot , $ duration );
412
- $ this ->assertLessThan (0.5 , $ duration );
417
+ $ this ->assertLessThan ($ upperBound , $ duration );
413
418
414
419
$ this ->assertFalse ($ changeStream ->valid ());
415
420
0 commit comments