Skip to content

Commit 3f78c72

Browse files
committed
fix(txpipeline): test normal tx pipeline behaviour
1 parent ef6e27a commit 3f78c72

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

osscluster_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ var _ = Describe("ClusterClient", func() {
462462
Describe("pipelining", func() {
463463
var pipe *redis.Pipeline
464464

465-
assertPipeline := func() {
466-
keys := []string{"A", "B", "C", "D", "E", "F", "G"}
465+
assertPipeline := func(keys []string) {
467466

468467
It("follows redirects", func() {
469468
if !failover {
@@ -517,14 +516,14 @@ var _ = Describe("ClusterClient", func() {
517516
})
518517

519518
It("works with missing keys", func() {
520-
pipe.Set(ctx, "A", "A_value", 0)
521-
pipe.Set(ctx, "C", "C_value", 0)
519+
pipe.Set(ctx, "A{s}", "A_value", 0)
520+
pipe.Set(ctx, "C{s}", "C_value", 0)
522521
_, err := pipe.Exec(ctx)
523522
Expect(err).NotTo(HaveOccurred())
524523

525-
a := pipe.Get(ctx, "A")
526-
b := pipe.Get(ctx, "B")
527-
c := pipe.Get(ctx, "C")
524+
a := pipe.Get(ctx, "A{s}")
525+
b := pipe.Get(ctx, "B{s}")
526+
c := pipe.Get(ctx, "C{s}")
528527
cmds, err := pipe.Exec(ctx)
529528
Expect(err).To(Equal(redis.Nil))
530529
Expect(cmds).To(HaveLen(3))
@@ -547,7 +546,8 @@ var _ = Describe("ClusterClient", func() {
547546

548547
AfterEach(func() {})
549548

550-
assertPipeline()
549+
keys := []string{"A", "B", "C", "D", "E", "F", "G"}
550+
assertPipeline(keys)
551551

552552
It("doesn't fail node with context.Canceled error", func() {
553553
ctx, cancel := context.WithCancel(context.Background())
@@ -590,7 +590,10 @@ var _ = Describe("ClusterClient", func() {
590590

591591
AfterEach(func() {})
592592

593-
assertPipeline()
593+
// TxPipeline doesn't support cross slot commands.
594+
// Use hashtag to force all keys to the same slot.
595+
keys := []string{"A{s}", "B{s}", "C{s}", "D{s}", "E{s}", "F{s}", "G{s}"}
596+
assertPipeline(keys)
594597
})
595598
})
596599

0 commit comments

Comments
 (0)