fix: fixed some testcases issues. (#388)

v4
Jacky Wu 3 years ago committed by GitHub
parent 7b3038c0f3
commit 92d0ad5b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      Makefile
  2. 4
      src/redis-shake/checkpoint/checkpoint_test.go
  3. 10
      src/redis-shake/common/utils.go
  4. 3
      src/redis-shake/common/utils_test.go
  5. 6
      src/redis-shake/main/sanitize.go
  6. 6
      src/redis-shake/restore.go
  7. 6
      test.sh

@ -1,4 +1,10 @@
all:
all:
build test
test:
./test.sh
build:
./build.sh
clean:
@ -8,4 +14,3 @@ clean:
rm -rf logs
rm -rf diagnostic/
rm -rf *.pid

@ -4,8 +4,8 @@ import (
"fmt"
"testing"
"redis-shake/common"
"redis-shake/unit_test_common"
utils "github.com/alibaba/RedisShake/redis-shake/common"
"github.com/alibaba/RedisShake/redis-shake/unit_test_common"
"github.com/stretchr/testify/assert"
)

@ -807,7 +807,7 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) {
}
_, err := Int64(c.Do("del", e.Key))
if err != nil {
log.Panicf("del ", string(e.Key), err)
log.Panicf("del %s error (%v)", string(e.Key), err)
}
case "ignore":
log.Warnf("target key name is busy but ignore: %v", string(e.Key))
@ -819,7 +819,7 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) {
if e.ExpireAt != 0 {
r, err := Int64(c.Do("pexpire", e.Key, ttlms))
if err != nil && r != 1 {
log.Panicf("expire ", string(e.Key), err)
log.Panicf("expire %s error (%v)", string(e.Key), err)
}
}
return
@ -843,11 +843,11 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) {
//use command
if conf.Options.KeyExists == "rewrite" && e.NeedReadLen == 1 {
if !conf.Options.Metric {
log.Infof("warning, rewrite big key:", string(e.Key))
log.Infof("warning, rewrite big key: %s", string(e.Key))
}
_, err := Int64(c.Do("del", e.Key))
if err != nil {
log.Panicf("del ", string(e.Key), err)
log.Panicf("del %s error (%v)", string(e.Key), err)
}
}
@ -858,7 +858,7 @@ func RestoreRdbEntry(c redigo.Conn, e *rdb.BinEntry) {
if e.ExpireAt != 0 {
r, err := Int64(c.Do("pexpire", e.Key, ttlms))
if err != nil && r != 1 {
log.Panicf("expire ", string(e.Key), err)
log.Panicf("expire %s error (%v)", string(e.Key), err)
}
}
return

@ -1,3 +1,4 @@
//go:build integration && (linux || darwin || windows)
// +build integration
// +build linux darwin windows
@ -7,7 +8,7 @@ import (
"fmt"
"testing"
"redis-shake/unit_test_common"
"github.com/alibaba/RedisShake/redis-shake/unit_test_common"
"github.com/stretchr/testify/assert"
)

@ -10,8 +10,8 @@ import (
"time"
"github.com/alibaba/RedisShake/pkg/libs/log"
"github.com/alibaba/RedisShake/redis-shake/common"
"github.com/alibaba/RedisShake/redis-shake/configure"
utils "github.com/alibaba/RedisShake/redis-shake/common"
conf "github.com/alibaba/RedisShake/redis-shake/configure"
logRotate "gopkg.in/natefinch/lumberjack.v2"
)
@ -332,7 +332,7 @@ func SanitizeOptions(tp string) error {
* set 1 if target is target version can't be fetched just like twemproxy.
*/
conf.Options.BigKeyThreshold = 1
log.Warnf("target version[%v] given, set big_key_threshold = 1. see #173",
log.Warnf("target version[%v] given [%v], set big_key_threshold = 1. see #173",
conf.Options.TargetVersion, conf.Options.SourceVersion)
}

@ -17,8 +17,8 @@ import (
"github.com/alibaba/RedisShake/pkg/redis"
"github.com/alibaba/RedisShake/redis-shake/base"
"github.com/alibaba/RedisShake/redis-shake/common"
"github.com/alibaba/RedisShake/redis-shake/configure"
utils "github.com/alibaba/RedisShake/redis-shake/common"
conf "github.com/alibaba/RedisShake/redis-shake/configure"
"github.com/alibaba/RedisShake/redis-shake/filter"
)
@ -237,7 +237,7 @@ func (dr *dbRestorer) restoreCommand(reader *bufio.Reader, target []string, auth
for {
resp := redis.MustDecode(reader)
if scmd, args, err := redis.ParseArgs(resp); err != nil {
log.PanicError(err, "routine[%v] parse command arguments failed", dr.id)
log.PanicErrorf(err, "routine[%v] parse command arguments failed", dr.id)
} else if scmd != "ping" {
if scmd == "select" {
if len(args) != 1 {

@ -0,0 +1,6 @@
#!/bin/bash
cd src
PKGS=$(go list ./... | grep -v /vendor/)
go test $PKGS
Loading…
Cancel
Save