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

Add race test for BLPop

This commit is contained in:
Vladimir Mihailenco
2018-03-08 10:16:53 +02:00
parent 9133634a13
commit 11ca0e65c6
3 changed files with 33 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net"
"strconv"
"sync/atomic"
"testing"
"time"
@@ -258,6 +259,30 @@ var _ = Describe("races", func() {
Expect(err).NotTo(HaveOccurred())
Expect(n).To(Equal(int64(N)))
})
It("should BLPop", func() {
var received uint32
wg := performAsync(C, func(id int) {
for {
v, err := client.BLPop(3*time.Second, "list").Result()
if err != nil {
break
}
Expect(v).To(Equal([]string{"list", "hello"}))
atomic.AddUint32(&received, 1)
}
})
perform(C, func(id int) {
for i := 0; i < N; i++ {
err := client.LPush("list", "hello").Err()
Expect(err).NotTo(HaveOccurred())
}
})
wg.Wait()
Expect(received).To(Equal(uint32(C * N)))
})
})
func bigVal() []byte {