Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(spanner): fix flaky TestReadWriteTransaction_ContextTimeoutDuringDuringCommit #3915

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions spanner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1749,10 +1749,28 @@ func TestClient_WriteStructWithCustomTypes(t *testing.T) {
}
}

func TestReadWriteTransaction_ContextTimeoutDuringDuringCommit(t *testing.T) {
func TestReadWriteTransaction_ContextTimeoutDuringCommit(t *testing.T) {
t.Parallel()
server, client, teardown := setupMockedTestServer(t)
server, client, teardown := setupMockedTestServerWithConfig(t, ClientConfig{
SessionPoolConfig: SessionPoolConfig{
MinOpened: 1,
WriteSessions: 0,
},
})
defer teardown()

// Wait until session creation has seized so that
// context timeout won't happen while a session is being created.
waitFor(t, func() error {
sp := client.idleSessions
sp.mu.Lock()
defer sp.mu.Unlock()
if sp.createReqs != 0 {
return fmt.Errorf("%d sessions are still in creation", sp.createReqs)
}
return nil
})

server.TestSpanner.PutExecutionTime(MethodCommitTransaction,
SimulatedExecutionTime{
MinimumExecutionTime: time.Minute,
Expand Down