mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
fix(txpipeline): test normal tx pipeline behaviour
This commit is contained in:
@ -462,8 +462,7 @@ var _ = Describe("ClusterClient", func() {
|
|||||||
Describe("pipelining", func() {
|
Describe("pipelining", func() {
|
||||||
var pipe *redis.Pipeline
|
var pipe *redis.Pipeline
|
||||||
|
|
||||||
assertPipeline := func() {
|
assertPipeline := func(keys []string) {
|
||||||
keys := []string{"A", "B", "C", "D", "E", "F", "G"}
|
|
||||||
|
|
||||||
It("follows redirects", func() {
|
It("follows redirects", func() {
|
||||||
if !failover {
|
if !failover {
|
||||||
@ -482,13 +481,12 @@ var _ = Describe("ClusterClient", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(cmds).To(HaveLen(14))
|
Expect(cmds).To(HaveLen(14))
|
||||||
|
|
||||||
_ = client.ForEachShard(ctx, func(ctx context.Context, node *redis.Client) error {
|
// Check that all keys are set.
|
||||||
defer GinkgoRecover()
|
for _, key := range keys {
|
||||||
Eventually(func() int64 {
|
Eventually(func() string {
|
||||||
return node.DBSize(ctx).Val()
|
return client.Get(ctx, key).Val()
|
||||||
}, 30*time.Second).ShouldNot(BeZero())
|
}, 30*time.Second).Should(Equal(key + "_value"))
|
||||||
return nil
|
}
|
||||||
})
|
|
||||||
|
|
||||||
if !failover {
|
if !failover {
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
@ -517,14 +515,14 @@ var _ = Describe("ClusterClient", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("works with missing keys", func() {
|
It("works with missing keys", func() {
|
||||||
pipe.Set(ctx, "A", "A_value", 0)
|
pipe.Set(ctx, "A{s}", "A_value", 0)
|
||||||
pipe.Set(ctx, "C", "C_value", 0)
|
pipe.Set(ctx, "C{s}", "C_value", 0)
|
||||||
_, err := pipe.Exec(ctx)
|
_, err := pipe.Exec(ctx)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
a := pipe.Get(ctx, "A")
|
a := pipe.Get(ctx, "A{s}")
|
||||||
b := pipe.Get(ctx, "B")
|
b := pipe.Get(ctx, "B{s}")
|
||||||
c := pipe.Get(ctx, "C")
|
c := pipe.Get(ctx, "C{s}")
|
||||||
cmds, err := pipe.Exec(ctx)
|
cmds, err := pipe.Exec(ctx)
|
||||||
Expect(err).To(Equal(redis.Nil))
|
Expect(err).To(Equal(redis.Nil))
|
||||||
Expect(cmds).To(HaveLen(3))
|
Expect(cmds).To(HaveLen(3))
|
||||||
@ -547,7 +545,8 @@ var _ = Describe("ClusterClient", func() {
|
|||||||
|
|
||||||
AfterEach(func() {})
|
AfterEach(func() {})
|
||||||
|
|
||||||
assertPipeline()
|
keys := []string{"A", "B", "C", "D", "E", "F", "G"}
|
||||||
|
assertPipeline(keys)
|
||||||
|
|
||||||
It("doesn't fail node with context.Canceled error", func() {
|
It("doesn't fail node with context.Canceled error", func() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
@ -590,7 +589,10 @@ var _ = Describe("ClusterClient", func() {
|
|||||||
|
|
||||||
AfterEach(func() {})
|
AfterEach(func() {})
|
||||||
|
|
||||||
assertPipeline()
|
// TxPipeline doesn't support cross slot commands.
|
||||||
|
// Use hashtag to force all keys to the same slot.
|
||||||
|
keys := []string{"A{s}", "B{s}", "C{s}", "D{s}", "E{s}", "F{s}", "G{s}"}
|
||||||
|
assertPipeline(keys)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user