@@ -2018,12 +2018,12 @@ func TestConnectionMigration(t *testing.T) {
2018
2018
require .Equal (t , totalAttempts , count )
2019
2019
}
2020
2020
2021
- transferConnWithRetries := func (t * testing.T , f * forwarder ) error {
2021
+ transferConnWithRetries := func (t * testing.T , ctx context. Context , f * forwarder ) error {
2022
2022
t .Helper ()
2023
2023
2024
2024
var nonRetriableErrSeen bool
2025
2025
err := testutils .SucceedsSoonError (func () error {
2026
- err := f .TransferConnection ()
2026
+ err := f .TransferConnection (ctx )
2027
2027
if err == nil {
2028
2028
return nil
2029
2029
}
@@ -2091,7 +2091,7 @@ func TestConnectionMigration(t *testing.T) {
2091
2091
require .NoError (t , err )
2092
2092
2093
2093
// Show that we get alternating SQL pods when we transfer.
2094
- require .NoError (t , transferConnWithRetries (t , f ))
2094
+ require .NoError (t , transferConnWithRetries (t , tCtx , f ))
2095
2095
require .Equal (t , int64 (1 ), f .metrics .ConnMigrationSuccessCount .Count ())
2096
2096
require .Equal (t , tenant2 .SQLAddr (), queryAddr (tCtx , t , db ))
2097
2097
@@ -2102,7 +2102,7 @@ func TestConnectionMigration(t *testing.T) {
2102
2102
_ , err = db .Exec ("SET application_name = 'bar'" )
2103
2103
require .NoError (t , err )
2104
2104
2105
- require .NoError (t , transferConnWithRetries (t , f ))
2105
+ require .NoError (t , transferConnWithRetries (t , tCtx , f ))
2106
2106
require .Equal (t , int64 (2 ), f .metrics .ConnMigrationSuccessCount .Count ())
2107
2107
require .Equal (t , tenant1 .SQLAddr (), queryAddr (tCtx , t , db ))
2108
2108
@@ -2120,14 +2120,14 @@ func TestConnectionMigration(t *testing.T) {
2120
2120
go func () {
2121
2121
defer wg .Done ()
2122
2122
for subCtx .Err () == nil {
2123
- _ = f .TransferConnection ()
2123
+ _ = f .TransferConnection (tCtx )
2124
2124
time .Sleep (100 * time .Millisecond )
2125
2125
}
2126
2126
}()
2127
2127
2128
2128
// This loop will run approximately 5 seconds.
2129
2129
var tenant1Addr , tenant2Addr int
2130
- for i := 0 ; i < 100 ; i ++ {
2130
+ for range 100 {
2131
2131
addr := queryAddr (tCtx , t , db )
2132
2132
if addr == tenant1 .SQLAddr () {
2133
2133
tenant1Addr ++
@@ -2167,7 +2167,7 @@ func TestConnectionMigration(t *testing.T) {
2167
2167
err = crdb .ExecuteTx (tCtx , db , nil /* txopts */ , func (tx * gosql.Tx ) error {
2168
2168
// Run multiple times to ensure that connection isn't closed.
2169
2169
for i := 0 ; i < 5 ; {
2170
- err := f .TransferConnection ()
2170
+ err := f .TransferConnection (tCtx )
2171
2171
if err == nil {
2172
2172
return errors .New ("no error" )
2173
2173
}
@@ -2201,7 +2201,7 @@ func TestConnectionMigration(t *testing.T) {
2201
2201
require .Equal (t , int64 (0 ), f .metrics .ConnMigrationErrorFatalCount .Count ())
2202
2202
2203
2203
// Once the transaction is closed, transfers should work.
2204
- require .NoError (t , transferConnWithRetries (t , f ))
2204
+ require .NoError (t , transferConnWithRetries (t , tCtx , f ))
2205
2205
require .NotEqual (t , initAddr , queryAddr (tCtx , t , db ))
2206
2206
require .Nil (t , f .ctx .Err ())
2207
2207
require .Equal (t , initSuccessCount + 1 , f .metrics .ConnMigrationSuccessCount .Count ())
@@ -2223,7 +2223,7 @@ func TestConnectionMigration(t *testing.T) {
2223
2223
lookupAddrDelayDuration = 10 * time .Second
2224
2224
defer testutils .TestingHook (& defaultTransferTimeout , 3 * time .Second )()
2225
2225
2226
- err := f .TransferConnection ()
2226
+ err := f .TransferConnection (tCtx )
2227
2227
require .Error (t , err )
2228
2228
require .Regexp (t , "injected delays" , err .Error ())
2229
2229
require .Equal (t , initAddr , queryAddr (tCtx , t , db ))
@@ -2319,7 +2319,7 @@ func TestConnectionMigration(t *testing.T) {
2319
2319
time .Sleep (2 * time .Second )
2320
2320
// This should be an error because the transfer timed out. Connection
2321
2321
// should automatically be closed.
2322
- require .Error (t , f .TransferConnection ())
2322
+ require .Error (t , f .TransferConnection (tCtx ))
2323
2323
2324
2324
select {
2325
2325
case <- time .After (10 * time .Second ):
0 commit comments