Skip to content

Commit 1511aa6

Browse files
committed
Fix failpoint being created on wrong server
1 parent 17352ee commit 1511aa6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

tests/Operation/WatchFunctionalTest.php

+14-10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use MongoDB\Driver\Exception\ServerException;
1919
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
2020
use MongoDB\Driver\ReadPreference;
21+
use MongoDB\Driver\Server;
2122
use MongoDB\Driver\WriteConcern;
2223
use MongoDB\Exception\ResumeTokenException;
2324
use MongoDB\Exception\UnsupportedValueException;
@@ -1371,7 +1372,7 @@ public function testOriginalReadPreferenceIsPreservedOnResume(): void
13711372

13721373
$changeStream = $operation->execute($secondary);
13731374
$previousCursorId = $changeStream->getCursorId();
1374-
$this->forceChangeStreamResume();
1375+
$this->forceChangeStreamResume($secondary);
13751376

13761377
$changeStream->next();
13771378
$this->assertNotEquals($previousCursorId, $changeStream->getCursorId());
@@ -1611,17 +1612,20 @@ function (array $event) use (&$commands): void {
16111612
$this->assertEmpty($commands);
16121613
}
16131614

1614-
private function forceChangeStreamResume(): void
1615+
private function forceChangeStreamResume(?Server $server = null): void
16151616
{
1616-
$this->configureFailPoint([
1617-
'configureFailPoint' => 'failCommand',
1618-
'mode' => ['times' => 1],
1619-
'data' => [
1620-
'failCommands' => ['getMore'],
1621-
'errorCode' => self::NOT_PRIMARY,
1622-
'errorLabels' => ['ResumableChangeStreamError'],
1617+
$this->configureFailPoint(
1618+
[
1619+
'configureFailPoint' => 'failCommand',
1620+
'mode' => ['times' => 1],
1621+
'data' => [
1622+
'failCommands' => ['getMore'],
1623+
'errorCode' => self::NOT_PRIMARY,
1624+
'errorLabels' => ['ResumableChangeStreamError'],
1625+
],
16231626
],
1624-
]);
1627+
$server,
1628+
);
16251629
}
16261630

16271631
private function getPostBatchResumeTokenFromReply(stdClass $reply)

0 commit comments

Comments
 (0)