Skip to content

Commit 6ab1062

Browse files
committed
PHPLIB-461: Fix ChangeStream tests on sharded clusters
1 parent c69a715 commit 6ab1062

File tree

4 files changed

+130
-62
lines changed

4 files changed

+130
-62
lines changed

src/ChangeStream.php

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

5253
/** @var callable */
@@ -180,6 +181,11 @@ private function isResumableError(RuntimeException $exception)
180181
return false;
181182
}
182183

184+
/* The ServerException doesn't expose the NonResumableChangeStreamError
185+
* label. Thus, the error code for the corresponding server exception
186+
* has been marked as non-resumable. This can be reverted once PHPC-1419
187+
* is fixed.
188+
*/
183189
if ($exception->hasErrorLabel('NonResumableChangeStreamError')) {
184190
return false;
185191
}

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
@@ -334,9 +334,6 @@ protected function skipIfChangeStreamIsNotSupported()
334334
if (! $this->isShardedClusterUsingReplicasets()) {
335335
$this->markTestSkipped('$changeStream is only supported with replicasets');
336336
}
337-
338-
// Temporarily skip tests because of an issue with change streams in the driver
339-
$this->markTestSkipped('$changeStreams currently don\'t on replica sets');
340337
break;
341338

342339
case Server::TYPE_RS_PRIMARY:

0 commit comments

Comments
 (0)