From d70dcb88884c455ec49a2bc3d99ffa15c1331fc1 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Tue, 20 May 2025 09:22:04 +0200 Subject: [PATCH 1/2] Remove server version 4.0 from testing --- .evergreen/config/generate-config.php | 1 - .../config/generated/test-variant/lowest.yml | 2 +- .../test-variant/modern-php-full.yml | 64 +++++++++---------- .../config/generated/test-variant/phpc.yml | 16 ++--- .evergreen/config/generated/test/local.yml | 32 ---------- .../config/templates/test-variant/lowest.yml | 2 +- .../test-variant/modern-php-full.yml | 16 ++--- .../config/templates/test-variant/phpc.yml | 16 ++--- 8 files changed, 58 insertions(+), 91 deletions(-) diff --git a/.evergreen/config/generate-config.php b/.evergreen/config/generate-config.php index 1b455988e..c39a10829 100755 --- a/.evergreen/config/generate-config.php +++ b/.evergreen/config/generate-config.php @@ -22,7 +22,6 @@ '5.0', '4.4', '4.2', - '4.0', ]; // Server versions diff --git a/.evergreen/config/generated/test-variant/lowest.yml b/.evergreen/config/generated/test-variant/lowest.yml index ce3b5fc69..0e3b79709 100644 --- a/.evergreen/config/generated/test-variant/lowest.yml +++ b/.evergreen/config/generated/test-variant/lowest.yml @@ -13,4 +13,4 @@ buildvariants: - variant: "build-rhel80" name: "build-php-8.1-lowest" tasks: - - ".replicaset .local .4.0 !.csfle" + - ".replicaset .local .4.2 !.csfle" diff --git a/.evergreen/config/generated/test-variant/modern-php-full.yml b/.evergreen/config/generated/test-variant/modern-php-full.yml index 24c0a6f8d..5e8d34b0d 100644 --- a/.evergreen/config/generated/test-variant/modern-php-full.yml +++ b/.evergreen/config/generated/test-variant/modern-php-full.yml @@ -14,10 +14,10 @@ buildvariants: - variant: "build-debian12" name: "build-php-8.4" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -36,10 +36,10 @@ buildvariants: name: "build-php-8.4" tasks: # Remember to add new major versions here as they are released - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".standalone .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".sharded .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" # Test versions < 5.0 - name: test-rhel80-php-8.4 @@ -75,10 +75,10 @@ buildvariants: - variant: "build-debian12" name: "build-php-8.3" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -97,10 +97,10 @@ buildvariants: name: "build-php-8.3" tasks: # Remember to add new major versions here as they are released - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".standalone .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".sharded .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" # Test versions < 5.0 - name: test-rhel80-php-8.3 @@ -136,10 +136,10 @@ buildvariants: - variant: "build-debian12" name: "build-php-8.2" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -158,10 +158,10 @@ buildvariants: name: "build-php-8.2" tasks: # Remember to add new major versions here as they are released - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".standalone .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".sharded .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" # Test versions < 5.0 - name: test-rhel80-php-8.2 @@ -197,10 +197,10 @@ buildvariants: - variant: "build-debian12" name: "build-php-8.1" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -219,10 +219,10 @@ buildvariants: name: "build-php-8.1" tasks: # Remember to add new major versions here as they are released - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".standalone .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".sharded .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" # Test versions < 5.0 - name: test-rhel80-php-8.1 diff --git a/.evergreen/config/generated/test-variant/phpc.yml b/.evergreen/config/generated/test-variant/phpc.yml index 4e6db6325..df1ebb2d2 100644 --- a/.evergreen/config/generated/test-variant/phpc.yml +++ b/.evergreen/config/generated/test-variant/phpc.yml @@ -13,10 +13,10 @@ buildvariants: - variant: "build-debian12" name: "build-php-8.4-next-stable" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -33,10 +33,10 @@ buildvariants: - variant: "build-debian12" name: "build-php-8.4-next-minor" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" diff --git a/.evergreen/config/generated/test/local.yml b/.evergreen/config/generated/test/local.yml index 87592e4ac..cee192412 100644 --- a/.evergreen/config/generated/test/local.yml +++ b/.evergreen/config/generated/test/local.yml @@ -256,35 +256,3 @@ tasks: - func: "start kms servers" - func: "set aws temp creds" - func: "run tests" - - name: "test-mongodb-4.0-standalone-noauth-nossl" - tags: ["standalone", "local", "4.0", "tag"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - TOPOLOGY: "server" - MONGODB_VERSION: "4.0" - - func: "start kms servers" - - func: "set aws temp creds" - - func: "run tests" - - - name: "test-mongodb-4.0-replicaset-noauth-nossl" - tags: ["replicaset", "local", "4.0", "pr", "tag"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - TOPOLOGY: "replica_set" - MONGODB_VERSION: "4.0" - - func: "start kms servers" - - func: "set aws temp creds" - - func: "run tests" - - - name: "test-mongodb-4.0-sharded-noauth-nossl" - tags: ["sharded", "local", "4.0", "tag"] - commands: - - func: "bootstrap mongo-orchestration" - vars: - TOPOLOGY: "sharded_cluster" - MONGODB_VERSION: "4.0" - - func: "start kms servers" - - func: "set aws temp creds" - - func: "run tests" diff --git a/.evergreen/config/templates/test-variant/lowest.yml b/.evergreen/config/templates/test-variant/lowest.yml index ff416a287..0959127fd 100644 --- a/.evergreen/config/templates/test-variant/lowest.yml +++ b/.evergreen/config/templates/test-variant/lowest.yml @@ -11,4 +11,4 @@ - variant: "build-rhel80" name: "build-php-%phpVersion%-lowest" tasks: - - ".replicaset .local .4.0 !.csfle" + - ".replicaset .local .4.2 !.csfle" diff --git a/.evergreen/config/templates/test-variant/modern-php-full.yml b/.evergreen/config/templates/test-variant/modern-php-full.yml index 21468390d..449e952b8 100644 --- a/.evergreen/config/templates/test-variant/modern-php-full.yml +++ b/.evergreen/config/templates/test-variant/modern-php-full.yml @@ -12,10 +12,10 @@ - variant: "build-debian12" name: "build-php-%phpVersion%" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -34,10 +34,10 @@ name: "build-php-%phpVersion%" tasks: # Remember to add new major versions here as they are released - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".standalone .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".sharded .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.7.0 !.8.0 !.rapid !.latest" # Test versions < 5.0 - name: test-rhel80-php-%phpVersion% diff --git a/.evergreen/config/templates/test-variant/phpc.yml b/.evergreen/config/templates/test-variant/phpc.yml index 88d0dd248..4bb6e3914 100644 --- a/.evergreen/config/templates/test-variant/phpc.yml +++ b/.evergreen/config/templates/test-variant/phpc.yml @@ -11,10 +11,10 @@ - variant: "build-debian12" name: "build-php-%phpVersion%-next-stable" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" @@ -31,10 +31,10 @@ - variant: "build-debian12" name: "build-php-%phpVersion%-next-minor" tasks: - - ".standalone .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".replicaset .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".sharded .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" - - ".loadbalanced .local !.csfle !.4.0 !.4.2 !.4.4 !.5.0 !.6.0" + - ".standalone .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".replicaset .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".sharded .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" + - ".loadbalanced .local !.csfle !.4.2 !.4.4 !.5.0 !.6.0" - "test_serverless_task_group" - "test_serverless_proxy_task_group" - "test-atlas-data-lake" From 726cba91e462f4c0f8d9534e0585bbf69e8e1b7b Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Tue, 20 May 2025 09:32:06 +0200 Subject: [PATCH 2/2] Remove obsolete skips and tests for MongoDB 4.0 --- tests/FunctionalTestCase.php | 24 +--- tests/Operation/ExplainFunctionalTest.php | 2 - tests/Operation/WatchFunctionalTest.php | 152 ---------------------- 3 files changed, 1 insertion(+), 177 deletions(-) diff --git a/tests/FunctionalTestCase.php b/tests/FunctionalTestCase.php index 05c9c1765..f8a179bc5 100644 --- a/tests/FunctionalTestCase.php +++ b/tests/FunctionalTestCase.php @@ -215,10 +215,6 @@ protected function assertSameObjectId($expectedObjectId, $actualObjectId): void */ public function configureFailPoint(array|stdClass $command, ?Server $server = null): void { - if (! $this->isFailCommandSupported()) { - $this->markTestSkipped('failCommand is only supported on mongod >= 4.0.0 and mongos >= 4.1.5.'); - } - if (! $this->isFailCommandEnabled()) { $this->markTestSkipped('The enableTestCommands parameter is not enabled.'); } @@ -512,15 +508,7 @@ protected function skipIfTransactionsAreNotSupported(): void } if ($this->isShardedCluster()) { - if (version_compare($this->getFeatureCompatibilityVersion(), '4.2', '<')) { - $this->markTestSkipped('Transactions are only supported on FCV 4.2 or higher'); - } - - return; - } - - if (version_compare($this->getFeatureCompatibilityVersion(), '4.0', '<')) { - $this->markTestSkipped('Transactions are only supported on FCV 4.0 or higher'); + $this->markTestSkipped('Transactions are only supported on FCV 4.2 or higher'); } if ($this->getServerStorageEngine() !== 'wiredTiger') { @@ -698,16 +686,6 @@ private static function getUriWithoutMultipleMongoses(): string return $uri; } - /** - * Checks if the failCommand command is supported on this server version - */ - private function isFailCommandSupported(): bool - { - $minVersion = $this->isShardedCluster() ? '4.1.5' : '4.0.0'; - - return version_compare($this->getServerVersion(), $minVersion, '>='); - } - /** * Checks if the failCommand command is enabled by checking the enableTestCommands parameter */ diff --git a/tests/Operation/ExplainFunctionalTest.php b/tests/Operation/ExplainFunctionalTest.php index 4c5949828..a4ec42f44 100644 --- a/tests/Operation/ExplainFunctionalTest.php +++ b/tests/Operation/ExplainFunctionalTest.php @@ -307,8 +307,6 @@ public function testUpdateOne($verbosity, $executionStatsExpected, $allPlansExec public function testAggregate(): void { - $this->skipIfServerVersion('<', '4.0.0', 'Explaining aggregate command requires server version >= 4.0'); - $this->createFixtures(3); // Use a $sort stage to ensure the aggregate does not get optimised to a query diff --git a/tests/Operation/WatchFunctionalTest.php b/tests/Operation/WatchFunctionalTest.php index 76a697058..522b01ba4 100644 --- a/tests/Operation/WatchFunctionalTest.php +++ b/tests/Operation/WatchFunctionalTest.php @@ -6,7 +6,6 @@ use Generator; use Iterator; use MongoDB\BSON\Document; -use MongoDB\BSON\TimestampInterface; use MongoDB\ChangeStream; use MongoDB\Codec\DecodeIfSupported; use MongoDB\Codec\DocumentCodec; @@ -106,44 +105,6 @@ public function encode($value): Document ]; } - /** - * Prose test 1: "ChangeStream must continuously track the last seen - * resumeToken" - */ - #[DataProvider('provideCodecOptions')] - public function testGetResumeToken(array $options, Closure $getIdentifier): void - { - $this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken is supported'); - - $operation = new Watch( - $this->manager, - $this->getDatabaseName(), - $this->getCollectionName(), - [], - $options + $this->defaultOptions, - ); - $changeStream = $operation->execute($this->getPrimaryServer()); - - $changeStream->rewind(); - $this->assertFalse($changeStream->valid()); - $this->assertNull($changeStream->getResumeToken()); - - $this->insertDocument(['x' => 1]); - $this->insertDocument(['x' => 2]); - - $this->advanceCursorUntilValid($changeStream); - $this->assertSameDocument($getIdentifier($changeStream->current()), $changeStream->getResumeToken()); - - $changeStream->next(); - $this->assertTrue($changeStream->valid()); - $this->assertSameDocument($getIdentifier($changeStream->current()), $changeStream->getResumeToken()); - - $this->insertDocument(['x' => 3]); - - $this->advanceCursorUntilValid($changeStream); - $this->assertSameDocument($getIdentifier($changeStream->current()), $changeStream->getResumeToken()); - } - /** * Prose test 1: "ChangeStream must continuously track the last seen * resumeToken" @@ -165,8 +126,6 @@ public function testGetResumeToken(array $options, Closure $getIdentifier): void #[DataProvider('provideCodecOptions')] public function testGetResumeTokenWithPostBatchResumeToken(array $options, Closure $getIdentifier): void { - $this->skipIfServerVersion('<', '4.0.7', 'postBatchResumeToken is not supported'); - $operation = new Watch( $this->manager, $this->getDatabaseName(), @@ -267,8 +226,6 @@ function (array $event) use (&$commands): void { public function testResumeBeforeReceivingAnyResultsIncludesPostBatchResumeToken(): void { - $this->skipIfServerVersion('<', '4.0.7', 'postBatchResumeToken is not supported'); - $operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions); $events = []; @@ -330,79 +287,6 @@ private function assertResumeAfter($expectedResumeToken, stdClass $command): voi $this->assertEquals($expectedResumeToken, $command->pipeline[0]->{'$changeStream'}->resumeAfter); } - /** - * Prose test 9: "$changeStream stage for ChangeStream against a server - * >=4.0 and <4.0.7 that has not received any results yet MUST include a - * startAtOperationTime option when resuming a changestream." - */ - public function testResumeBeforeReceivingAnyResultsIncludesStartAtOperationTime(): void - { - $this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken takes precedence over startAtOperationTime'); - - $operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions); - - $events = []; - - (new CommandObserver())->observe( - function () use ($operation, &$changeStream): void { - $changeStream = $operation->execute($this->getPrimaryServer()); - }, - function (array $event) use (&$events): void { - $events[] = $event; - }, - ); - - $this->assertCount(1, $events); - $this->assertSame('aggregate', $events[0]['started']->getCommandName()); - $reply = $events[0]['succeeded']->getReply(); - $this->assertObjectHasProperty('operationTime', $reply); - $operationTime = $reply->operationTime; - $this->assertInstanceOf(TimestampInterface::class, $operationTime); - - $this->assertFalse($changeStream->valid()); - $this->forceChangeStreamResume(); - - $this->assertNoCommandExecuted(function () use ($changeStream): void { - $changeStream->rewind(); - }); - - $events = []; - - (new CommandObserver())->observe( - function () use ($changeStream): void { - $changeStream->next(); - }, - function (array $event) use (&$events): void { - $events[] = $event; - }, - ); - - $this->assertCount(3, $events); - - $this->assertSame('getMore', $events[0]['started']->getCommandName()); - $this->assertArrayHasKey('failed', $events[0]); - - $this->assertSame('aggregate', $events[1]['started']->getCommandName()); - $this->assertStartAtOperationTime($operationTime, $events[1]['started']->getCommand()); - $this->assertArrayHasKey('succeeded', $events[1]); - - // Original cursor is freed immediately after the change stream resumes - $this->assertSame('killCursors', $events[2]['started']->getCommandName()); - $this->assertArrayHasKey('succeeded', $events[2]); - - $this->assertFalse($changeStream->valid()); - } - - private function assertStartAtOperationTime(TimestampInterface $expectedOperationTime, stdClass $command): void - { - $this->assertObjectHasProperty('pipeline', $command); - $this->assertIsArray($command->pipeline); - $this->assertArrayHasKey(0, $command->pipeline); - $this->assertObjectHasProperty('$changeStream', $command->pipeline[0]); - $this->assertObjectHasProperty('startAtOperationTime', $command->pipeline[0]->{'$changeStream'}); - $this->assertEquals($expectedOperationTime, $command->pipeline[0]->{'$changeStream'}->startAtOperationTime); - } - public function testRewindMultipleTimesWithResults(): void { $this->skipIfIsShardedCluster('Cursor needs to be advanced multiple times and can\'t be rewound afterwards.'); @@ -1319,8 +1203,6 @@ function (array $aggregateCommand) { */ public function testErrorDuringAggregateCommandDoesNotCauseResume(): void { - $this->skipIfServerVersion('<', '4.0.0', 'failCommand is not supported'); - $operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions); $commandCount = 0; @@ -1382,39 +1264,6 @@ public function testOriginalReadPreferenceIsPreservedOnResume(): void self::assertTrue($cursor->getServer()->isSecondary()); } - /** - * Prose test 12 - * For a ChangeStream under these conditions: - * - Running against a server <4.0.7. - * - The batch is empty or has been iterated to the last document. - * Expected result: - * - getResumeToken must return the _id of the last document returned if one exists. - * - getResumeToken must return resumeAfter from the initial aggregate if the option was specified. - * - If resumeAfter was not specified, the getResumeToken result must be empty. - */ - public function testGetResumeTokenReturnsOriginalResumeTokenOnEmptyBatch(): void - { - $this->skipIfServerVersion('>=', '4.0.7', 'postBatchResumeToken is supported'); - - $operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $this->defaultOptions); - $changeStream = $operation->execute($this->getPrimaryServer()); - - $this->assertNull($changeStream->getResumeToken()); - - $this->insertDocument(['x' => 1]); - - $changeStream->next(); - $this->assertTrue($changeStream->valid()); - $resumeToken = $changeStream->getResumeToken(); - $this->assertSame($resumeToken, $changeStream->current()->_id); - - $options = ['resumeAfter' => $resumeToken] + $this->defaultOptions; - $operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], $options); - $changeStream = $operation->execute($this->getPrimaryServer()); - - $this->assertSame($resumeToken, $changeStream->getResumeToken()); - } - /** * Prose test 14 * For a ChangeStream under these conditions: @@ -1429,7 +1278,6 @@ public function testGetResumeTokenReturnsOriginalResumeTokenOnEmptyBatch(): void #[DataProvider('provideCodecOptions')] public function testResumeTokenBehaviour(array $options, Closure $getIdentifier): void { - $this->skipIfServerVersion('<', '4.1.1', 'Testing resumeAfter and startAfter can only be tested on servers >= 4.1.1'); $this->skipIfIsShardedCluster('Resume token behaviour can\'t be reliably tested on sharded clusters.'); $operation = new Watch(