Skip to content

Commit

Permalink
feat(spanner): fix falkiness (#8977)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshachinta committed Nov 6, 2023
1 parent b2db89e commit ca8d3cb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions spanner/client_test.go
Expand Up @@ -1047,18 +1047,18 @@ func TestClient_ReadOnlyTransaction_WhenMultipleOperations_SessionLastUseTimeSho
MaxOpened: 1,
InactiveTransactionRemovalOptions: InactiveTransactionRemovalOptions{
actionOnInactiveTransaction: WarnAndClose,
idleTimeThreshold: 30 * time.Millisecond,
idleTimeThreshold: 300 * time.Millisecond,
},
},
})
defer teardown()
server.TestSpanner.PutExecutionTime(MethodExecuteStreamingSql,
SimulatedExecutionTime{
MinimumExecutionTime: 20 * time.Millisecond,
MinimumExecutionTime: 200 * time.Millisecond,
})
server.TestSpanner.PutExecutionTime(MethodStreamingRead,
SimulatedExecutionTime{
MinimumExecutionTime: 20 * time.Millisecond,
MinimumExecutionTime: 200 * time.Millisecond,
})
ctx := context.Background()
p := client.idleSessions
Expand Down Expand Up @@ -1090,11 +1090,11 @@ func TestClient_ReadOnlyTransaction_WhenMultipleOperations_SessionLastUseTimeSho
t.Fatalf("Session lastUseTime times should not be equal")
}

if (time.Now().Sub(sessionPrevLastUseTime)).Milliseconds() < 40 {
t.Fatalf("Expected session to be checkedout for more than 40 milliseconds")
if (time.Now().Sub(sessionPrevLastUseTime)).Milliseconds() < 400 {
t.Fatalf("Expected session to be checkedout for more than 400 milliseconds")
}
if (time.Now().Sub(sessionCheckoutTime)).Milliseconds() < 40 {
t.Fatalf("Expected session to be checkedout for more than 40 milliseconds")
if (time.Now().Sub(sessionCheckoutTime)).Milliseconds() < 400 {
t.Fatalf("Expected session to be checkedout for more than 400 milliseconds")
}
// force run task to clean up unexpected long-running sessions whose lastUseTime >= 3sec.
// The session should not be cleaned since the latest operation on the transaction has updated the lastUseTime.
Expand Down

0 comments on commit ca8d3cb

Please sign in to comment.