forked from mirror/redis
Add test for running commands from different goroutines.
This commit is contained in:
parent
2f284d75b8
commit
859c5fb03b
|
@ -1426,7 +1426,7 @@ func (t *RedisTest) TestExecOnEmptyQueue(c *C) {
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (t *RedisTest) TestConcAccess(c *C) {
|
||||
func (t *RedisTest) TestRunningCommandsFromDifferentGoroutines(c *C) {
|
||||
for i := int64(0); i < 99; i++ {
|
||||
go func() {
|
||||
msg := "echo" + strconv.FormatInt(i, 10)
|
||||
|
@ -1437,6 +1437,30 @@ func (t *RedisTest) TestConcAccess(c *C) {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *RedisTest) TestPipeliningFromDifferentGoroutines(c *C) {
|
||||
for i := int64(0); i < 99; i += 2 {
|
||||
go func() {
|
||||
msg1 := "echo" + strconv.FormatInt(i, 10)
|
||||
msg2 := "echo" + strconv.FormatInt(i+1, 10)
|
||||
|
||||
echo1Req := t.redisC.Echo(msg1)
|
||||
echo2Req := t.redisC.Echo(msg2)
|
||||
|
||||
reqs, err := t.redisC.RunQueued()
|
||||
c.Check(reqs, HasLen, 2)
|
||||
c.Check(err, IsNil)
|
||||
|
||||
echo1, err := echo1Req.Reply()
|
||||
c.Check(err, IsNil)
|
||||
c.Check(echo1, Equals, msg1)
|
||||
|
||||
echo2, err := echo2Req.Reply()
|
||||
c.Check(err, IsNil)
|
||||
c.Check(echo2, Equals, msg2)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
func (t *RedisTest) BenchmarkRedisPing(c *C) {
|
||||
|
|
Loading…
Reference in New Issue