Skip to content

Commit 83b5685

Browse files
requested changes: add in exitCode message, skip unimplemented tests, fix options
1 parent d9ed22a commit 83b5685

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

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

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable @typescript-eslint/no-empty-function */
2-
32
import { type TestConfiguration } from '../../tools/runner/config';
43
import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder';
54

@@ -20,12 +19,14 @@ describe.skip('MongoClient.close() Integration', () => {
2019
config,
2120
async function run({ MongoClient, uri, expect }) {
2221
const infiniteFile = '/dev/zero';
23-
const client = new MongoClient(uri, { tlsCertificateKeyFile: infiniteFile });
24-
client.connect();
22+
const client = new MongoClient(uri, { tls: true, tlsCertificateKeyFile: infiniteFile });
23+
const connectPromise = client.connect();
2524
expect(process.getActiveResourcesInfo()).to.include('FSReqPromise');
2625
await client.close();
2726
expect(process.getActiveResourcesInfo()).to.not.include('FSReqPromise');
28-
}
27+
const err = await connectPromise.catch(e => e);
28+
expect(err).to.exist;
29+
}
2930
);
3031
});
3132
});
@@ -74,7 +75,7 @@ describe.skip('MongoClient.close() Integration', () => {
7475
describe('Topology', () => {
7576
describe('Node.js resource: Server Selection Timer', () => {
7677
describe('after a Topology is created through client.connect()', () => {
77-
it('server selection timers are cleaned up by client.close()', async () => {});
78+
it.skip('server selection timers are cleaned up by client.close()', async () => {});
7879
});
7980
});
8081

@@ -90,25 +91,25 @@ describe.skip('MongoClient.close() Integration', () => {
9091
describe('MonitorInterval', () => {
9192
describe('Node.js resource: Timer', () => {
9293
describe('after a new monitor is made', () => {
93-
it('monitor interval timer is cleaned up by client.close()', async () => {});
94+
it.skip('monitor interval timer is cleaned up by client.close()', async () => {});
9495
});
9596

9697
describe('after a heartbeat fails', () => {
97-
it('the new monitor interval timer is cleaned up by client.close()', async () => {});
98+
it.skip('the new monitor interval timer is cleaned up by client.close()', async () => {});
9899
});
99100
});
100101
});
101102

102103
describe('Connection Monitoring', () => {
103104
describe('Node.js resource: Socket', () => {
104-
it('no sockets remain after client.close()', metadata, async function () {});
105+
it.skip('no sockets remain after client.close()', metadata, async function () {});
105106
});
106107
});
107108

108109
describe('RTT Pinger', () => {
109110
describe('Node.js resource: Timer', () => {
110111
describe('after entering monitor streaming mode ', () => {
111-
it('the rtt pinger timer is cleaned up by client.close()', async () => {
112+
it.skip('the rtt pinger timer is cleaned up by client.close()', async () => {
112113
// helloReply has a topologyVersion defined
113114
});
114115
});
@@ -117,7 +118,7 @@ describe.skip('MongoClient.close() Integration', () => {
117118
describe('Connection', () => {
118119
describe('Node.js resource: Socket', () => {
119120
describe('when rtt monitoring is turned on', () => {
120-
it('no sockets remain after client.close()', async () => {});
121+
it.skip('no sockets remain after client.close()', async () => {});
121122
});
122123
});
123124
});
@@ -127,25 +128,25 @@ describe.skip('MongoClient.close() Integration', () => {
127128
describe('ConnectionPool', () => {
128129
describe('Node.js resource: minPoolSize timer', () => {
129130
describe('after new connection pool is created', () => {
130-
it('the minPoolSize timer is cleaned up by client.close()', async () => {});
131+
it.skip('the minPoolSize timer is cleaned up by client.close()', async () => {});
131132
});
132133
});
133134

134135
describe('Node.js resource: checkOut Timer', () => {
135136
// waitQueueTimeoutMS
136137
describe('after new connection pool is created', () => {
137-
it('the wait queue timer is cleaned up by client.close()', async () => {});
138+
it.skip('the wait queue timer is cleaned up by client.close()', async () => {});
138139
});
139140
});
140141

141142
describe('Connection', () => {
142143
describe('Node.js resource: Socket', () => {
143144
describe('after a connection is checked out', () => {
144-
it('no sockets remain after client.close()', async () => {});
145+
it.skip('no sockets remain after client.close()', async () => {});
145146
});
146147

147148
describe('after a minPoolSize has been set on the ConnectionPool', () => {
148-
it('no sockets remain after client.close()', async () => {});
149+
it.skip('no sockets remain after client.close()', async () => {});
149150
});
150151
});
151152
});
@@ -155,7 +156,7 @@ describe.skip('MongoClient.close() Integration', () => {
155156
describe('SrvPoller', () => {
156157
describe('Node.js resource: Timer', () => {
157158
describe('after SRVPoller is created', () => {
158-
it('timers are cleaned up by client.close()', async () => {});
159+
it.skip('timers are cleaned up by client.close()', async () => {});
159160
});
160161
});
161162
});
@@ -164,27 +165,27 @@ describe.skip('MongoClient.close() Integration', () => {
164165
describe('ClientSession (Implicit)', () => {
165166
describe('Server resource: LSID/ServerSession', () => {
166167
describe('after a clientSession is implicitly created and used', () => {
167-
it('the server-side ServerSession is cleaned up by client.close()', async function () {});
168+
it.skip('the server-side ServerSession is cleaned up by client.close()', async function () {});
168169
});
169170
});
170171

171172
describe('Server resource: Transactions', () => {
172173
describe('after a clientSession is implicitly created and used', () => {
173-
it('the server-side transaction is cleaned up by client.close()', async function () {});
174+
it.skip('the server-side transaction is cleaned up by client.close()', async function () {});
174175
});
175176
});
176177
});
177178

178179
describe('ClientSession (Explicit)', () => {
179180
describe('Server resource: LSID/ServerSession', () => {
180181
describe('after a clientSession is created and used', () => {
181-
it('the server-side ServerSession is cleaned up by client.close()', async function () {});
182+
it.skip('the server-side ServerSession is cleaned up by client.close()', async function () {});
182183
});
183184
});
184185

185186
describe('Server resource: Transactions', () => {
186187
describe('after a clientSession is created and used', () => {
187-
it('the server-side transaction is cleaned up by client.close()', async function () {});
188+
it.skip('the server-side transaction is cleaned up by client.close()', async function () {});
188189
});
189190
});
190191
});
@@ -287,14 +288,14 @@ describe.skip('MongoClient.close() Integration', () => {
287288
});
288289

289290
describe('Node.js resource: Socket', () => {
290-
it('no sockets remain after client.close()', metadata, async () => {});
291+
it.skip('no sockets remain after client.close()', metadata, async () => {});
291292
});
292293
});
293294
});
294295

295296
describe('Server resource: Cursor', () => {
296297
describe('after cursors are created', () => {
297-
it('all active server-side cursors are closed by client.close()', async function () {});
298+
it.skip('all active server-side cursors are closed by client.close()', async function () {});
298299
});
299300
});
300301
});

test/integration/node-specific/resource_tracking_script_builder.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { on, once } from 'node:events';
33
import { readFile, unlink, writeFile } from 'node:fs/promises';
44
import * as path from 'node:path';
55

6-
import { expect } from 'chai';
6+
import { AssertionError, expect } from 'chai';
77
import { parseSnapshot } from 'v8-heapsnapshot';
88

99
import { type BSON, type ClientEncryption, type MongoClient } from '../../mongodb';
@@ -187,7 +187,11 @@ export async function runScriptAndGetProcessInfo(
187187
await unlink(logFile);
188188

189189
// assertions about exit status
190-
expect(exitCode, 'process should have exited with zero').to.equal(0);
190+
if (exitCode) {
191+
const assertionError = new AssertionError(messages.error.message);
192+
assertionError.stack = messages.error.stack + new Error().stack.slice('Error'.length);
193+
throw assertionError;
194+
}
191195

192196
// assertions about resource status
193197
expect(messages.beforeExitHappened).to.be.true;

test/tools/fixtures/process_resource_script.in.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ async function main() {
7878
main()
7979
.then(() => {})
8080
.catch(e => {
81-
log({ exitCode: 1, error: util.inspect(e) });
81+
log({ exitCode: 1, error: { message: e.message, stack: e.stack } });
8282
});
8383

8484
setTimeout(() => {
8585
// this means something was in the event loop such that it hung for more than 10 seconds
8686
// so we kill the process
87+
log({ newLibuvResources: getNewLibuvResourceArray() });
88+
log({ exitCode: 99, error: { message: 'Process timed out: resources remain in the event loop.' } });
8789
process.exit(99);
8890
// using `unref` will ensure this setTimeout call is not a resource / does not keep the event loop running
8991
}, 10000).unref();

0 commit comments

Comments
 (0)