mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
add readOnly on failover opts (#3281)
* add readOnly on failover opts add failover that if is True it connects to slaves * add test * add test for slave connect * fix test * fix tests * skip Flaky * add more tests on slave * add test * delete file * Update universal_test.go enable previously skipped test. * rm skip from sentinels * rm tmp files * Update universal_test.go don't run sentinel test in RE * Update universal_test.go --------- Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
This commit is contained in:
parent
162a15432b
commit
8fadbef84a
@ -163,6 +163,8 @@ func (o *UniversalOptions) Failover() *FailoverOptions {
|
||||
|
||||
TLSConfig: o.TLSConfig,
|
||||
|
||||
ReplicaOnly: o.ReadOnly,
|
||||
|
||||
DisableIndentity: o.DisableIndentity,
|
||||
IdentitySuffix: o.IdentitySuffix,
|
||||
UnstableResp3: o.UnstableResp3,
|
||||
|
@ -60,6 +60,25 @@ var _ = Describe("UniversalClient", func() {
|
||||
Expect(a).ToNot(Panic())
|
||||
})
|
||||
|
||||
It("should connect to failover servers on slaves when readonly Options is ok", Label("NonRedisEnterprise"), func() {
|
||||
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())
|
||||
})
|
||||
It("should connect to clusters if IsClusterMode is set even if only a single address is provided", Label("NonRedisEnterprise"), func() {
|
||||
client = redis.NewUniversalClient(&redis.UniversalOptions{
|
||||
Addrs: []string{cluster.addrs()[0]},
|
||||
@ -77,3 +96,4 @@ var _ = Describe("UniversalClient", func() {
|
||||
Expect(client.ClusterSlots(ctx).Val()).To(HaveLen(3))
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user