Skip to content

Commit c882eec

Browse files
committed
PHPLIB-461: Fix ChangeStream tests on sharded clusters
1 parent 67ffd33 commit c882eec

File tree

4 files changed

+118
-60
lines changed

4 files changed

+118
-60
lines changed

src/ChangeStream.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ChangeStream implements Iterator
4646
136, // CappedPositionLost
4747
237, // CursorKilled
4848
11601, // Interrupted
49+
280, // ChangeStreamFatalError
4950
];
5051

5152
private $resumeCallable;
@@ -172,6 +173,11 @@ private function isResumableError(RuntimeException $exception)
172173
return false;
173174
}
174175

176+
/* The ServerException doesn't expose the NonResumableChangeStreamError
177+
* label. Thus, the error code for the corresponding server exception
178+
* has been marked as non-resumable. This can be reverted once PHPC-1419
179+
* is fixed.
180+
*/
175181
if ($exception->hasErrorLabel('NonResumableChangeStreamError')) {
176182
return false;
177183
}

tests/DocumentationExamplesTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,10 @@ public function testChangeStreamExample_1_4()
935935
{
936936
$this->skipIfChangeStreamIsNotSupported();
937937

938+
if ($this->isShardedCluster()) {
939+
$this->markTestSkipped('Test does not apply on sharded clusters: need more than a single getMore call on the change stream.');
940+
}
941+
938942
$db = new Database($this->manager, $this->getDatabaseName());
939943
$db->dropCollection('inventory');
940944
$db->createCollection('inventory');

tests/FunctionalTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,6 @@ protected function skipIfChangeStreamIsNotSupported()
332332
if (! $this->isShardedClusterUsingReplicasets()) {
333333
$this->markTestSkipped('$changeStream is only supported with replicasets');
334334
}
335-
336-
// Temporarily skip tests because of an issue with change streams in the driver
337-
$this->markTestSkipped('$changeStreams currently don\'t on replica sets');
338335
break;
339336

340337
case Server::TYPE_RS_PRIMARY:

0 commit comments

Comments
 (0)