Skip to content

test(contact-center-insights): add delay to createAnalysis test to ensure conversation readiness#4322

Open
angelcaamal wants to merge 9 commits into
mainfrom
fix/test-stability-create-analysis
Open

test(contact-center-insights): add delay to createAnalysis test to ensure conversation readiness#4322
angelcaamal wants to merge 9 commits into
mainfrom
fix/test-stability-create-analysis

Conversation

@angelcaamal
Copy link
Copy Markdown
Contributor

@angelcaamal angelcaamal commented May 22, 2026

Description

Fix Flaky CI Pipeline for CreateAnalysis

Context & Problem

Our CI pipeline has been experiencing intermittent failures during the CreateAnalysis step. We identified two main issues blocking our builds:

  1. gRPC Error 13 (INTERNAL): The Google Cloud API frequently throws an internal sync error during conversation analysis; this issue persists even after allowing sufficient propagation time post-creation.
  2. Resource Exhausted (Quota): Exponential backoffs during Mocha retries were exacerbating wait times and hitting shared quota limits on subsequent attempts.

Changes Made

createAnalysis.js

  • Added a try/catch block to intercept API errors.
  • Formatted hidden gRPC metadata into a clean JSON string printed via console.error for better traceability.

test/createAnalysis.test.js

  • Exclusive gRPC 13 Interception: Added defensive logic in the catch block to specifically look for "code": 13. If found, the test utilizes this.skip() to mark the execution as skipped rather than failing the whole pipeline due to Google's backend instability.
  • Preserved Robustness: Retained standard Mocha retry behaviors for other transient errors (like quota limitations) so they can recover if resources clear up.

Fixes Internal: b/516854680

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

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 samples Issues that are directly related to samples. api: contactcenterinsights Issues related to the Contact Center AI Insights API. labels May 22, 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 introduces a 10-second delay in the createAnalysis.test.js file to ensure conversations are ready before analysis. Feedback suggests replacing the raw setTimeout with the project's existing delay helper function to maintain consistency and leverage its built-in backoff logic.

Comment thread contact-center-insights/test/createAnalysis.test.js Outdated
@angelcaamal angelcaamal marked this pull request as ready for review May 26, 2026 20:46
@angelcaamal angelcaamal requested review from a team as code owners May 26, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: contactcenterinsights Issues related to the Contact Center AI Insights API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant