Enable race tests.

This commit is contained in:
Vladimir Mihailenco 2014-11-18 12:11:06 +02:00
parent 9778c1acf5
commit 20c738a103
3 changed files with 16 additions and 8 deletions

View File

@ -1,2 +1,3 @@
all: all:
go test gopkg.in/redis.v2 -cpu=1,2,4 go test gopkg.in/redis.v2 -cpu=1,2,4
go test gopkg.in/redis.v2 -short -race

View File

@ -7,8 +7,11 @@ import (
) )
func TestRateLimiter(t *testing.T) { func TestRateLimiter(t *testing.T) {
const n = 100000 var n = 100000
rl := newRateLimiter(time.Second, n) if testing.Short() {
n = 1000
}
rl := newRateLimiter(time.Minute, n)
wg := &sync.WaitGroup{} wg := &sync.WaitGroup{}
for i := 0; i < n; i++ { for i := 0; i < n; i++ {

View File

@ -392,17 +392,21 @@ func (t *RedisTest) TestGetBigVal(c *C) {
} }
func (t *RedisTest) TestManyKeys(c *C) { func (t *RedisTest) TestManyKeys(c *C) {
for i := 0; i < 100000; i++ { var n = 100000
for i := 0; i < n; i++ {
t.client.Set("keys.key"+strconv.Itoa(i), "hello"+strconv.Itoa(i)) t.client.Set("keys.key"+strconv.Itoa(i), "hello"+strconv.Itoa(i))
} }
keys := t.client.Keys("keys.*") keys := t.client.Keys("keys.*")
c.Assert(keys.Err(), IsNil) c.Assert(keys.Err(), IsNil)
c.Assert(len(keys.Val()), Equals, 100000) c.Assert(len(keys.Val()), Equals, n)
} }
func (t *RedisTest) TestManyKeys2(c *C) { func (t *RedisTest) TestManyKeys2(c *C) {
var n = 100000
keys := []string{"non-existent-key"} keys := []string{"non-existent-key"}
for i := 0; i < 100000; i++ { for i := 0; i < n; i++ {
key := "keys.key" + strconv.Itoa(i) key := "keys.key" + strconv.Itoa(i)
t.client.Set(key, "hello"+strconv.Itoa(i)) t.client.Set(key, "hello"+strconv.Itoa(i))
keys = append(keys, key) keys = append(keys, key)
@ -411,13 +415,13 @@ func (t *RedisTest) TestManyKeys2(c *C) {
mget := t.client.MGet(keys...) mget := t.client.MGet(keys...)
c.Assert(mget.Err(), IsNil) c.Assert(mget.Err(), IsNil)
c.Assert(len(mget.Val()), Equals, 100002) c.Assert(len(mget.Val()), Equals, n+2)
vals := mget.Val() vals := mget.Val()
for i := 0; i < 100000; i++ { for i := 0; i < n; i++ {
c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i)) c.Assert(vals[i+1], Equals, "hello"+strconv.Itoa(i))
} }
c.Assert(vals[0], Equals, nil) c.Assert(vals[0], Equals, nil)
c.Assert(vals[100001], Equals, nil) c.Assert(vals[n+1], Equals, nil)
} }
func (t *RedisTest) TestStringCmdHelpers(c *C) { func (t *RedisTest) TestStringCmdHelpers(c *C) {