Add test for running commands from different goroutines.

This commit is contained in:
Vladimir Mihailenco 2012-07-29 13:02:45 +03:00
parent 2f284d75b8
commit 859c5fb03b
1 changed files with 25 additions and 1 deletions

View File

@ -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) {