Skip to content

Commit 726cba9

Browse files
committed
Remove obsolete skips and tests for MongoDB 4.0
1 parent d70dcb8 commit 726cba9

File tree

3 files changed

+1
-177
lines changed

3 files changed

+1
-177
lines changed

tests/FunctionalTestCase.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ protected function assertSameObjectId($expectedObjectId, $actualObjectId): void
215215
*/
216216
public function configureFailPoint(array|stdClass $command, ?Server $server = null): void
217217
{
218-
if (! $this->isFailCommandSupported()) {
219-
$this->markTestSkipped('failCommand is only supported on mongod >= 4.0.0 and mongos >= 4.1.5.');
220-
}
221-
222218
if (! $this->isFailCommandEnabled()) {
223219
$this->markTestSkipped('The enableTestCommands parameter is not enabled.');
224220
}
@@ -512,15 +508,7 @@ protected function skipIfTransactionsAreNotSupported(): void
512508
}
513509

514510
if ($this->isShardedCluster()) {
515-
if (version_compare($this->getFeatureCompatibilityVersion(), '4.2', '<')) {
516-
$this->markTestSkipped('Transactions are only supported on FCV 4.2 or higher');
517-
}
518-
519-
return;
520-
}
521-
522-
if (version_compare($this->getFeatureCompatibilityVersion(), '4.0', '<')) {
523-
$this->markTestSkipped('Transactions are only supported on FCV 4.0 or higher');
511+
$this->markTestSkipped('Transactions are only supported on FCV 4.2 or higher');
524512
}
525513

526514
if ($this->getServerStorageEngine() !== 'wiredTiger') {
@@ -698,16 +686,6 @@ private static function getUriWithoutMultipleMongoses(): string
698686
return $uri;
699687
}
700688

701-
/**
702-
* Checks if the failCommand command is supported on this server version
703-
*/
704-
private function isFailCommandSupported(): bool
705-
{
706-
$minVersion = $this->isShardedCluster() ? '4.1.5' : '4.0.0';
707-
708-
return version_compare($this->getServerVersion(), $minVersion, '>=');
709-
}
710-
711689
/**
712690
* Checks if the failCommand command is enabled by checking the enableTestCommands parameter
713691
*/

tests/Operation/ExplainFunctionalTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,6 @@ public function testUpdateOne($verbosity, $executionStatsExpected, $allPlansExec
307307

308308
public function testAggregate(): void
309309
{
310-
$this->skipIfServerVersion('<', '4.0.0', 'Explaining aggregate command requires server version >= 4.0');
311-
312310
$this->createFixtures(3);
313311

314312
// Use a $sort stage to ensure the aggregate does not get optimised to a query

tests/Operation/WatchFunctionalTest.php

Lines changed: 0 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Generator;
77
use Iterator;
88
use MongoDB\BSON\Document;
9-
use MongoDB\BSON\TimestampInterface;
109
use MongoDB\ChangeStream;
1110
use MongoDB\Codec\DecodeIfSupported;
1211
use MongoDB\Codec\DocumentCodec;
@@ -106,44 +105,6 @@ public function encode($value): Document
106105
];
107106
}
108107

