diff --git a/universal.go b/universal.go index 47fda2769..6cfec8234 100644 --- a/universal.go +++ b/universal.go @@ -160,6 +160,8 @@ func (o *UniversalOptions) Failover() *FailoverOptions { TLSConfig: o.TLSConfig, + ReplicaOnly: o.ReadOnly, + DisableIndentity: o.DisableIndentity, IdentitySuffix: o.IdentitySuffix, UnstableResp3: o.UnstableResp3, diff --git a/universal_test.go b/universal_test.go index 9328b4776..8a7e643ee 100644 --- a/universal_test.go +++ b/universal_test.go @@ -60,4 +60,32 @@ var _ = Describe("UniversalClient", func() { a := func() { client.FTInfo(ctx, "all").Result() } Expect(a).ToNot(Panic()) }) + + + It("should connect to failover servers on slaves when readonly Options is ok", func() { + Skip("Flaky Test") + client = redis.NewUniversalClient(&redis.UniversalOptions{ + MasterName: sentinelName, + Addrs: sentinelAddrs, + ReadOnly: true, + }) + Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred()) + + + roleCmd := client.Do(ctx, "ROLE") + role, err := roleCmd.Result() + Expect(err).NotTo(HaveOccurred()) + + roleSlice, ok := role.([]interface{}) + Expect(ok).To(BeTrue()) + Expect(roleSlice[0]).To(Equal("slave")) + + + err = client.Set(ctx, "somekey", "somevalue", 0).Err() + Expect(err).To(HaveOccurred()) + + }) + + }) +