@@ -200,7 +200,7 @@ var _ = Describe("ClusterClient", func() {
200200
201201 Eventually (func () string {
202202 return client .Get ("A" ).Val ()
203- }).Should (Equal ("VALUE" ))
203+ }, 30 * time . Second ).Should (Equal ("VALUE" ))
204204
205205 cnt , err := client .Del ("A" ).Result ()
206206 Expect (err ).NotTo (HaveOccurred ())
@@ -215,7 +215,7 @@ var _ = Describe("ClusterClient", func() {
215215
216216 Eventually (func () string {
217217 return client .Get ("A" ).Val ()
218- }).Should (Equal ("VALUE" ))
218+ }, 30 * time . Second ).Should (Equal ("VALUE" ))
219219 })
220220
221221 It ("distributes keys" , func () {
@@ -227,7 +227,7 @@ var _ = Describe("ClusterClient", func() {
227227 for _ , master := range cluster .masters () {
228228 Eventually (func () string {
229229 return master .Info ("keyspace" ).Val ()
230- }, 5 * time .Second ).Should (Or (
230+ }, 30 * time .Second ).Should (Or (
231231 ContainSubstring ("keys=31" ),
232232 ContainSubstring ("keys=29" ),
233233 ContainSubstring ("keys=40" ),
@@ -251,7 +251,7 @@ var _ = Describe("ClusterClient", func() {
251251 for _ , master := range cluster .masters () {
252252 Eventually (func () string {
253253 return master .Info ("keyspace" ).Val ()
254- }, 5 * time .Second ).Should (Or (
254+ }, 30 * time .Second ).Should (Or (
255255 ContainSubstring ("keys=31" ),
256256 ContainSubstring ("keys=29" ),
257257 ContainSubstring ("keys=40" ),
@@ -320,10 +320,6 @@ var _ = Describe("ClusterClient", func() {
320320 Expect (err ).NotTo (HaveOccurred ())
321321 Expect (cmds ).To (HaveLen (14 ))
322322
323- if opt .RouteByLatency {
324- return
325- }
326-
327323 for _ , key := range keys {
328324 slot := hashtag .Slot (key )
329325 client .SwapSlotNodes (slot )
@@ -432,6 +428,9 @@ var _ = Describe("ClusterClient", func() {
432428 })
433429
434430 AfterEach (func () {
431+ _ = client .ForEachMaster (func (master * redis.Client ) error {
432+ return master .FlushDB ().Err ()
433+ })
435434 Expect (client .Close ()).NotTo (HaveOccurred ())
436435 })
437436
@@ -560,6 +559,9 @@ var _ = Describe("ClusterClient", func() {
560559 })
561560
562561 AfterEach (func () {
562+ _ = client .ForEachMaster (func (master * redis.Client ) error {
563+ return master .FlushDB ().Err ()
564+ })
563565 Expect (client .Close ()).NotTo (HaveOccurred ())
564566 })
565567
@@ -575,10 +577,19 @@ var _ = Describe("ClusterClient", func() {
575577 _ = client .ForEachMaster (func (master * redis.Client ) error {
576578 return master .FlushDB ().Err ()
577579 })
580+
581+ _ = client .ForEachSlave (func (slave * redis.Client ) error {
582+ Eventually (func () int64 {
583+ return client .DBSize ().Val ()
584+ }, 30 * time .Second ).Should (Equal (int64 (0 )))
585+ return nil
586+ })
578587 })
579588
580589 AfterEach (func () {
581- client .FlushDB ()
590+ _ = client .ForEachMaster (func (master * redis.Client ) error {
591+ return master .FlushDB ().Err ()
592+ })
582593 Expect (client .Close ()).NotTo (HaveOccurred ())
583594 })
584595
@@ -597,7 +608,7 @@ var _ = Describe("ClusterClient without nodes", func() {
597608 Expect (client .Close ()).NotTo (HaveOccurred ())
598609 })
599610
600- It ("returns an error" , func () {
611+ It ("Ping returns an error" , func () {
601612 err := client .Ping ().Err ()
602613 Expect (err ).To (MatchError ("redis: cluster has no nodes" ))
603614 })
@@ -626,15 +637,15 @@ var _ = Describe("ClusterClient without valid nodes", func() {
626637
627638 It ("returns an error" , func () {
628639 err := client .Ping ().Err ()
629- Expect (err ).To (MatchError ("ERR This instance has cluster support disabled " ))
640+ Expect (err ).To (MatchError ("redis: cannot load cluster slots " ))
630641 })
631642
632643 It ("pipeline returns an error" , func () {
633644 _ , err := client .Pipelined (func (pipe redis.Pipeliner ) error {
634645 pipe .Ping ()
635646 return nil
636647 })
637- Expect (err ).To (MatchError ("ERR This instance has cluster support disabled " ))
648+ Expect (err ).To (MatchError ("redis: cannot load cluster slots " ))
638649 })
639650})
640651
@@ -664,7 +675,7 @@ var _ = Describe("ClusterClient timeout", func() {
664675 It ("Tx timeouts" , func () {
665676 err := client .Watch (func (tx * redis.Tx ) error {
666677 return tx .Ping ().Err ()
667- })
678+ }, "foo" )
668679 Expect (err ).To (HaveOccurred ())
669680 Expect (err .(net.Error ).Timeout ()).To (BeTrue ())
670681 })
@@ -676,42 +687,20 @@ var _ = Describe("ClusterClient timeout", func() {
676687 return nil
677688 })
678689 return err
679- })
690+ }, "foo" )
680691 Expect (err ).To (HaveOccurred ())
681692 Expect (err .(net.Error ).Timeout ()).To (BeTrue ())
682693 })
683694 }
684695
685- Context ("read timeout" , func () {
686- BeforeEach (func () {
687- opt := redisClusterOptions ()
688- opt .ReadTimeout = time .Nanosecond
689- opt .WriteTimeout = - 1
690- client = cluster .clusterClient (opt )
691- })
692-
693- testTimeout ()
694- })
696+ const pause = time .Second
695697
696- Context ("write timeout" , func () {
698+ Context ("read/ write timeout" , func () {
697699 BeforeEach (func () {
698700 opt := redisClusterOptions ()
699- opt .ReadTimeout = time .Nanosecond
700- opt .WriteTimeout = - 1
701- client = cluster .clusterClient (opt )
702- })
703-
704- testTimeout ()
705- })
706-
707- Context ("ClientPause timeout" , func () {
708- const pause = time .Second
709-
710- BeforeEach (func () {
711- opt := redisClusterOptions ()
712- opt .ReadTimeout = pause / 10
713- opt .WriteTimeout = pause / 10
714- opt .MaxRedirects = - 1
701+ opt .ReadTimeout = 100 * time .Millisecond
702+ opt .WriteTimeout = 100 * time .Millisecond
703+ opt .MaxRedirects = 1
715704 client = cluster .clusterClient (opt )
716705
717706 err := client .ForEachNode (func (client * redis.Client ) error {
0 commit comments