-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feat(NODE-5678): add options parsing support for timeoutMS and defaultTimeoutMS #4068
Merged
durran
merged 27 commits into
main
from
NODE-5678/add-options-parsing-support-for-timeoutMS-and-defaultTimeoutMS
Apr 10, 2024
Merged
Changes from 19 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
fb86c85
convert to typescript
W-A-James 042e9aa
small fixes
W-A-James 2ac89dc
add option parsing tests
W-A-James 0662269
add client tests
W-A-James cd562ca
add client and connection string support for defaultTimeoutMS
W-A-James 7923029
lint fix
W-A-James 07b57a0
Add support for timeoutMS and defaultTimeoutMS to db
W-A-James 4c8219e
Add support for timeoutMS and defaultTimeoutMS to collection
W-A-James e3a1548
Add support for timeoutMS and defaultTimeoutMS to gridfs
W-A-James 504eba7
Add support for timeoutMS and defaultTimeoutMS to operations
W-A-James dc1aaf4
Add support for timeoutMS and defaultTimeoutMS to sessions
W-A-James 7142a0d
pull in uri spec tests
W-A-James 75acc7b
support timeoutMS option on uri-spec-runner
W-A-James 524ccf9
remove defaultTimeoutMS option
W-A-James 51724db
fix option implementation
W-A-James eb37575
access timeoutMS optionally
W-A-James 37c8ae2
migrate file to typescript and add additional tests
W-A-James b860acc
add inheritance tests
W-A-James fec996c
remove field from options
W-A-James a7cff11
add error logich when timeoutMS is specified on explicit session and …
W-A-James d34ae2f
Add todo comments
W-A-James d8f97a2
add csot tests
W-A-James 11f26e1
revert duplicated tests
W-A-James 0d87b05
Merge branch 'main' into NODE-5678/add-options-parsing-support-for-ti…
W-A-James aa2a8bb
Apply suggestions from code review
W-A-James 5ef3ac1
move session check logic to executeOperation
W-A-James 8f23ae3
Merge branch 'main' into NODE-5678/add-options-parsing-support-for-ti…
durran 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 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 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 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 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 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 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 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 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
96 changes: 94 additions & 2 deletions
96
test/integration/client-side-operations-timeout/node_csot.test.ts
This file contains 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 |
---|---|---|
@@ -1,4 +1,96 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
/* Anything javascript specific relating to timeouts */ | ||
import { expect } from 'chai'; | ||
import * as sinon from 'sinon'; | ||
|
||
describe.skip('CSOT driver tests', () => {}); | ||
import { | ||
type ClientSession, | ||
type Collection, | ||
type Db, | ||
type FindCursor, | ||
type MongoClient | ||
} from '../../mongodb'; | ||
|
||
describe('CSOT driver tests', () => { | ||
afterEach(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
describe('timeoutMS inheritance', () => { | ||
let client: MongoClient; | ||
let db: Db; | ||
let coll: Collection; | ||
|
||
beforeEach(async function () { | ||
client = this.configuration.newClient(undefined, { timeoutMS: 100 }); | ||
db = client.db('test', { timeoutMS: 200 }); | ||
}); | ||
|
||
afterEach(async () => { | ||
if (client) await client.close(); | ||
}); | ||
W-A-James marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
describe('when timeoutMS is provided on an operation', () => { | ||
beforeEach(() => { | ||
coll = db.collection('test', { timeoutMS: 300 }); | ||
}); | ||
|
||
describe('when in a session', () => { | ||
let cursor: FindCursor; | ||
let session: ClientSession; | ||
|
||
beforeEach(() => { | ||
session = client.startSession({ defaultTimeoutMS: 400 }); | ||
cursor = coll.find({}, { session, timeoutMS: 500 }); | ||
}); | ||
|
||
afterEach(async () => { | ||
await cursor.close(); | ||
await session.endSession(); | ||
W-A-James marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}); | ||
|
||
it('overrides the value provided on the db and the session', async () => { | ||
expect(cursor.cursorOptions).to.have.property('timeoutMS', 500); | ||
}); | ||
}); | ||
|
||
describe('when not in a session', () => { | ||
let cursor: FindCursor; | ||
|
||
beforeEach(() => { | ||
db = client.db('test', { timeoutMS: 200 }); | ||
coll = db.collection('test', { timeoutMS: 300 }); | ||
cursor = coll.find({}, { timeoutMS: 400 }); | ||
}); | ||
|
||
afterEach(async () => { | ||
await cursor.close(); | ||
}); | ||
W-A-James marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
it('overrides the value provided on the db', async () => { | ||
expect(cursor.cursorOptions).to.have.property('timeoutMS', 400); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when timeoutMS is provided on a collection', () => { | ||
beforeEach(() => { | ||
db = client.db('test', { timeoutMS: 200 }); | ||
coll = db.collection('test', { timeoutMS: 300 }); | ||
}); | ||
|
||
it('overrides the value provided on the db', () => { | ||
expect(coll.s.options).to.have.property('timeoutMS', 300); | ||
}); | ||
|
||
describe('when timeoutMS is provided on a db', () => { | ||
beforeEach(() => { | ||
db = client.db('test', { timeoutMS: 200 }); | ||
}); | ||
|
||
it('overrides the value provided on the client', () => { | ||
expect(db.s.options).to.have.property('timeoutMS', 200); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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 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 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 |
---|---|---|
|
@@ -65,4 +65,3 @@ tests: | |
hosts: ~ | ||
auth: ~ | ||
options: {} | ||
|
This file contains 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 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 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.
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.
Applies to all operations, including cursor operations