-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-5207): deprecate unsupported runCommand options and add spec tests #3643
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
ebf9ccb
wip
nbbeeken ccc624c
test: runCommand
nbbeeken 6fcae13
test: update runOnReqs
nbbeeken 6417b5b
fix: db options
nbbeeken 0b6c680
minServerVersion
nbbeeken 80c8fdf
fix: test titles
nbbeeken 2e26e93
wip
nbbeeken 3ec381d
fix: sync tests
nbbeeken 0ddc187
fix: withTransaction should throw
nbbeeken b46fc83
refactor: improve runCommand operation runner
nbbeeken f9d5033
rm only
nbbeeken 7d841d0
feat: deprecate non spec runCommand options
nbbeeken 80d5c1a
docs: phrasing
nbbeeken 1cf3145
docs: sources of values
nbbeeken 306ca47
fix: move spread
nbbeeken 67f16b7
docs: transaction src
nbbeeken 6504b25
docs: comment clean up
nbbeeken 36a16f0
docs: options
nbbeeken 9162f09
docs: RP
nbbeeken 6bba224
test: err msg
nbbeeken 6ce1100
fix: tests
nbbeeken 77f76be
test: add freeze
nbbeeken 755a8e1
fix runCommand tests
nbbeeken cd5269a
test: fix
nbbeeken ef17124
fix: cp
nbbeeken 41aa7ed
update tests
nbbeeken 58a22ef
chore: sync title update
nbbeeken 3ce922d
Merge branch 'main' into NODE-5202-runCommand
dariakp 37b64b3
refactor: use new variable name
nbbeeken 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
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { loadSpecTests } from '../../spec'; | ||
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner'; | ||
|
||
describe('RunCommand spec', () => { | ||
runUnifiedSuite(loadSpecTests('run-command')); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { | ||
CommandStartedEvent, | ||
Db, | ||
MongoClient, | ||
ReadConcern, | ||
ReadPreference, | ||
WriteConcern | ||
} from '../../mongodb'; | ||
|
||
describe('RunCommand API', () => { | ||
let client: MongoClient; | ||
let db: Db; | ||
let commandsStarted: CommandStartedEvent[]; | ||
beforeEach(async function () { | ||
const options = { | ||
serverApi: { version: '1', strict: true, deprecationErrors: false }, | ||
monitorCommands: true | ||
}; | ||
client = this.configuration.newClient({}, options); | ||
db = client.db(); | ||
commandsStarted = []; | ||
client.on('commandStarted', started => commandsStarted.push(started)); | ||
}); | ||
|
||
afterEach(async function () { | ||
commandsStarted = []; | ||
await client.close(); | ||
}); | ||
|
||
it('does not modify user input', { requires: { mongodb: '>=5.0' } }, async () => { | ||
const command = Object.freeze({ ping: 1 }); | ||
// will throw if it tries to modify command | ||
await db.command(command, { readPreference: ReadPreference.nearest }); | ||
}); | ||
|
||
it('does not support writeConcern in options', { requires: { mongodb: '>=5.0' } }, async () => { | ||
const command = Object.freeze({ insert: 'test', documents: [{ x: 1 }] }); | ||
await db.command(command, { writeConcern: new WriteConcern('majority') }); | ||
expect(commandsStarted).to.not.have.nested.property('[0].command.writeConcern'); | ||
expect(command).to.not.have.property('writeConcern'); | ||
}); | ||
|
||
// TODO(NODE-4936): We do support readConcern in options, the spec forbids this | ||
it.skip( | ||
'does not support readConcern in options', | ||
{ requires: { mongodb: '>=5.0' } }, | ||
async () => { | ||
const command = Object.freeze({ find: 'test', filter: {} }); | ||
const res = await db.command(command, { readConcern: ReadConcern.MAJORITY }); | ||
expect(res).to.have.property('ok', 1); | ||
expect(commandsStarted).to.not.have.nested.property('[0].command.readConcern'); | ||
expect(command).to.not.have.property('readConcern'); | ||
} | ||
).skipReason = | ||
'TODO(NODE-4936): Enable this test when readConcern support has been removed from runCommand'; | ||
}); |
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.
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.
Although this leaves the supplied command untouched outside of the scope of this method can we assign it to a new const to avoid any potential confusion?
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.
sure, updated