Skip to content

Commit

Permalink
Fix failpoint being created on wrong server
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Sep 23, 2024
1 parent 17352ee commit 1511aa6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/Operation/WatchFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use MongoDB\Driver\Exception\ServerException;
use MongoDB\Driver\Monitoring\CommandSucceededEvent;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\ResumeTokenException;
use MongoDB\Exception\UnsupportedValueException;
Expand Down Expand Up @@ -1371,7 +1372,7 @@ public function testOriginalReadPreferenceIsPreservedOnResume(): void

$changeStream = $operation->execute($secondary);
$previousCursorId = $changeStream->getCursorId();
$this->forceChangeStreamResume();
$this->forceChangeStreamResume($secondary);

$changeStream->next();
$this->assertNotEquals($previousCursorId, $changeStream->getCursorId());
Expand Down Expand Up @@ -1611,17 +1612,20 @@ function (array $event) use (&$commands): void {
$this->assertEmpty($commands);
}

private function forceChangeStreamResume(): void
private function forceChangeStreamResume(?Server $server = null): void
{
$this->configureFailPoint([
'configureFailPoint' => 'failCommand',
'mode' => ['times' => 1],
'data' => [
'failCommands' => ['getMore'],
'errorCode' => self::NOT_PRIMARY,
'errorLabels' => ['ResumableChangeStreamError'],
$this->configureFailPoint(
[
'configureFailPoint' => 'failCommand',
'mode' => ['times' => 1],
'data' => [
'failCommands' => ['getMore'],
'errorCode' => self::NOT_PRIMARY,
'errorLabels' => ['ResumableChangeStreamError'],
],
],
]);
$server,
);
}

private function getPostBatchResumeTokenFromReply(stdClass $reply)
Expand Down

0 comments on commit 1511aa6

Please sign in to comment.