@@ -6,11 +6,13 @@ import (
66 "errors"
77 "fmt"
88 "net"
9+ "reflect"
910 "slices"
1011 "strconv"
1112 "strings"
1213 "sync"
1314 "time"
15+ "unsafe"
1416
1517 . "github.com/bsm/ginkgo/v2"
1618 . "github.com/bsm/gomega"
@@ -256,6 +258,10 @@ func slotEqual(s1, s2 redis.ClusterSlot) bool {
256258 return true
257259}
258260
261+ func getField (field reflect.Value ) any {
262+ return reflect .NewAt (field .Type (), unsafe .Pointer (field .UnsafeAddr ())).Elem ().Interface ()
263+ }
264+
259265// ------------------------------------------------------------------------------
260266
261267var _ = Describe ("ClusterClient" , func () {
@@ -1631,11 +1637,12 @@ var _ = Describe("ClusterClient timeout", func() {
16311637 BeforeEach (func () {
16321638 opt := redisClusterOptions ()
16331639 client = cluster .newClusterClient (ctx , opt )
1640+ opt = getField (reflect .ValueOf (client ).Elem ().FieldByName ("opt" )).(* redis.ClusterOptions )
16341641
16351642 err := client .ForEachShard (ctx , func (ctx context.Context , client * redis.Client ) error {
16361643 err := client .ClientPause (ctx , pause ).Err ()
16371644
1638- opt := client . Options ( )
1645+ opt := getField ( reflect . ValueOf ( client ). Elem (). FieldByName ( "opt" )).( * redis. Options )
16391646 opt .ReadTimeout = time .Nanosecond
16401647 opt .WriteTimeout = time .Nanosecond
16411648
@@ -1653,7 +1660,7 @@ var _ = Describe("ClusterClient timeout", func() {
16531660 _ = client .ForEachShard (ctx , func (ctx context.Context , client * redis.Client ) error {
16541661 defer GinkgoRecover ()
16551662
1656- opt := client . Options ( )
1663+ opt := getField ( reflect . ValueOf ( client ). Elem (). FieldByName ( "opt" )).( * redis. Options )
16571664 opt .ReadTimeout = time .Second
16581665 opt .WriteTimeout = time .Second
16591666
@@ -3188,6 +3195,7 @@ var _ = Describe("ClusterClient FailingTimeoutSeconds", func() {
31883195 It ("should use default failing timeout of 15 seconds" , func () {
31893196 opt := redisClusterOptions ()
31903197 client = cluster .newClusterClient (ctx , opt )
3198+ opt = client .Options ()
31913199
31923200 // Default should be 15 seconds
31933201 Expect (opt .FailingTimeoutSeconds ).To (Equal (15 ))
@@ -3197,6 +3205,7 @@ var _ = Describe("ClusterClient FailingTimeoutSeconds", func() {
31973205 opt := redisClusterOptions ()
31983206 opt .FailingTimeoutSeconds = 30
31993207 client = cluster .newClusterClient (ctx , opt )
3208+ opt = client .Options ()
32003209
32013210 // Should use custom value
32023211 Expect (opt .FailingTimeoutSeconds ).To (Equal (30 ))
@@ -3241,6 +3250,7 @@ var _ = Describe("ClusterClient FailingTimeoutSeconds", func() {
32413250 opt := redisClusterOptions ()
32423251 opt .FailingTimeoutSeconds = 0 // Should use default
32433252 client = cluster .newClusterClient (ctx , opt )
3253+ opt = client .Options ()
32443254
32453255 // After initialization, should be set to default
32463256 Expect (opt .FailingTimeoutSeconds ).To (Equal (15 ))
0 commit comments