-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(NODE-5678): add options parsing support for timeoutMS and defaul…
…tTimeoutMS (#4068) Co-authored-by: Durran Jordan <durran@gmail.com>
- Loading branch information
Showing
19 changed files
with
309 additions
and
49 deletions.
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
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
97 changes: 95 additions & 2 deletions
97
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,97 @@ | ||
/* 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 () => { | ||
await client?.close(); | ||
}); | ||
|
||
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(); | ||
await session.endSession(); | ||
}); | ||
|
||
it('throws an error', 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(); | ||
}); | ||
|
||
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.