1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

feat: Add support for CLUSTER SHARDS command (#2507)

* feat: Adding support for CLUSTER SHARDS command

Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com>
This commit is contained in:
Anurag Bandyopadhyay
2023-03-29 19:14:06 +05:30
committed by GitHub
parent 2cdd5ea34a
commit 9aba95a74f
3 changed files with 188 additions and 0 deletions

View File

@ -677,6 +677,37 @@ var _ = Describe("ClusterClient", func() {
Expect(assertSlotsEqual(res, wanted)).NotTo(HaveOccurred())
})
It("should CLUSTER SHARDS", func() {
res, err := client.ClusterShards(ctx).Result()
Expect(err).NotTo(HaveOccurred())
Expect(res).NotTo(BeEmpty())
// Iterate over the ClusterShard results and validate the fields.
for _, shard := range res {
Expect(shard.Slots).NotTo(BeEmpty())
for _, slotRange := range shard.Slots {
Expect(slotRange.Start).To(BeNumerically(">=", 0))
Expect(slotRange.End).To(BeNumerically(">=", slotRange.Start))
}
Expect(shard.Nodes).NotTo(BeEmpty())
for _, node := range shard.Nodes {
Expect(node.ID).NotTo(BeEmpty())
Expect(node.Endpoint).NotTo(BeEmpty())
Expect(node.IP).NotTo(BeEmpty())
Expect(node.Port).To(BeNumerically(">", 0))
validRoles := []string{"master", "slave", "replica"}
Expect(validRoles).To(ContainElement(node.Role))
Expect(node.ReplicationOffset).To(BeNumerically(">=", 0))
validHealthStatuses := []string{"online", "failed", "loading"}
Expect(validHealthStatuses).To(ContainElement(node.Health))
}
}
})
It("should CLUSTER LINKS", func() {
res, err := client.ClusterLinks(ctx).Result()
Expect(err).NotTo(HaveOccurred())