mirror of
https://github.com/redis/go-redis.git
synced 2025-07-31 05:04:23 +03:00
Close the conn on context timeout
This commit is contained in:
20
race_test.go
20
race_test.go
@ -2,6 +2,7 @@ package redis_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
@ -295,6 +296,25 @@ var _ = Describe("races", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
It("should abort on context timeout", func() {
|
||||
opt := redisClusterOptions()
|
||||
client := cluster.newClusterClient(ctx, opt)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
wg := performAsync(C, func(_ int) {
|
||||
_, err := client.XRead(ctx, &redis.XReadArgs{
|
||||
Streams: []string{"test", "$"},
|
||||
Block: 1 * time.Second,
|
||||
}).Result()
|
||||
Expect(err).To(Equal(context.Canceled))
|
||||
})
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
cancel()
|
||||
wg.Wait()
|
||||
})
|
||||
})
|
||||
|
||||
var _ = Describe("cluster races", func() {
|
||||
|
Reference in New Issue
Block a user