From f2751e3d1845449109df3f03d4d93b1cdcc330fd Mon Sep 17 00:00:00 2001 From: Filipe Constantinov Menezes Date: Mon, 30 Jun 2025 17:47:53 +0100 Subject: [PATCH 1/3] fix: index tests --- .github/workflows/code_health.yaml | 6 +++--- src/tools/mongodb/read/aggregate.ts | 2 +- tests/integration/tools/mongodb/mongodbHelpers.ts | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code_health.yaml b/.github/workflows/code_health.yaml index 2f8ed17a..5505ec67 100644 --- a/.github/workflows/code_health.yaml +++ b/.github/workflows/code_health.yaml @@ -11,7 +11,7 @@ permissions: {} jobs: run-tests: name: Run MongoDB tests - if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository + if: github.event_name == 'push' || (github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository) strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -38,7 +38,7 @@ jobs: run-atlas-tests: name: Run Atlas tests - if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository + if: github.event_name == 'push' || (github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository) runs-on: ubuntu-latest steps: - uses: GitHubSecurityLab/actions-permissions/monitor@v1 @@ -64,7 +64,7 @@ jobs: coverage: name: Report Coverage - if: always() && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository + if: always() && (github.event_name == 'push' || (github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository)) runs-on: ubuntu-latest needs: [run-tests, run-atlas-tests] steps: diff --git a/src/tools/mongodb/read/aggregate.ts b/src/tools/mongodb/read/aggregate.ts index aa21fc5d..3116fe61 100644 --- a/src/tools/mongodb/read/aggregate.ts +++ b/src/tools/mongodb/read/aggregate.ts @@ -29,7 +29,7 @@ export class AggregateTool extends MongoDBToolBase { if (this.config.indexCheck) { await checkIndexUsage(provider, database, collection, "aggregate", async () => { return provider - .aggregate(database, collection, pipeline, {}, { writeConcern: undefined }) + .aggregate(database, collection, pipeline) .explain("queryPlanner"); }); } diff --git a/tests/integration/tools/mongodb/mongodbHelpers.ts b/tests/integration/tools/mongodb/mongodbHelpers.ts index ca4b09c1..935b27db 100644 --- a/tests/integration/tools/mongodb/mongodbHelpers.ts +++ b/tests/integration/tools/mongodb/mongodbHelpers.ts @@ -70,6 +70,7 @@ export function setupMongoDBIntegrationTest(): MongoDBIntegrationTest { tmpDir: dbsDir, logDir: path.join(tmpDir, "mongodb-runner", "logs"), topology: "standalone", + version: "8.0.10", }); return; From e4c7c033766eb118a6732d15afe73d142ae4896c Mon Sep 17 00:00:00 2001 From: Filipe Constantinov Menezes Date: Mon, 30 Jun 2025 17:50:36 +0100 Subject: [PATCH 2/3] fix: style --- src/tools/mongodb/read/aggregate.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tools/mongodb/read/aggregate.ts b/src/tools/mongodb/read/aggregate.ts index 3116fe61..03050ac1 100644 --- a/src/tools/mongodb/read/aggregate.ts +++ b/src/tools/mongodb/read/aggregate.ts @@ -28,9 +28,7 @@ export class AggregateTool extends MongoDBToolBase { // Check if aggregate operation uses an index if enabled if (this.config.indexCheck) { await checkIndexUsage(provider, database, collection, "aggregate", async () => { - return provider - .aggregate(database, collection, pipeline) - .explain("queryPlanner"); + return provider.aggregate(database, collection, pipeline).explain("queryPlanner"); }); } From 6e5bd97d5a9752afa468fe8cd03e890fe9344bb3 Mon Sep 17 00:00:00 2001 From: Filipe Constantinov Menezes Date: Mon, 30 Jun 2025 18:05:10 +0100 Subject: [PATCH 3/3] fix: tests --- src/tools/mongodb/read/aggregate.ts | 4 +++- tests/integration/indexCheck.test.ts | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tools/mongodb/read/aggregate.ts b/src/tools/mongodb/read/aggregate.ts index 03050ac1..aa21fc5d 100644 --- a/src/tools/mongodb/read/aggregate.ts +++ b/src/tools/mongodb/read/aggregate.ts @@ -28,7 +28,9 @@ export class AggregateTool extends MongoDBToolBase { // Check if aggregate operation uses an index if enabled if (this.config.indexCheck) { await checkIndexUsage(provider, database, collection, "aggregate", async () => { - return provider.aggregate(database, collection, pipeline).explain("queryPlanner"); + return provider + .aggregate(database, collection, pipeline, {}, { writeConcern: undefined }) + .explain("queryPlanner"); }); } diff --git a/tests/integration/indexCheck.test.ts b/tests/integration/indexCheck.test.ts index c6cc003e..70f53ed5 100644 --- a/tests/integration/indexCheck.test.ts +++ b/tests/integration/indexCheck.test.ts @@ -191,7 +191,6 @@ describe("IndexCheck integration tests", () => { collection: "aggregate-test-collection", pipeline: [ { $match: { category: "A" } }, // Now has index - { $group: { _id: "$category", count: { $sum: 1 } } }, ], }, }); @@ -308,7 +307,7 @@ describe("IndexCheck integration tests", () => { expect(response.isError).toBeFalsy(); const content = getResponseContent(response.content); expect(content).toContain("Deleted"); - expect(content).toMatch(/\d+ document\(s\)/); + expect(content).toMatch(/`\d+` document\(s\)/); }); }); },