From 286e8ef22765042f004664d4c24f8740a0be2c24 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 10:47:39 -0700 Subject: [PATCH 1/8] test(NODE-7561): Skip QE "prefixPreview" and "suffixPreview" tests on server 9.0.0+ Co-authored-by: Copilot --- ...e_encryption.prose.27.text_queries.test.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts index 1159b3360d3..36d59ec8304 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts @@ -14,6 +14,15 @@ const metadata: MongoDBMetadataUI = { libmongocrypt: '>=1.15.1' } }; +// # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416 +const metadataWithoutPreview: MongoDBMetadataUI = { + requires: { + clientSideEncryption: '>=6.4.0', + mongodb: '>=8.2.0 <9.0.0', + topology: '!single', + libmongocrypt: '>=1.15.1' + } +}; const loadFLEDataFile = async (filename: string) => EJSON.parse( @@ -36,6 +45,7 @@ describe('27. Text Explicit Encryption', function () { // Using QE CreateCollection() and Collection.Drop(), drop and create the following collections with majority write concern: // - db.prefix-suffix using the encryptedFields option set to the contents of encryptedFields-prefix-suffix.json + // Skip this step if testing server 9.0.0+. // - db.substring using the encryptedFields option set to the contents of encryptedFields-substring.json async function dropAndCreateCollection(ns: string, encryptedFields?: Document) { const { db, collection } = MongoDBCollectionNamespace.fromString(ns); @@ -208,7 +218,7 @@ describe('27. Text Explicit Encryption', function () { await Promise.allSettled([utilClient.close(), encryptedClient.close(), keyVaultClient.close()]); }); - it('Case 1: can find a document by prefix', metadata, async function () { + it('Case 1: can find a document by prefix', metadataWithoutPreview, async function () { // Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -260,7 +270,7 @@ describe('27. Text Explicit Encryption', function () { expect(result).to.deep.equal({ _id: 0, encryptedText: 'foobarbaz' }); }); - it('Case 2: can find a document by suffix', metadata, async function () { + it('Case 2: can find a document by suffix', metadataWithoutPreview, async function () { // Use clientEncryption.encrypt() to encrypt the string "baz" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -311,7 +321,7 @@ describe('27. Text Explicit Encryption', function () { expect(result).to.deep.equal({ _id: 0, encryptedText: 'foobarbaz' }); }); - it('Case 3: assert no document found by prefix', metadata, async function () { + it('Case 3: assert no document found by prefix', metadataWithoutPreview, async function () { // Use clientEncryption.encrypt() to encrypt the string "baz" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -351,7 +361,7 @@ describe('27. Text Explicit Encryption', function () { expect(await encryptedClient.db('db').collection('prefix-suffix').findOne(filter)).to.be.null; }); - it('Case 4: assert no document found by suffix', metadata, async function () { + it('Case 4: assert no document found by suffix', metadataWithoutPreview, async function () { // Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -497,7 +507,7 @@ describe('27. Text Explicit Encryption', function () { expect(result).to.be.null; }); - it('Case 7: assert contentionFactor is required', metadata, async function () { + it('Case 7: assert contentionFactor is required', metadataWithoutPreview, async function () { // Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts: // class EncryptOpts { // keyId : , From 2e65a50031d8f93a540aa53472c19cc85656c17c Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 11:10:53 -0700 Subject: [PATCH 2/8] added comments to match source --- .../client_side_encryption.prose.27.text_queries.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts index 36d59ec8304..df590ace814 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts @@ -219,6 +219,7 @@ describe('27. Text Explicit Encryption', function () { }); it('Case 1: can find a document by prefix', metadataWithoutPreview, async function () { + // Skip this test case if testing MongoDB server 9.0.0+. // Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -271,6 +272,7 @@ describe('27. Text Explicit Encryption', function () { }); it('Case 2: can find a document by suffix', metadataWithoutPreview, async function () { + // Skip this test case if testing MongoDB server 9.0.0+. // Use clientEncryption.encrypt() to encrypt the string "baz" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -322,6 +324,7 @@ describe('27. Text Explicit Encryption', function () { }); it('Case 3: assert no document found by prefix', metadataWithoutPreview, async function () { + // Skip this test case if testing MongoDB server 9.0.0+. // Use clientEncryption.encrypt() to encrypt the string "baz" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -362,6 +365,7 @@ describe('27. Text Explicit Encryption', function () { }); it('Case 4: assert no document found by suffix', metadataWithoutPreview, async function () { + // Skip this test case if testing MongoDB server 9.0.0+. // Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts: // class EncryptOpts { // keyId : , @@ -508,6 +512,7 @@ describe('27. Text Explicit Encryption', function () { }); it('Case 7: assert contentionFactor is required', metadataWithoutPreview, async function () { + // Skip this test case if testing MongoDB server 9.0.0+. // Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts: // class EncryptOpts { // keyId : , From 5b84994ff472161947c6efd07761f685565143b2 Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 11:11:12 -0700 Subject: [PATCH 3/8] updated unified json/yml files --- .../tests/unified/QE-Text-cleanupStructuredEncryptionData.json | 1 + .../tests/unified/QE-Text-cleanupStructuredEncryptionData.yml | 1 + .../tests/unified/QE-Text-compactStructuredEncryptionData.json | 1 + .../tests/unified/QE-Text-compactStructuredEncryptionData.yml | 1 + .../tests/unified/QE-Text-prefixPreview.json | 1 + .../tests/unified/QE-Text-prefixPreview.yml | 1 + .../tests/unified/QE-Text-substringPreview.json | 2 +- .../tests/unified/QE-Text-substringPreview.yml | 2 +- .../tests/unified/QE-Text-suffixPreview.json | 1 + .../tests/unified/QE-Text-suffixPreview.yml | 1 + 10 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.json b/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.json index 24f33ab3ecb..fd74573ea26 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.json +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.json @@ -4,6 +4,7 @@ "runOnRequirements": [ { "minServerVersion": "8.2.0", + "maxServerVersion": "8.99.99", "topologies": [ "replicaset", "sharded", diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.yml b/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.yml index a326cca63db..8d8979bd234 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.yml +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.yml @@ -2,6 +2,7 @@ description: QE-Text-cleanupStructuredEncryptionData schemaVersion: "1.25" runOnRequirements: - minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries. + maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416 topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone. csfle: minLibmongocryptVersion: 1.15.0 # For SPM-4158. diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.json b/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.json index c7abfe2d4bc..a89ab96fc4c 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.json +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.json @@ -4,6 +4,7 @@ "runOnRequirements": [ { "minServerVersion": "8.2.0", + "maxServerVersion": "8.99.99", "topologies": [ "replicaset", "sharded", diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.yml b/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.yml index 994e6209eab..d608cd038f8 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.yml +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.yml @@ -2,6 +2,7 @@ description: QE-Text-compactStructuredEncryptionData schemaVersion: "1.25" runOnRequirements: - minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries. + maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416 topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone. csfle: minLibmongocryptVersion: 1.15.0 # For SPM-4158. diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.json b/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.json index 7279385743f..c193608e887 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.json +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.json @@ -4,6 +4,7 @@ "runOnRequirements": [ { "minServerVersion": "8.2.0", + "maxServerVersion": "8.99.99", "topologies": [ "replicaset", "sharded", diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.yml b/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.yml index 6f228e2d708..aca60fdabf2 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.yml +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.yml @@ -2,6 +2,7 @@ description: QE-Text-prefixPreview schemaVersion: "1.25" runOnRequirements: - minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries. + maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416 topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone. csfle: minLibmongocryptVersion: 1.15.0 # For SPM-4158. diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.json b/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.json index 6a8f133eac5..7787194fc65 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.json +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.json @@ -126,7 +126,7 @@ ], "tests": [ { - "description": "Insert QE suffixPreview", + "description": "Insert QE substringPreview", "operations": [ { "name": "insertOne", diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.yml b/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.yml index cee6a9f7ca4..a58a77743ee 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.yml +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.yml @@ -74,7 +74,7 @@ initialData: ], } tests: - - description: "Insert QE suffixPreview" + - description: "Insert QE substringPreview" operations: - name: insertOne arguments: diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.json b/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.json index deec5e63b07..2de5cde4a4b 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.json +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.json @@ -4,6 +4,7 @@ "runOnRequirements": [ { "minServerVersion": "8.2.0", + "maxServerVersion": "8.99.99", "topologies": [ "replicaset", "sharded", diff --git a/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.yml b/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.yml index 9a6925a2a1c..e2ddd9f0d41 100644 --- a/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.yml +++ b/test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.yml @@ -2,6 +2,7 @@ description: QE-Text-suffixPreview schemaVersion: "1.25" runOnRequirements: - minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries. + maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416 topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone. csfle: minLibmongocryptVersion: 1.15.0 # For SPM-4158. From abd126dcc130f43a11e54475e116041584a4998f Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 11:46:30 -0700 Subject: [PATCH 4/8] skip setup in some cases --- ...t_side_encryption.prose.27.text_queries.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts index df590ace814..8b678b317a5 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts @@ -42,6 +42,8 @@ describe('27. Text Explicit Encryption', function () { beforeEach(async function () { utilClient = this.configuration.newClient(); + const isServer9OrAbove = this.configuration.version >= '9.0.0'; + const shouldRunPrefixSuffixTests = !isServer9OrAbove; // Using QE CreateCollection() and Collection.Drop(), drop and create the following collections with majority write concern: // - db.prefix-suffix using the encryptedFields option set to the contents of encryptedFields-prefix-suffix.json @@ -59,10 +61,12 @@ describe('27. Text Explicit Encryption', function () { }); } - await dropAndCreateCollection( - 'db.prefix-suffix', - await loadFLEDataFile('encryptedFields-prefix-suffix.json') - ); + if (shouldRunPrefixSuffixTests) { + await dropAndCreateCollection( + 'db.prefix-suffix', + await loadFLEDataFile('encryptedFields-prefix-suffix.json') + ); + } await dropAndCreateCollection( 'db.substring', await loadFLEDataFile('encryptedFields-substring.json') @@ -154,6 +158,7 @@ describe('27. Text Explicit Encryption', function () { } }); + if (shouldRunPrefixSuffixTests) { // Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern: // { "_id": 0, "encryptedText": } await encryptedClient @@ -166,6 +171,7 @@ describe('27. Text Explicit Encryption', function () { }, { writeConcern: { w: 'majority' } } ); + } } { From 48671d09c3aec7dbf3162108f1795ddcd6d132db Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 12:11:06 -0700 Subject: [PATCH 5/8] lint --- ...e_encryption.prose.27.text_queries.test.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts index 8b678b317a5..47ed4bf214f 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts @@ -159,18 +159,18 @@ describe('27. Text Explicit Encryption', function () { }); if (shouldRunPrefixSuffixTests) { - // Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern: - // { "_id": 0, "encryptedText": } - await encryptedClient - .db('db') - .collection<{ _id: number; encryptedText: Binary }>('prefix-suffix') - .insertOne( - { - _id: 0, - encryptedText - }, - { writeConcern: { w: 'majority' } } - ); + // Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern: + // { "_id": 0, "encryptedText": } + await encryptedClient + .db('db') + .collection<{ _id: number; encryptedText: Binary }>('prefix-suffix') + .insertOne( + { + _id: 0, + encryptedText + }, + { writeConcern: { w: 'majority' } } + ); } } From f7d4dd59e6dc08ce609a4f80b605c980fcf1048f Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 14:44:24 -0700 Subject: [PATCH 6/8] skip some tests against mdb 9 --- test/integration/change-streams/change_streams.spec.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/change-streams/change_streams.spec.test.ts b/test/integration/change-streams/change_streams.spec.test.ts index 451acc7a2dc..8e8b56ef878 100644 --- a/test/integration/change-streams/change_streams.spec.test.ts +++ b/test/integration/change-streams/change_streams.spec.test.ts @@ -3,6 +3,7 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -describe('Change Streams Spec - Unified', function () { +// TODO: NODE-7559 - remove the mongodb version requirement once the spec tests are updated to be compatible with MongoDB 9.0 +describe('Change Streams Spec - Unified', { requires: { mongodb: '<9.0.0' } }, function () { runUnifiedSuite(loadSpecTests(path.join('change-streams', 'unified'))); }); From d6d6570ad0d8cac0f44db424dc77297fd9d19cdd Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 17:24:49 -0700 Subject: [PATCH 7/8] really skip that test --- .../integration/change-streams/change_streams.spec.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/integration/change-streams/change_streams.spec.test.ts b/test/integration/change-streams/change_streams.spec.test.ts index 8e8b56ef878..faad6eabdf2 100644 --- a/test/integration/change-streams/change_streams.spec.test.ts +++ b/test/integration/change-streams/change_streams.spec.test.ts @@ -2,8 +2,11 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; +import { config } from 'chai'; // TODO: NODE-7559 - remove the mongodb version requirement once the spec tests are updated to be compatible with MongoDB 9.0 -describe('Change Streams Spec - Unified', { requires: { mongodb: '<9.0.0' } }, function () { - runUnifiedSuite(loadSpecTests(path.join('change-streams', 'unified'))); +describe('Change Streams Spec - Unified', function () { + it('should run, unless it should not', { requires: { mongodb: '<9.0' } }, function () { + runUnifiedSuite(loadSpecTests(path.join('change-streams', 'unified'))); + }); }); From 178b0dcebad85bba439fe081eff186db75279fca Mon Sep 17 00:00:00 2001 From: Pavel Safronov Date: Fri, 1 May 2026 18:45:43 -0700 Subject: [PATCH 8/8] lint --- test/integration/change-streams/change_streams.spec.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration/change-streams/change_streams.spec.test.ts b/test/integration/change-streams/change_streams.spec.test.ts index faad6eabdf2..9b08c5f2454 100644 --- a/test/integration/change-streams/change_streams.spec.test.ts +++ b/test/integration/change-streams/change_streams.spec.test.ts @@ -2,7 +2,6 @@ import * as path from 'path'; import { loadSpecTests } from '../../spec'; import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; -import { config } from 'chai'; // TODO: NODE-7559 - remove the mongodb version requirement once the spec tests are updated to be compatible with MongoDB 9.0 describe('Change Streams Spec - Unified', function () {