mirror of https://github.com/go-redis/redis.git
Merge pull request #126 from go-redis/fix/ring-pipeline-tests
ring: improve pipelining tests.
This commit is contained in:
commit
a43e6ec46d
16
ring_test.go
16
ring_test.go
|
@ -82,7 +82,8 @@ var _ = Describe("Redis ring", func() {
|
||||||
Expect(ringShard2.Info().Val()).To(ContainSubstring("keys=43"))
|
Expect(ringShard2.Info().Val()).To(ContainSubstring("keys=43"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("supports pipelining", func() {
|
Describe("pipelining", func() {
|
||||||
|
It("uses both shards", func() {
|
||||||
pipe := ring.Pipeline()
|
pipe := ring.Pipeline()
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
err := pipe.Set(fmt.Sprintf("key%d", i), "value", 0).Err()
|
err := pipe.Set(fmt.Sprintf("key%d", i), "value", 0).Err()
|
||||||
|
@ -102,4 +103,17 @@ var _ = Describe("Redis ring", func() {
|
||||||
Expect(ringShard1.Info().Val()).To(ContainSubstring("keys=57"))
|
Expect(ringShard1.Info().Val()).To(ContainSubstring("keys=57"))
|
||||||
Expect(ringShard2.Info().Val()).To(ContainSubstring("keys=43"))
|
Expect(ringShard2.Info().Val()).To(ContainSubstring("keys=43"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("is consistent", func() {
|
||||||
|
_, err := ring.Pipelined(func(pipe *redis.RingPipeline) error {
|
||||||
|
pipe.Set("mykey", "pipeline", 0)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
val, err := ring.Get("mykey").Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(val).To(Equal("pipeline"))
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue