mirror of https://github.com/go-redis/redis.git
Enable race tests.
This commit is contained in:
parent
9778c1acf5
commit
20c738a103
1
Makefile
1
Makefile
|
@ -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
|
||||||
|
|
|
@ -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++ {
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue