Skip to content

Commit 7d2e85e

Browse files
committed
only set opt.IdleTimeout in It("reuses connections")
Signed-off-by: monkey <[email protected]>
1 parent 42b2a72 commit 7d2e85e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pool_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var _ = Describe("pool", func() {
1717
opt := redisOptions()
1818
opt.MinIdleConns = 0
1919
opt.MaxConnAge = 0
20-
opt.IdleTimeout = 2 * time.Second
20+
opt.IdleTimeout = time.Second
2121
client = redis.NewClient(opt)
2222
})
2323

@@ -105,6 +105,13 @@ var _ = Describe("pool", func() {
105105
})
106106

107107
It("reuses connections", func() {
108+
// explain: https://github.com/go-redis/redis/pull/1675
109+
opt := redisOptions()
110+
opt.MinIdleConns = 0
111+
opt.MaxConnAge = 0
112+
opt.IdleTimeout = 2 * time.Second
113+
client = redis.NewClient(opt)
114+
108115
for i := 0; i < 100; i++ {
109116
val, err := client.Ping(ctx).Result()
110117
Expect(err).NotTo(HaveOccurred())
@@ -135,7 +142,7 @@ var _ = Describe("pool", func() {
135142
StaleConns: 0,
136143
}))
137144

138-
time.Sleep(3 * time.Second)
145+
time.Sleep(2 * time.Second)
139146

140147
stats = client.PoolStats()
141148
Expect(stats).To(Equal(&redis.PoolStats{

0 commit comments

Comments
 (0)