Skip to content

test(spanner): unflake ChannelPoolBuiltInMetricsTest - #15054

Merged
sakthivelmanii merged 1 commit into
mainfrom
unflake-channelpoolbuiltinmetricstest
Nov 17, 2026
Merged

sakthivelmanii merged 1 commit into
mainfrom
unflake-channelpoolbuiltinmetricstest

Conversation

@sakthivelmanii

Copy link
Copy Markdown
Contributor

Problem

  • ChannelPoolBuiltInMetricsTest.tearDown() resets SpannerOptions.useDefaultEnvironment(), and four individual DirectPath and environment-variable tests override SpannerOptions.useEnvironment(...), but setUp() does not isolate the test suite from ambient process environment variables.
  • When GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS=true is exported in the process environment, SpannerOptions.newBuilder() reads SpannerEnvironmentImpl.isEnableDirectAccess() == true and enables GCP fallback (setupGcpFallback), creating both directpath and cloudpath grpc-gcp channel pools instead of a single cloudpath pool and causing six CloudPath-expecting unit tests (adminCallsDoNotReportChannelLoad, channelCountIsReportedForTheDataPoolOnly, channelLoadIsReportedWithTheDatabaseOfTheCall, channelPoolMetricsConvertToCloudMonitoringTimeSeries, dynamicPoolReportsDynamicPoolModeAndChannelLoad, and eachClientReportsItsOwnPoolUntilItIsClosed) to fail deterministically.

Solution

  • Call SpannerOptions.useEnvironment(new SpannerOptions.SpannerEnvironment() {}); in ChannelPoolBuiltInMetricsTest.setUp() (matching MetricsProviderTest.setUp() and pairing symmetrically with SpannerOptions.useDefaultEnvironment() in tearDown()) so all tests start from a hermetic SpannerEnvironment regardless of ambient environment variables while still allowing individual tests to install custom SpannerEnvironment overrides.

Isolate ChannelPoolBuiltInMetricsTest from ambient process environment variables by installing an empty SpannerOptions.SpannerEnvironment in setUp(), matching tearDown()'s SpannerOptions.useDefaultEnvironment().
@sakthivelmanii
sakthivelmanii requested review from a team as code owners November 17, 2026 14:10
@sakthivelmanii
sakthivelmanii enabled auto-merge (squash) November 17, 2026 14:10
@sakthivelmanii

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 updates the setUp method in ChannelPoolBuiltInMetricsTest.java to initialize a default SpannerEnvironment using SpannerOptions.useEnvironment(). There are no review comments, so I have no feedback to provide.

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

Copy link
Copy Markdown
Contributor

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 updates the setUp method in ChannelPoolBuiltInMetricsTest.java to initialize a default SpannerEnvironment using SpannerOptions.useEnvironment(). There are no review comments to address, and I have no additional feedback to provide.

@sakthivelmanii
sakthivelmanii merged commit f3215e7 into main Nov 17, 2026
203 of 205 checks passed
@sakthivelmanii
sakthivelmanii deleted the unflake-channelpoolbuiltinmetricstest branch November 17, 2026 15:08
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.

2 participants