Skip to content

fix(test): resolve flakiness in MaxIdleConnections tests#825

Open
olavloite wants to merge 3 commits into
mainfrom
fix/816-flaky-idle-connections-test
Open

fix(test): resolve flakiness in MaxIdleConnections tests#825
olavloite wants to merge 3 commits into
mainfrom
fix/816-flaky-idle-connections-test

Conversation

@olavloite

@olavloite olavloite commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Resolves the flakiness in TestMaxIdleConnectionsNonZero and TestMaxIdleConnectionsZero by running them with multiplexed sessions disabled, configuring minSessions=1, and counting the created sessions. Drains requests after shutting down the client/server during teardown. Additionally, fixes an infinite loop bug in DrainRequestsFromServer on closed channel, and removes an unused background client in setupTestDBConnectionWithParamsAndDialect.

Fixes #816

@olavloite olavloite requested a review from a team as a code owner June 11, 2026 13:12

@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 refactors several Spanner driver tests to handle multiplexed sessions correctly, simplifies connection closing, and introduces a helper function countCreatedSessions to count session creation requests. It also updates DrainRequestsFromServer to safely handle closed channels. The review feedback suggests two improvements: storing the channel in a local variable before the loop in DrainRequestsFromServer to avoid repeated method calls, and using a type switch in countCreatedSessions for more idiomatic Go code.

Comment thread testutil/inmem_spanner_server.go
Comment thread driver_with_mockserver_test.go
@olavloite

Copy link
Copy Markdown
Collaborator Author

Excellent fix for MaxIdleConnections flakiness. Disabling multiplexed sessions and checking session creation requests directly makes the tests deterministic. Also, fixing the infinite loop in DrainRequestsFromServer when the channel is closed is a crucial bug fix for the test utilities. Clean work.

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.

TestMaxIdleConnectionsNonZero is flaky

1 participant