Skip to content

Commit

Permalink
reset redis client when redis node updated
Browse files Browse the repository at this point in the history
  • Loading branch information
polefishu committed Mar 23, 2020
1 parent 5a3b191 commit 9bc4ace
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions test/e2e/drc/drc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,30 @@ var _ = Describe("DistributedRedisCluster CRUD", func() {
e2e.DeleteMasterPodForDRC(drc, f.Client)
Eventually(e2e.IsDRCPodBeDeleted(f, drc), "5m", "10s").ShouldNot(HaveOccurred())
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
It("should scale up a DistributedRedisCluster", func() {
e2e.ScaleUPDRC(drc)
Ω(f.UpdateRedisCluster(drc)).Should(Succeed())
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
Context("when the scale up succeeded", func() {
It("should scale down a DistributedRedisCluster", func() {
e2e.ScaleUPDown(drc)
Ω(f.UpdateRedisCluster(drc)).Should(Succeed())
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
})
It("should update the DistributedRedisCluster minor version", func() {
e2e.RollingUpdateDRC(drc)
Ω(f.UpdateRedisCluster(drc)).Should(Succeed())
Eventually(e2e.IsDistributedRedisClusterProperly(f, drc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(drc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
})
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/drcb/drcb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,30 @@ var _ = Describe("Restore DistributedRedisCluster From RedisClusterBackup", func
e2e.DeleteMasterPodForDRC(rdrc, f.Client)
Eventually(e2e.IsDRCPodBeDeleted(f, rdrc), "5m", "10s").ShouldNot(HaveOccurred())
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
It("should scale up a DistributedRedisCluster", func() {
e2e.ScaleUPDRC(rdrc)
Ω(f.UpdateRedisCluster(rdrc)).Should(Succeed())
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
Context("when the scale up succeeded", func() {
It("should scale down a DistributedRedisCluster", func() {
e2e.ScaleUPDown(rdrc)
Ω(f.UpdateRedisCluster(rdrc)).Should(Succeed())
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
})
It("should update the DistributedRedisCluster minor version", func() {
e2e.RollingUpdateDRC(rdrc)
Ω(f.UpdateRedisCluster(rdrc)).Should(Succeed())
Eventually(e2e.IsDistributedRedisClusterProperly(f, rdrc), "10m", "10s").ShouldNot(HaveOccurred())
goredis = e2e.NewGoRedisClient(rdrc.Name, f.Namespace(), goredis.Password())
Expect(e2e.IsDBSizeConsistent(dbsize, goredis)).NotTo(HaveOccurred())
})
})
Expand Down
21 changes: 13 additions & 8 deletions test/e2e/goredis_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ type GoRedis struct {
func NewGoRedis(addr, password string) *GoRedis {
return &GoRedis{
client: redis.NewClusterClient(&redis.ClusterOptions{
Addrs: []string{addr},
Password: password,
MaxRetries: 5,

PoolSize: 3,
MinIdleConns: 1,
PoolTimeout: defaultTimeOut,
IdleTimeout: defaultTimeOut,
Addrs: []string{addr},
Password: password,
//MaxRetries: 5,
//
//PoolSize: 3,
//MinIdleConns: 1,
//PoolTimeout: defaultTimeOut,
//IdleTimeout: defaultTimeOut,
}),
password: password,
}
Expand Down Expand Up @@ -61,3 +61,8 @@ func (g *GoRedis) DBSize() (int64, error) {
func (g *GoRedis) Password() string {
return g.password
}

// Close closes the cluster client.
func (g *GoRedis) Close() error {
return g.client.Close()
}

0 comments on commit 9bc4ace

Please sign in to comment.