@@ -653,6 +653,32 @@ var _ = Describe("ClusterClient", func() {
653653 Expect (client .Close ()).NotTo (HaveOccurred ())
654654 })
655655
656+ It ("follows node redirection immediately" , func () {
657+ // Configure retry backoffs far in excess of the expected duration of redirection
658+ opt := redisClusterOptions ()
659+ opt .MinRetryBackoff = 10 * time .Minute
660+ opt .MaxRetryBackoff = 20 * time .Minute
661+ client := cluster .newClusterClient (ctx , opt )
662+
663+ Eventually (func () error {
664+ return client .SwapNodes (ctx , "A" )
665+ }, 30 * time .Second ).ShouldNot (HaveOccurred ())
666+
667+ // Note that this context sets a deadline more aggressive than the lowest possible bound
668+ // of the retry backoff; this verifies that redirection completes immediately.
669+ redirCtx , cancel := context .WithTimeout (ctx , 5 * time .Second )
670+ defer cancel ()
671+
672+ err := client .Set (redirCtx , "A" , "VALUE" , 0 ).Err ()
673+ Expect (err ).NotTo (HaveOccurred ())
674+
675+ v , err := client .Get (redirCtx , "A" ).Result ()
676+ Expect (err ).NotTo (HaveOccurred ())
677+ Expect (v ).To (Equal ("VALUE" ))
678+
679+ Expect (client .Close ()).NotTo (HaveOccurred ())
680+ })
681+
656682 It ("calls fn for every master node" , func () {
657683 for i := 0 ; i < 10 ; i ++ {
658684 Expect (client .Set (ctx , strconv .Itoa (i ), "" , 0 ).Err ()).NotTo (HaveOccurred ())
0 commit comments