Skip to content

Commit 9bc4ace

Browse files
committed
reset redis client when redis node updated
1 parent 5a3b191 commit 9bc4ace

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

test/e2e/drc/drc_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,30 @@ var _ = Describe("DistributedRedisCluster CRUD", func() {
3939
e2e.DeleteMasterPodForDRC(drc, f.Client)
4040
Eventually(e2e.IsDRCPodBeDeleted(f, drc), "5m", "10s").ShouldNot(HaveOccurred())
4141
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
42+
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
4243
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
4344
})
4445
It("should scale up a DistributedRedisCluster", func() {
4546
e2e.ScaleUPDRC(drc)
4647
Ω(f.UpdateRedisCluster(drc)).Should(Succeed())
4748
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
49+
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
4850
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
4951
})
5052
Context("when the scale up succeeded", func() {
5153
It("should scale down a DistributedRedisCluster", func() {
5254
e2e.ScaleUPDown(drc)
5355
Ω(f.UpdateRedisCluster(drc)).Should(Succeed())
5456
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
57+
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
5558
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
5659
})
5760
})
5861
It("should update the DistributedRedisCluster minor version", func() {
5962
e2e.RollingUpdateDRC(drc)
6063
Ω(f.UpdateRedisCluster(drc)).Should(Succeed())
6164
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
65+
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
6266
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
6367
})
6468
})

test/e2e/drcb/drcb_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,30 @@ var _ = Describe("Restore DistributedRedisCluster From RedisClusterBackup", func
6262
e2e.DeleteMasterPodForDRC(rdrc, f.Client)
6363
Eventually(e2e.IsDRCPodBeDeleted(f, rdrc), "5m", "10s").ShouldNot(HaveOccurred())
6464
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
65+
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
6566
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
6667
})
6768
It("should scale up a DistributedRedisCluster", func() {
6869
e2e.ScaleUPDRC(rdrc)
6970
Ω(f.UpdateRedisCluster(rdrc)).Should(Succeed())
7071
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
72+
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
7173
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
7274
})
7375
Context("when the scale up succeeded", func() {
7476
It("should scale down a DistributedRedisCluster", func() {
7577
e2e.ScaleUPDown(rdrc)
7678
Ω(f.UpdateRedisCluster(rdrc)).Should(Succeed())
7779
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
80+
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
7881
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
7982
})
8083
})
8184
It("should update the DistributedRedisCluster minor version", func() {
8285
e2e.RollingUpdateDRC(rdrc)
8386
Ω(f.UpdateRedisCluster(rdrc)).Should(Succeed())
8487
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
88+
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
8589
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
8690
})
8791
})

test/e2e/goredis_util.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ type GoRedis struct {
1919
func NewGoRedis(addr, password string) *GoRedis {
2020
return &GoRedis{
2121
client: redis.NewClusterClient(&redis.ClusterOptions{
22-
Addrs: []string{addr},
23-
Password: password,
24-
MaxRetries: 5,
25-
26-
PoolSize: 3,
27-
MinIdleConns: 1,
28-
PoolTimeout: defaultTimeOut,
29-
IdleTimeout: defaultTimeOut,
22+
Addrs: []string{addr},
23+
Password: password,
24+
//MaxRetries: 5,
25+
//
26+
//PoolSize: 3,
27+
//MinIdleConns: 1,
28+
//PoolTimeout: defaultTimeOut,
29+
//IdleTimeout: defaultTimeOut,
3030
}),
3131
password: password,
3232
}
@@ -61,3 +61,8 @@ func (g *GoRedis) DBSize() (int64, error) {
6161
func (g *GoRedis) Password() string {
6262
return g.password
6363
}
64+
65+
// Close closes the cluster client.
66+
func (g *GoRedis) Close() error {
67+
return g.client.Close()
68+
}

0 commit comments

Comments
 (0)