-
Notifications
You must be signed in to change notification settings - Fork 1.8k
test(NODE-7561): Skip QE "prefixPreview" and "suffixPreview" tests on server 9.0.0+ #4934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PavelSafronov
wants to merge
14
commits into
main
Choose a base branch
from
node-7561-skip-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
286e8ef
test(NODE-7561): Skip QE "prefixPreview" and "suffixPreview" tests on…
PavelSafronov 2e65a50
added comments to match source
PavelSafronov 5b84994
updated unified json/yml files
PavelSafronov abd126d
skip setup in some cases
PavelSafronov 48671d0
lint
PavelSafronov f7d4dd5
skip some tests against mdb 9
PavelSafronov d6d6570
really skip that test
PavelSafronov 178b0dc
lint
PavelSafronov 06b6ce5
explicitly log the mdb version comparison
PavelSafronov eb1a16d
move the version check
PavelSafronov 8886a4a
lint
PavelSafronov 574dd90
use semver to test version fit
PavelSafronov 72a6c9c
pr feedback: remove unrelated changes
PavelSafronov 339dde7
Merge branch 'main' into node-7561-skip-tests
PavelSafronov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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( | ||
|
|
@@ -33,9 +42,12 @@ describe('27. Text Explicit Encryption', function () { | |
|
|
||
| beforeEach(async function () { | ||
| utilClient = this.configuration.newClient(); | ||
| const isServer9OrAbove = this.configuration.version >= '9.0.0'; | ||
| const shouldRunPrefixSuffixTests = !isServer9OrAbove; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated, using semver. |
||
|
|
||
| // 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); | ||
|
|
@@ -49,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') | ||
|
|
@@ -144,18 +158,20 @@ describe('27. Text Explicit Encryption', function () { | |
| } | ||
| }); | ||
|
|
||
| // Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern: | ||
| // { "_id": 0, "encryptedText": <encrypted 'foobarbaz'> } | ||
| await encryptedClient | ||
| .db('db') | ||
| .collection<{ _id: number; encryptedText: Binary }>('prefix-suffix') | ||
| .insertOne( | ||
| { | ||
| _id: 0, | ||
| encryptedText | ||
| }, | ||
| { writeConcern: { w: 'majority' } } | ||
| ); | ||
| if (shouldRunPrefixSuffixTests) { | ||
| // Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern: | ||
| // { "_id": 0, "encryptedText": <encrypted 'foobarbaz'> } | ||
| await encryptedClient | ||
| .db('db') | ||
| .collection<{ _id: number; encryptedText: Binary }>('prefix-suffix') | ||
| .insertOne( | ||
| { | ||
| _id: 0, | ||
| encryptedText | ||
| }, | ||
| { writeConcern: { w: 'majority' } } | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| { | ||
|
|
@@ -208,7 +224,8 @@ 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 () { | ||
| // 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 : <key1ID>, | ||
|
|
@@ -260,7 +277,8 @@ 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 () { | ||
| // 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 : <key1ID>, | ||
|
|
@@ -311,7 +329,8 @@ 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 () { | ||
| // 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 : <key1ID>, | ||
|
|
@@ -351,7 +370,8 @@ 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 () { | ||
| // 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 : <key1ID>, | ||
|
|
@@ -497,7 +517,8 @@ 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 () { | ||
| // 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 : <key1ID>, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one fundamental problem with this approach, caused by 2 independent causes:
describe(which is created byrunUnifiedSuite) is ignored when defined insideit(introduced by this change), so you can see on evergreen logs like this:Basically it means no tests are running. But then there a second problem I want to highlight: in our current configuration the matrix looks like:
Which means (with the constraints down below
mongodb: '>=8.2.0 <9.0.0')we don't run tests on 8.1, 8.2, etc. The only variant we catch - is rapid, just because it's 8.3 currently. In other words we do not run tests on latest stable release which is 8.2.7 at the moment.Can you please take a look into this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! PR updated, here are the new results:
The explanation is actually more complicated than MONGODB_VERSIONS.
(MONGODB_VERSIONS is only used to build the jobs.
rapidresults in the latest 8 version, whilelatestpulls in9.0.0-alpha..., I don't think it's related to this at all.)The last version was:
When MDB was < 9.0: Mocha runs the
itcallback,runUnifiedSuitetries to register test blocks during test execution, which Mocha silently drops. The outeritpasses with zero assertions, giving us a false green. The change stream spec tests never run.When MDB was >= 9.0: Mocha's
requirescheck filters out the outerit: same thing, tests don't run.New code:
When MDB < 9.0:
runUnifiedSuitecalled synchronously insidedescribe, so all nested/newcontext/itblocks register correctly during suite construction. Mocha then executes them normally.When MDB >= 9.0: same new blocks are registered, then as each
itexecutes, theskipFilterreturns a skip reason string, and Mocha marks that individual test as skipped due to NODE-7559.