Skip to content

Commit

Permalink
chore: skip failing aggregate explain tests (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson authored Sep 11, 2023
1 parent 68e5d67 commit 2a3de19
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 52 deletions.
108 changes: 56 additions & 52 deletions test/integration/crud/aggregation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,66 +270,70 @@ describe('Aggregation', function () {
});
});

it('should correctly return a cursor and call explain', function (done) {
const client = this.configuration.newClient({ maxPoolSize: 1 }),
databaseName = this.configuration.db;

const db = client.db(databaseName);
// Some docs for insertion
const docs = [
{
title: 'this is my title',
author: 'bob',
posted: new Date(),
pageViews: 5,
tags: ['fun', 'good', 'fun'],
other: { foo: 5 },
comments: [
{ author: 'joe', text: 'this is cool' },
{ author: 'sam', text: 'this is bad' }
]
}
];
it(
'should correctly return a cursor and call explain',
{ requires: { mongodb: '<7.1.0' } },
function (done) {
const client = this.configuration.newClient({ maxPoolSize: 1 }),
databaseName = this.configuration.db;

const db = client.db(databaseName);
// Some docs for insertion
const docs = [
{
title: 'this is my title',
author: 'bob',
posted: new Date(),
pageViews: 5,
tags: ['fun', 'good', 'fun'],
other: { foo: 5 },
comments: [
{ author: 'joe', text: 'this is cool' },
{ author: 'sam', text: 'this is bad' }
]
}
];

// Create a collection
const collection = db.collection('shouldCorrectlyDoAggWithCursorGet');
// Insert the docs
collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) {
expect(result).to.exist;
expect(err).to.not.exist;
// Create a collection
const collection = db.collection('shouldCorrectlyDoAggWithCursorGet');
// Insert the docs
collection.insertMany(docs, { writeConcern: { w: 1 } }, function (err, result) {
expect(result).to.exist;
expect(err).to.not.exist;

// Execute aggregate, notice the pipeline is expressed as an Array
const cursor = collection.aggregate(
[
{
$project: {
author: 1,
tags: 1
// Execute aggregate, notice the pipeline is expressed as an Array
const cursor = collection.aggregate(
[
{
$project: {
author: 1,
tags: 1
}
},
{ $unwind: '$tags' },
{
$group: {
_id: { tags: '$tags' },
authors: { $addToSet: '$author' }
}
}
},
{ $unwind: '$tags' },
],
{
$group: {
_id: { tags: '$tags' },
authors: { $addToSet: '$author' }
}
cursor: { batchSize: 100 }
}
],
{
cursor: { batchSize: 100 }
}
);
);

// Iterate over all the items in the cursor
cursor.explain(function (err, result) {
expect(err).to.not.exist;
expect(result.stages).to.have.lengthOf.at.least(1);
expect(result.stages[0]).to.have.property('$cursor');
// Iterate over all the items in the cursor
cursor.explain(function (err, result) {
expect(err).to.not.exist;
expect(result.stages).to.have.lengthOf.at.least(1);
expect(result.stages[0]).to.have.property('$cursor');

client.close(done);
client.close(done);
});
});
});
});
}
).skipReason = 'TODO(NODE-5617): aggregate explain tests failing on latest servers';

it('should correctly return a cursor with batchSize 1 and call next', function (done) {
const client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1 }),
Expand Down
12 changes: 12 additions & 0 deletions test/integration/crud/explain.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { once } from 'events';
import { gte } from 'semver';

import {
type Collection,
Expand Down Expand Up @@ -73,6 +74,17 @@ describe('CRUD API explain option', function () {
collection = db.collection('test');
await collection.insertOne({ a: 1 });
commandStartedPromise = once(client, 'commandStarted');

const test = this.currentTest;
if (
test?.fullTitle().includes('aggregate') &&
gte(this.configuration.version, '7.1.0') &&
this.currentTest
) {
this.currentTest.skipReason =
'TODO(NODE-5617): aggregate explain tests failing on latest servers';
this.skip();
}
});

afterEach(async function () {
Expand Down

0 comments on commit 2a3de19

Please sign in to comment.