Skip to content

Commit b6bfb4b

Browse files
better0fdeadoleg-jukovec
authored andcommitted
test: fix connection_pool test
Changed checkTimeout time in test. The reason is that by default it updates the connects once every 1 second. And it doesn't have time to update for some reason in the case of a test in the same second. So set the update to half the time. Part of #157
1 parent 8ae485f commit b6bfb4b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

connection_pool/connection_pool_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,7 +2210,11 @@ func TestConnectionPool_NewWatcher_update(t *testing.T) {
22102210
err := test_helpers.SetClusterRO(servers, opts, roles)
22112211
require.Nilf(t, err, "fail to set roles for cluster")
22122212

2213-
pool, err := connection_pool.Connect(servers, opts)
2213+
poolOpts := connection_pool.OptsPool{
2214+
CheckTimeout: 500 * time.Millisecond,
2215+
}
2216+
pool, err := connection_pool.ConnectWithOpts(servers, opts, poolOpts)
2217+
22142218
require.Nilf(t, err, "failed to connect")
22152219
require.NotNilf(t, pool, "conn is nil after Connect")
22162220
defer pool.Close()
@@ -2238,7 +2242,7 @@ func TestConnectionPool_NewWatcher_update(t *testing.T) {
22382242
} else {
22392243
testMap[addr] = 1
22402244
}
2241-
case <-time.After(time.Second):
2245+
case <-time.After(poolOpts.CheckTimeout * 2):
22422246
t.Errorf("Failed to get a watch init event.")
22432247
break
22442248
}

0 commit comments

Comments
 (0)