Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(no-story): skip failing aggregate explain tests #3863

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 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,18 @@ 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') &&
!test?.fullTitle().includes('false') &&
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