test: The test collecting CSM for a second project should record metrics for the second project#1634
Merged
gcf-merge-on-green[bot] merged 19 commits intomainfrom Jul 14, 2025
Merged
Conversation
danieljbruce
commented
Jul 7, 2025
| const metricHandler = new metricsHandlerClass( | ||
| options as unknown as ClientOptions & {value: string}, | ||
| ); | ||
| const newClient = new Bigtable(options); |
Contributor
Author
There was a problem hiding this comment.
These changes make it so that now projectId gets passed into the metricsHandlerClass constructor.
danieljbruce
commented
Jul 7, 2025
| .catch(err => { | ||
| done(new Error('Metrics have not been published')); | ||
| done(err); | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
The catch is needed so that we can tell the test runner about the error and fail the test when this doesn't work.
…apis/nodejs-bigtable into second-project-id-bug-fix
This reverts commit d18c596.
…apis/nodejs-bigtable into second-project-id-bug-fix
daniel-sanche
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As indicated by this test run the CI pipeline is suddenly failing every time on the "should send the metrics to Google Cloud Monitoring for a ReadRows call with a second project" test. This is because the test incorrectly mocks the metric handler for the fake Bigtable client so that it doesn't include the same project as the Bigtable client. In practice this can never happen because options are always passed down from the Bigtable client to the metrics handler to the exporter as confirmed by "should pass the credentials to the exporter" test.
The assertion error occurs when we fetch the client side metrics, but there isn't any series in the returned array. This is because before with the test we were writing metrics with the default project instead of the secondary project:
Impact
Unblocks the CI pipeline.
Testing
The tests were changed to mock a more realistic situation.