-
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-5844): add iscryptd to ServerDescription
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 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
37 changes: 37 additions & 0 deletions
37
test/integration/server-discovery-and-monitoring/server_description.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { type ChildProcess, spawn } from 'node:child_process'; | ||
|
||
import { expect } from 'chai'; | ||
|
||
import { MongoClient } from '../../mongodb'; | ||
|
||
describe('ServerDescription xxx', function () { | ||
let client: MongoClient; | ||
const mongocryptdTestPort = '27022'; | ||
let childProcess: ChildProcess; | ||
|
||
beforeEach(async () => { | ||
childProcess = spawn('mongocryptd', ['--port', mongocryptdTestPort, '--ipv6'], { | ||
stdio: 'ignore', | ||
detached: true | ||
}); | ||
|
||
childProcess.on('error', err => { | ||
console.warn('Sessions prose mongocryptd error:', err); | ||
}); | ||
client = new MongoClient(`mongodb://localhost:${mongocryptdTestPort}`); | ||
}); | ||
|
||
afterEach(async () => { | ||
await client?.close(); | ||
childProcess.kill('SIGKILL'); | ||
}); | ||
|
||
it('iscryptd is set to true when connecting to mongocryptd', async function () { | ||
const descriptions = []; | ||
client.on('serverDescriptionChanged', description => descriptions.push(description)); | ||
const hello = await client.db().command({ hello: true }); | ||
expect(hello).to.have.property('iscryptd', true); // sanity check | ||
expect(hello).to.not.have.property('logicalSessionTimeoutMinutes'); | ||
expect(descriptions.at(-1)).to.have.nested.property('newDescription.iscryptd', true); | ||
}); | ||
}); |