diff --git a/Makefile b/Makefile index 9fedcd6..5bee253 100644 --- a/Makefile +++ b/Makefile @@ -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 - diff --git a/src/redis-shake/checkpoint/checkpoint_test.go b/src/redis-shake/checkpoint/checkpoint_test.go index 76a0e25..0297fef 100644 --- a/src/redis-shake/checkpoint/checkpoint_test.go +++ b/src/redis-shake/checkpoint/checkpoint_test.go @@ -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" ) diff --git a/src/redis-shake/common/utils.go b/src/redis-shake/common/utils.go index 62f4a1d..d9bbbb3 100644 --- a/src/redis-shake/common/utils.go +++ b/src/redis-shake/common/utils.go @@ -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 diff --git a/src/redis-shake/common/utils_test.go b/src/redis-shake/common/utils_test.go index d3c3aad..052e943 100644 --- a/src/redis-shake/common/utils_test.go +++ b/src/redis-shake/common/utils_test.go @@ -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" ) diff --git a/src/redis-shake/main/sanitize.go b/src/redis-shake/main/sanitize.go index 8530656..0edddf3 100644 --- a/src/redis-shake/main/sanitize.go +++ b/src/redis-shake/main/sanitize.go @@ -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) } diff --git a/src/redis-shake/restore.go b/src/redis-shake/restore.go index 2c0cb8b..01e5ee8 100644 --- a/src/redis-shake/restore.go +++ b/src/redis-shake/restore.go @@ -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 { diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..f924f9c --- /dev/null +++ b/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd src + +PKGS=$(go list ./... | grep -v /vendor/) +go test $PKGS