Skip to content

Conversation

blva
Copy link
Collaborator

@blva blva commented Oct 14, 2025

Proposed changes

  • reduces the clean up time to 2h
  • updates the orgs test to explicitly use credentials

Checklist

@blva blva changed the title chore: reduce cleanup time and improve tests chore: reduce cleanup time Oct 14, 2025
@blva blva marked this pull request as ready for review October 14, 2025 16:42
@blva blva requested a review from a team as a code owner October 14, 2025 16:42
@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 16:42
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR reduces cleanup time for test resources and enhances test organization by creating a more flexible credential handling system. It changes the cleanup threshold from 24 hours to 2 hours to prevent test resource accumulation.

  • Reduces cleanup time from 24 hours to 2 hours for Atlas test resources
  • Adds credential validation wrapper for Atlas integration tests
  • Improves null safety in cleanup script

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/integration/tools/atlas/orgs.test.ts Wraps tests with credential validation using new withCredentials helper
tests/integration/tools/atlas/atlasHelpers.ts Adds withCredentials function and fallback credentials for test configuration
scripts/cleanupAtlasTestLeftovers.test.ts Reduces cleanup time to 2 hours and adds null safety check for organization ID

Comment on lines +21 to +22
apiClientId: process.env.MDB_MCP_API_CLIENT_ID || "test-client",
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET || "test-secret",
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using hardcoded fallback credentials ('test-client', 'test-secret') creates a security risk. These fallback values should be removed or replaced with proper test environment validation that fails gracefully when credentials are missing.

Suggested change
apiClientId: process.env.MDB_MCP_API_CLIENT_ID || "test-client",
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET || "test-secret",
apiClientId: process.env.MDB_MCP_API_CLIENT_ID,
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET,

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this, why don't we use defaultTestConfig here which ideally should already parse these values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use defaultTestConfig but override it with the test items if it's not there


export function withCredentials(integration: IntegrationTest, fn: IntegrationTestFunction): SuiteCollector<object> {
const describeFn =
!process.env.MDB_MCP_API_CLIENT_ID?.length || !process.env.MDB_MCP_API_CLIENT_SECRET?.length
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The credential validation logic is duplicated between describeWithAtlas and withCredentials. Consider extracting this into a shared helper function to reduce code duplication.

Copilot uses AI. Check for mistakes.

Comment on lines +21 to +22
apiClientId: process.env.MDB_MCP_API_CLIENT_ID || "test-client",
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET || "test-secret",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed this, why don't we use defaultTestConfig here which ideally should already parse these values?

@blva blva merged commit 18fe549 into main Oct 15, 2025
15 of 17 checks passed
@blva blva deleted the fix-cleanup-2 branch October 15, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants