Skip to content

Commit e0bb095

Browse files
committed
PHPLIB-461: Fix ChangeStream tests on sharded clusters
1 parent 9074847 commit e0bb095

File tree

5 files changed

+116
-55
lines changed

5 files changed

+116
-55
lines changed

src/ChangeStream.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class ChangeStream implements Iterator
4444
136, // CappedPositionLost
4545
237, // CursorKilled
4646
11601, // Interrupted
47+
280, // ChangeStreamFatalError
4748
];
4849

4950
private $resumeCallable;
@@ -171,6 +172,11 @@ private function isResumableError(RuntimeException $exception)
171172
return false;
172173
}
173174

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

tests/DocumentationExamplesTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,10 @@ public function testChangeStreamExample_1_4()
928928
{
929929
$this->skipIfChangeStreamIsNotSupported();
930930

931+
if ($this->isShardedCluster()) {
932+
$this->markTestSkipped('Test does not apply on sharded clusters: need more than a single getMore call on the change stream.');
933+
}
934+
931935
$db = new Database($this->manager, $this->getDatabaseName());
932936
$db->dropCollection('inventory');
933937
$db->createCollection('inventory');

tests/FunctionalTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ protected function skipIfChangeStreamIsNotSupported()
320320
if (!$this->isShardedClusterUsingReplicasets()) {
321321
$this->markTestSkipped('$changeStream is only supported with replicasets');
322322
}
323-
324-
// Temporarily skip tests because of an issue with change streams in the driver
325-
$this->markTestSkipped('$changeStreams currently don\'t on replica sets');
326323
break;
327324

328325
case Server::TYPE_RS_PRIMARY:

0 commit comments

Comments
 (0)