109-
/**
110-
* Prose test 1: "ChangeStream must continuously track the last seen
111-
* resumeToken"
112-
*/
113-
#[DataProvider('provideCodecOptions')]
114-
public function testGetResumeToken(array $options, Closure $getIdentifier): void
115-
{
116-
$this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken is supported');
117-
118-
$operation = new Watch(
119-
$this->manager,
120-
$this->getDatabaseName(),
121-
$this->getCollectionName(),
122-
[],
123-
$options + $this->defaultOptions,
124-
);
125-
$changeStream = $operation->execute($this->getPrimaryServer());
126-
127-
$changeStream->rewind();
128-
$this->assertFalse($changeStream->valid());
129-
$this->assertNull($changeStream->getResumeToken());
130-
131-
$this->insertDocument(['x' => 1]);
132-
$this->insertDocument(['x' => 2]);
133-
134-
$this->advanceCursorUntilValid($changeStream);
135-
$this->assertSameDocument($getIdentifier($changeStream->current()), $changeStream->getResumeToken());
136-
137-
$changeStream->next();
138-
$this->assertTrue($changeStream->valid());
139-
$this->assertSameDocument($getIdentifier($changeStream->current()), $changeStream->getResumeToken());
140-
141-
$this->insertDocument(['x' => 3]);
142-
143-
$this->advanceCursorUntilValid($changeStream);
144-
$this->assertSameDocument($getIdentifier($changeStream->current()), $changeStream->getResumeToken());
145-
}
146-
147108
/**
148109
* Prose test 1: "ChangeStream must continuously track the last seen
149110
* resumeToken"
@@ -165,8 +126,6 @@ public function testGetResumeToken(array $options, Closure $getIdentifier): void
165126
#[DataProvider('provideCodecOptions')]
166127
public function testGetResumeTokenWithPostBatchResumeToken(array $options, Closure $getIdentifier): void
167128
{
168-
$this->skipIfServerVersion('<', '4.0.7', 'postBatchResumeToken is not supported');
169-
170129
$operation = new Watch(
171130
$this->manager,
172131
$this->getDatabaseName(),
@@ -267,8 +226,6 @@ function (array $event) use (&$commands): void {
267226

268227
public function testResumeBeforeReceivingAnyResultsIncludesPostBatchResumeToken(): void
269228
{
270-
$this->skipIfServerVersion('<', '4.0.7', 'postBatchResumeToken is not supported');
271-
272229
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
273230

274231
$events = [];
@@ -330,79 +287,6 @@ private function assertResumeAfter($expectedResumeToken, stdClass $command): voi
330287
$this->assertEquals($expectedResumeToken, $command->pipeline[0]->{'$changeStream'}->resumeAfter);
331288
}
332289

333-
/**
334-
* Prose test 9: "$changeStream stage for ChangeStream against a server
335-
* >=4.0 and <4.0.7 that has not received any results yet MUST include a
336-
* startAtOperationTime option when resuming a changestream."
337-
*/
338-
public function testResumeBeforeReceivingAnyResultsIncludesStartAtOperationTime(): void
339-
{
340-
$this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken takes precedence over startAtOperationTime');
341-
342-
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
343-
344-
$events = [];
345-
346-
(new CommandObserver())->observe(
347-
function () use ($operation, &$changeStream): void {
348-
$changeStream = $operation->execute($this->getPrimaryServer());
349-
},
350-
function (array $event) use (&$events): void {
351-
$events[] = $event;
352-
},
353-
);
354-
355-
$this->assertCount(1, $events);
356-
$this->assertSame('aggregate', $events[0]['started']->getCommandName());
357-
$reply = $events[0]['succeeded']->getReply();
358-
$this->assertObjectHasProperty('operationTime', $reply);
359-
$operationTime = $reply->operationTime;
360-
$this->assertInstanceOf(TimestampInterface::class, $operationTime);
361-
362-
$this->assertFalse($changeStream->valid());
363-
$this->forceChangeStreamResume();
364-
365-
$this->assertNoCommandExecuted(function () use ($changeStream): void {
366-
$changeStream->rewind();
367-
});
368-
369-
$events = [];
370-
371-
(new CommandObserver())->observe(
372-
function () use ($changeStream): void {
373-
$changeStream->next();
374-
},
375-
function (array $event) use (&$events): void {
376-
$events[] = $event;
377-
},
378-
);
379-
380-
$this->assertCount(3, $events);
381-
382-
$this->assertSame('getMore', $events[0]['started']->getCommandName());
383-
$this->assertArrayHasKey('failed', $events[0]);
384-
385-
$this->assertSame('aggregate', $events[1]['started']->getCommandName());
386-
$this->assertStartAtOperationTime($operationTime, $events[1]['started']->getCommand());
387-
$this->assertArrayHasKey('succeeded', $events[1]);
388-
389-
// Original cursor is freed immediately after the change stream resumes
390-
$this->assertSame('killCursors', $events[2]['started']->getCommandName());
391-
$this->assertArrayHasKey('succeeded', $events[2]);
392-
393-
$this->assertFalse($changeStream->valid());
394-
}
395-
396-
private function assertStartAtOperationTime(TimestampInterface $expectedOperationTime, stdClass $command): void
397-
{
398-
$this->assertObjectHasProperty('pipeline', $command);
399-
$this->assertIsArray($command->pipeline);
400-
$this->assertArrayHasKey(0, $command->pipeline);
401-
$this->assertObjectHasProperty('$changeStream', $command->pipeline[0]);
402-
$this->assertObjectHasProperty('startAtOperationTime', $command->pipeline[0]->{'$changeStream'});
403-
$this->assertEquals($expectedOperationTime, $command->pipeline[0]->{'$changeStream'}->startAtOperationTime);
404-
}
405-
406290
public function testRewindMultipleTimesWithResults(): void
407291
{
408292
$this->skipIfIsShardedCluster('Cursor needs to be advanced multiple times and can\'t be rewound afterwards.');
@@ -1319,8 +1203,6 @@ function (array $aggregateCommand) {
13191203
*/
13201204
public function testErrorDuringAggregateCommandDoesNotCauseResume(): void
13211205
{
1322-
$this->skipIfServerVersion('<', '4.0.0', 'failCommand is not supported');
1323-
13241206
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
13251207

13261208
$commandCount = 0;
@@ -1382,39 +1264,6 @@ public function testOriginalReadPreferenceIsPreservedOnResume(): void
13821264
self::assertTrue($cursor->getServer()->isSecondary());
13831265
}
13841266

1385-
/**
1386-
* Prose test 12
1387-
* For a ChangeStream under these conditions:
1388-
* - Running against a server <4.0.7.
1389-
* - The batch is empty or has been iterated to the last document.
1390-
* Expected result:
1391-
* - getResumeToken must return the _id of the last document returned if one exists.
1392-
* - getResumeToken must return resumeAfter from the initial aggregate if the option was specified.
1393-
* - If resumeAfter was not specified, the getResumeToken result must be empty.
1394-
*/
1395-
public function testGetResumeTokenReturnsOriginalResumeTokenOnEmptyBatch(): void
1396-
{
1397-
$this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken is supported');
1398-
1399-
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions);
1400-
$changeStream = $operation->execute($this->getPrimaryServer());
1401-
1402-
$this->assertNull($changeStream->getResumeToken());
1403-
1404-
$this->insertDocument(['x' => 1]);
1405-
1406-
$changeStream->next();
1407-
$this->assertTrue($changeStream->valid());
1408-
$resumeToken = $changeStream->getResumeToken();
1409-
$this->assertSame($resumeToken, $changeStream->current()->_id);
1410-
1411-
$options = ['resumeAfter' => $resumeToken] + $this->defaultOptions;
1412-
$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $options);
1413-
$changeStream = $operation->execute($this->getPrimaryServer());
1414-
1415-
$this->assertSame($resumeToken, $changeStream->getResumeToken());
1416-
}
1417-
14181267
/**
14191268
* Prose test 14
14201269
* For a ChangeStream under these conditions:
@@ -1429,7 +1278,6 @@ public function testGetResumeTokenReturnsOriginalResumeTokenOnEmptyBatch(): void
14291278
#[DataProvider('provideCodecOptions')]
14301279
public function testResumeTokenBehaviour(array $options, Closure $getIdentifier): void
14311280
{
1432-
$this->skipIfServerVersion('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1');
14331281
$this->skipIfIsShardedCluster('Resume token behaviour can\'t be reliably tested on sharded clusters.');
14341282

14351283
$operation = new Watch(

0 commit comments

Comments
 (0)