Skip to content

test(security-center): fix concurrent modification error in management api tests#4318

Open
angelcaamal wants to merge 6 commits into
mainfrom
fix/security-center-concurrent-tests
Open

test(security-center): fix concurrent modification error in management api tests#4318
angelcaamal wants to merge 6 commits into
mainfrom
fix/security-center-concurrent-tests

Conversation

@angelcaamal
Copy link
Copy Markdown
Contributor

@angelcaamal angelcaamal commented May 19, 2026

Description

Fixes Internal : b/515074301

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

  • Fixed API Concurrency Collisions (package.json)

    • Removed the parallel execution flags (-p -j 2) from the test script. Running tests sequentially eliminates the 10 ABORTED: Failed to create module due to concurrent modification errors caused by workers clashing over the same global resources.
  • Resolved Resource Leaks in Notifications V2 (ALREADY_EXISTS)

    • Implemented dynamic Pub/Sub topic naming using uuidv1() to prevent collisions between test runs.
    • Enhanced the teardown logic in the after hook to explicitly delete the Notification Config (deleteNotificationConfig) alongside the Pub/Sub topic, preventing orphaned resources.
  • Stabilized Custom Module Tests (createSecurityHealthAnalyticsCustomModule)

    • Leveraged Mocha's native this.retries(3) to gracefully handle any residual API timeouts or flakiness.
    • Moved the SecurityCenterManagementClient instantiation to the describe block scope and added await client.close() in the teardown hook to ensure proper gRPC connection closure.
  • Fixed Unhandled Promise Rejections in Mute Rules V2

    • Wrapped the createMuteConfig API call in a try...catch block. This prevents silent API failures from returning undefined and throwing misleading TypeError: (intermediate value) is not iterable destructuring errors, allowing Mocha to correctly report the underlying API issue.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Note: Any check with (dev), (experimental), or (legacy) can be ignored and should not block your PR from merging (see CI testing).

@angelcaamal angelcaamal added the api: securitycenter Issues related to the Security Command Center API. label May 19, 2026
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label May 19, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the security health analytics custom module tests by moving the SecurityCenterManagementClient instantiation to the describe block scope and adding a client.close() call in the after hook for better resource management. It also introduces a retry mechanism with exponential backoff in the before hook to handle concurrent modification errors (code 10) during module creation. I have no feedback to provide as there were no review comments.

@angelcaamal angelcaamal marked this pull request as ready for review May 20, 2026 21:11
@angelcaamal angelcaamal requested review from a team as code owners May 20, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: securitycenter Issues related to the Security Command Center API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants