Skip to content

Commit f4a4798

Browse files
committed
chore: filter on ns
1 parent 9722533 commit f4a4798

File tree

3 files changed

+7
-54
lines changed

3 files changed

+7
-54
lines changed

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

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
FindCursor,
1717
ListCollectionsCursor,
1818
type Log,
19-
Long,
2019
type MongoClient,
2120
MongoServerError,
2221
promiseWithResolvers,
@@ -53,11 +52,9 @@ describe('AbortSignal support', () => {
5352
let db: Db;
5453
let collection: Collection<{ a: number; ssn: string }>;
5554
const logs: Log[] = [];
56-
const cursors = [];
5755

5856
beforeEach(async function () {
5957
logs.length = 0;
60-
cursors.length = 0;
6158

6259
client = this.configuration.newClient(
6360
{},
@@ -73,37 +70,17 @@ describe('AbortSignal support', () => {
7370
await client.connect();
7471
db = client.db('abortSignal');
7572
collection = db.collection('support');
76-
77-
client.on('commandSucceeded', ev => {
78-
if (
79-
ev.commandName === 'find' ||
80-
ev.commandName === 'aggregate' ||
81-
ev.commandName === 'listCollections'
82-
) {
83-
const cursorId = Long.isLong(ev.reply.cursor.id)
84-
? ev.reply.cursor.id
85-
: Long.fromNumber(ev.reply.cursor.id);
86-
87-
if (!Long.ZERO.equals(cursorId)) {
88-
cursors.push(cursorId);
89-
}
90-
}
91-
});
9273
});
9374

9475
afterEach(async function () {
9576
logs.length = 0;
9677
const utilClient = this.configuration.newClient();
9778
try {
98-
if (cursors.length) {
99-
await utilClient.db('abortSignal').command({ killCursors: 'support', cursors });
100-
cursors.length = 0;
101-
}
10279
await utilClient.db('abortSignal').collection('support').deleteMany({});
10380
} finally {
10481
await utilClient.close();
105-
await client?.close();
10682
}
83+
await client?.close();
10784
});
10885

10986
function testCursor(cursorName: string, constructor: any) {

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
type ChangeStream,
88
ClientSession,
99
type Collection,
10-
Long,
1110
MongoClient,
1211
MongoNotConnectedError,
1312
ProfilingLevel,
@@ -20,7 +19,7 @@ describe('When executing an operation for the first time', () => {
2019
let client: MongoClient;
2120

2221
beforeEach('create client', async function () {
23-
client = this.configuration.newClient({}, { monitorCommands: true });
22+
client = this.configuration.newClient();
2423
});
2524

2625
beforeEach('create test namespace', async function () {
@@ -213,16 +212,13 @@ describe('When executing an operation for the first time', () => {
213212
let changeCausingCollection: Collection;
214213
let collection: Collection;
215214
let cs: ChangeStream;
216-
const cursors = [];
217215

218216
beforeEach(async function () {
219-
cursors.length = 0;
220-
221217
if (this.configuration.topologyType === TopologyType.Single) {
222218
return;
223219
}
224220
changeCausingClient = this.configuration.newClient();
225-
changeCausingCollection = await changeCausingClient
221+
await changeCausingClient
226222
.db('auto-connect-change')
227223
.createCollection('auto-connect')
228224
.catch(() => null);
@@ -233,25 +229,9 @@ describe('When executing an operation for the first time', () => {
233229

234230
collection = client.db('auto-connect-change').collection('auto-connect');
235231
cs = collection.watch();
236-
237-
client.on('commandSucceeded', ev => {
238-
if (ev.commandName === 'aggregate') {
239-
const cursorId = Long.isLong(ev.reply.cursor.id)
240-
? ev.reply.cursor.id
241-
: Long.fromNumber(ev.reply.cursor.id);
242-
243-
if (!Long.ZERO.equals(cursorId)) {
244-
cursors.push(cursorId);
245-
}
246-
}
247-
});
248232
});
249233

250234
afterEach(async function () {
251-
if (cursors.length) {
252-
await client.db('auto-connect-change').command({ killCursors: 'auto-connect', cursors });
253-
cursors.length = 0;
254-
}
255235
await changeCausingClient?.close();
256236
await cs?.close();
257237
});

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,11 @@ describe('MongoClient.close() Integration', () => {
648648
utilClient = this.configuration.newClient();
649649
await client.connect();
650650
await client
651-
.db('db')
652-
.collection('coll')
651+
.db('close_db')
652+
.collection('close_coll')
653653
.drop()
654654
.catch(() => null);
655-
coll = await client.db('db').createCollection('coll');
655+
coll = await client.db('close_db').createCollection('close_coll');
656656
await coll.insertMany([{ a: 1 }, { b: 2 }, { c: 3 }]);
657657
});
658658

@@ -672,11 +672,7 @@ describe('MongoClient.close() Integration', () => {
672672
.aggregate([{ $currentOp: { idleCursors: true } }])
673673
.toArray();
674674

675-
return cursors.filter(
676-
c =>
677-
c.ns !== 'local.oplog.rs' &&
678-
(c.type === 'idleCursor' || (c.type === 'op' && c.desc === 'getMore'))
679-
); // all idle cursors
675+
return cursors.filter(c => c.ns === 'close_db.close_coll');
680676
};
681677

682678
cursor = coll.find({}, { batchSize: 1 });

0 commit comments

Comments
 (0)