Skip to content

Commit aa90bdc

Browse files
committed
test: update tests to require Linux OS for client.close() interruptions
1 parent 4394e11 commit aa90bdc

File tree

1 file changed

+51
-39
lines changed

1 file changed

+51
-39
lines changed

test/integration/node-specific/client_close.test.ts

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,32 @@ describe('MongoClient.close() Integration', () => {
1010

1111
describe('Node.js resource: TLS File read', () => {
1212
describe('when client is connecting and reads an infinite TLS file', () => {
13-
it('the file read is interrupted by client.close()', async function () {
14-
await runScriptAndGetProcessInfo(
15-
'tls-file-read',
16-
this.configuration,
17-
async function run({ mongodb: { MongoClient, MongoClientClosedError }, uri, expect }) {
18-
const infiniteFile = '/dev/zero';
19-
const client = new MongoClient(uri, { tls: true, tlsCertificateKeyFile: infiniteFile });
20-
const connectPromise = client.connect().then(
21-
() => null,
22-
e => e
23-
);
24-
expect(process.getActiveResourcesInfo()).to.include('FSReqPromise');
25-
await client.close();
26-
const err = await connectPromise;
27-
expect(err).to.be.instanceOf(MongoClientClosedError);
28-
expect(process.getActiveResourcesInfo()).to.not.include('FSReqPromise');
29-
}
30-
);
31-
});
13+
it(
14+
'the file read is interrupted by client.close()',
15+
{ requires: { os: 'linux' } },
16+
async function () {
17+
await runScriptAndGetProcessInfo(
18+
'tls-file-read',
19+
this.configuration,
20+
async function run({ mongodb: { MongoClient, MongoClientClosedError }, uri, expect }) {
21+
const infiniteFile = '/dev/zero';
22+
const client = new MongoClient(uri, {
23+
tls: true,
24+
tlsCertificateKeyFile: infiniteFile
25+
});
26+
const connectPromise = client.connect().then(
27+
() => null,
28+
e => e
29+
);
30+
expect(process.getActiveResourcesInfo()).to.include('FSReqPromise');
31+
await client.close();
32+
const err = await connectPromise;
33+
expect(err).to.be.instanceOf(MongoClientClosedError);
34+
expect(process.getActiveResourcesInfo()).to.not.include('FSReqPromise');
35+
}
36+
);
37+
}
38+
);
3239
});
3340
});
3441

@@ -49,26 +56,30 @@ describe('MongoClient.close() Integration', () => {
4956
});
5057

5158
describe('when MongoClientAuthProviders is instantiated and token file read hangs', () => {
52-
it('the file read is interrupted by client.close()', async function () {
53-
await runScriptAndGetProcessInfo(
54-
'token-file-read',
55-
this.configuration,
56-
async function run({ MongoClient, uri, expect }) {
57-
const infiniteFile = '/dev/zero';
58-
process.env.OIDC_TOKEN_FILE = infiniteFile;
59-
const options = {
60-
authMechanismProperties: { ENVIRONMENT: 'test' },
61-
authMechanism: 'MONGODB-OIDC'
62-
} as const;
63-
const client = new MongoClient(uri, options);
64-
const connectPromise = client.connect();
65-
expect(process.getActiveResourcesInfo()).to.include('FSReqPromise');
66-
await client.close();
67-
expect(process.getActiveResourcesInfo()).to.not.include('FSReqPromise');
68-
await connectPromise;
69-
}
70-
);
71-
});
59+
it(
60+
'the file read is interrupted by client.close()',
61+
{ requires: { os: 'linux' } },
62+
async function () {
63+
await runScriptAndGetProcessInfo(
64+
'token-file-read',
65+
this.configuration,
66+
async function run({ MongoClient, uri, expect }) {
67+
const infiniteFile = '/dev/zero';
68+
process.env.OIDC_TOKEN_FILE = infiniteFile;
69+
const options = {
70+
authMechanismProperties: { ENVIRONMENT: 'test' },
71+
authMechanism: 'MONGODB-OIDC'
72+
} as const;
73+
const client = new MongoClient(uri, options);
74+
const connectPromise = client.connect();
75+
expect(process.getActiveResourcesInfo()).to.include('FSReqPromise');
76+
await client.close();
77+
expect(process.getActiveResourcesInfo()).to.not.include('FSReqPromise');
78+
await connectPromise;
79+
}
80+
);
81+
}
82+
);
7283
});
7384
});
7485
});
@@ -583,6 +594,7 @@ describe('MongoClient.close() Integration', () => {
583594
describe('AutoEncrypter', () => {
584595
const metadata: MongoDBMetadataUI = {
585596
requires: {
597+
os: 'linux',
586598
mongodb: '>=4.2.0',
587599
clientSideEncryption: true
588600
}

0 commit comments

Comments
 (0)