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:
25
race_test.go
25
race_test.go
@@ -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 {
|
||||
|
Reference in New Issue
Block a user