Skip to content

Commit 2a3de19

Browse files
chore: skip failing aggregate explain tests (#3863)
1 parent 68e5d67 commit 2a3de19

File tree

2 files changed

+68
-52
lines changed

2 files changed

+68
-52
lines changed

test/integration/crud/aggregation.test.ts

Lines changed: 56 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -270,66 +270,70 @@ describe('Aggregation', function () {
270270
});
271271
});
272272

273-
it('should correctly return a cursor and call explain', function (done) {
274-
const client = this.configuration.newClient({ maxPoolSize: 1 }),
275-
databaseName = this.configuration.db;
276-
277-
const db = client.db(databaseName);
278-
// Some docs for insertion
279-
const docs = [
280-
{
281-
title: 'this is my title',
282-
author: 'bob',
283-
posted: new Date(),
284-
pageViews: 5,
285-
tags: ['fun', 'good', 'fun'],
286-
other: { foo: 5 },
287-
comments: [
288-
{ author: 'joe', text: 'this is cool' },
289-
{ author: 'sam', text: 'this is bad' }
290-
]
291-
}
292-
];
273+
it(
274+
'should correctly return a cursor and call explain',
275+
{ requires: { mongodb: '<7.1.0' } },
276+
function (done) {
277+
const client = this.configuration.newClient({ maxPoolSize: 1 }),
278+
databaseName = this.configuration.db;
279+
280+
const db = client.db(databaseName);
281+
// Some docs for insertion
282+
const docs = [
283+
{
284+
title: 'this is my title',
285+
author: 'bob',
286+
posted: new Date(),
287+
pageViews: 5,
288+
tags: ['fun', 'good', 'fun'],
289+
other: { foo: 5 },
290+
comments: [
291+
{ author: 'joe', text: 'this is cool' },
292+
{ author: 'sam', text: 'this is bad' }
293+
]
294+
}
295+
];
293296

294-
// Create a collection
295-
const collection = db.collection('shouldCorrectlyDoAggWithCursorGet');
296-
// Insert the docs
297-
collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) {
298-
expect(result).to.exist;
299-
expect(err).to.not.exist;
297+
// Create a collection
298+
const collection = db.collection('shouldCorrectlyDoAggWithCursorGet');
299+
// Insert the docs
300+
collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) {
301+
expect(result).to.exist;
302+
expect(err).to.not.exist;
300303

301-
// Execute aggregate, notice the pipeline is expressed as an Array
302-
const cursor = collection.aggregate(
303-
[
304-
{
305-
$project: {
306-
author: 1,
307-
tags: 1
304+
// Execute aggregate, notice the pipeline is expressed as an Array
305+
const cursor = collection.aggregate(
306+
[
307+
{
308+
$project: {
309+
author: 1,
310+
tags: 1
311+
}
312+
},
313+
{ $unwind: '$tags' },
314+
{
315+
$group: {
316+
_id: { tags: '$tags' },
317+
authors: { $addToSet: '$author' }
318+
}
308319
}
309-
},
310-
{ $unwind: '$tags' },
320+
],
311321
{
312-
$group: {
313-
_id: { tags: '$tags' },
314-
authors: { $addToSet: '$author' }
315-
}
322+
cursor: { batchSize: 100 }
316323
}
317-
],
318-
{
319-
cursor: { batchSize: 100 }
320-
}
321-
);
324+
);
322325

323-
// Iterate over all the items in the cursor
324-
cursor.explain(function (err, result) {
325-
expect(err).to.not.exist;
326-
expect(result.stages).to.have.lengthOf.at.least(1);
327-
expect(result.stages[0]).to.have.property('$cursor');
326+
// Iterate over all the items in the cursor
327+
cursor.explain(function (err, result) {
328+
expect(err).to.not.exist;
329+
expect(result.stages).to.have.lengthOf.at.least(1);
330+
expect(result.stages[0]).to.have.property('$cursor');
328331

329-
client.close(done);
332+
client.close(done);
333+
});
330334
});
331-
});
332-
});
335+
}
336+
).skipReason = 'TODO(NODE-5617): aggregate explain tests failing on latest servers';
333337

334338
it('should correctly return a cursor with batchSize 1 and call next', function (done) {
335339
const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),

test/integration/crud/explain.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { expect } from 'chai';
22
import { once } from 'events';
3+
import { gte } from 'semver';
34

45
import {
56
type Collection,
@@ -73,6 +74,17 @@ describe('CRUD API explain option', function () {
7374
collection = db.collection('test');
7475
await collection.insertOne({ a: 1 });
7576
commandStartedPromise = once(client, 'commandStarted');
77+
78+
const test = this.currentTest;
79+
if (
80+
test?.fullTitle().includes('aggregate') &&
81+
gte(this.configuration.version, '7.1.0') &&
82+
this.currentTest
83+
) {
84+
this.currentTest.skipReason =
85+
'TODO(NODE-5617): aggregate explain tests failing on latest servers';
86+
this.skip();
87+
}
7688
});
7789

7890
afterEach(async function () {

0 commit comments

Comments
 (0)