Score
0
Watch 16 Star 50 Fork 2

piaohao / godisGoMIT

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
godis 是一个 golang 实现的 redis 客户端,参考 jedis 实现。godis 实现了几乎所有的 redis 命令,包括单机命令,集群命令,管道命令和事物命令等 spread retract

Clone or download
cluster_test.go 35.48 KB
Copy Edit Web IDE Raw Blame History
piaohao authored 2019-07-03 18:42 . 1.add more args of poolconfig;
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428
package godis
import (
"fmt"
"github.com/stretchr/testify/assert"
"sync"
"testing"
"time"
)
var clusterOption = &ClusterOption{
Nodes: []string{"localhost:7000", "localhost:7001", "localhost:7002", "localhost:7003", "localhost:7004", "localhost:7005"},
ConnectionTimeout: 5 * time.Second,
SoTimeout: 5 * time.Second,
MaxAttempts: 0,
Password: "",
PoolConfig: &PoolConfig{
MaxTotal: 100,
},
}
func clearKeys(cluster *RedisCluster) {
for _, k := range []string{"godis", "godis1", "godis2", "godis3", "godis4", "godis5"} {
cluster.Del(k)
}
}
func TestRedisCluster_Append(t *testing.T) {
cluster := NewRedisCluster(clusterOption)
clearKeys(cluster)
count, err := cluster.Append("godis", "good")
assert.Nil(t, err)
assert.Equal(t, int64(4), count)
}
func TestRedisCluster_Bitcount(t *testing.T) {
cluster := NewRedisCluster(clusterOption)
cluster.Set("godis", "good")
count, err := cluster.BitCount("godis")
assert.Nil(t, err)
assert.Equal(t, int64(20), count)
}
func TestRedisCluster_BitcountRange(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.BitCountRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, int64(20), s)
}
func TestRedisCluster_Bitfield(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
_, err := redis.BitField("godis", "INCRBY")
assert.NotNil(t, err)
}
func TestRedisCluster_Bitop(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Del("bit-1")
redis.Del("bit-2")
redis.Del("and-result")
b, e := redis.SetBit("bit-1", 0, "1")
assert.Nil(t, e)
assert.Equal(t, false, b)
b, e = redis.SetBit("bit-1", 3, "1")
assert.Nil(t, e)
assert.Equal(t, false, b)
b, e = redis.SetBit("bit-2", 0, "1")
assert.Nil(t, e)
assert.Equal(t, false, b)
b, e = redis.SetBit("bit-2", 1, "1")
assert.Nil(t, e)
assert.Equal(t, false, b)
b, e = redis.SetBit("bit-2", 3, "1")
assert.Nil(t, e)
assert.Equal(t, false, b)
i, e := redis.BitOp(*BitOpAnd, "c", "bit-1", "bit-2")
assert.NotNil(t, e)
assert.Equal(t, int64(0), i)
b, e = redis.GetBit("and-result", 0)
assert.Nil(t, e)
assert.Equal(t, false, b)
}
func TestRedisCluster_Bitpos(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "\x00\xff\xf0")
s, err := redis.BitPos("godis", true, &BitPosParams{params: [][]byte{IntToByteArr(0)}})
assert.Nil(t, err)
assert.Equal(t, int64(8), s)
}
func TestRedisCluster_Blpop(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.LPush("command", "update system...")
redis.LPush("request", "visit page")
_, e := redis.BLPop("job", "command", "request", "0")
assert.NotNil(t, e)
}
func TestRedisCluster_BlpopTimout(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
go func() {
_, e := redis.BLPopTimeout(5, "command", "update system...")
assert.NotNil(t, e)
}()
time.Sleep(1 * time.Second)
redis.LPush("command", "update system...")
redis.LPush("request", "visit page")
time.Sleep(1 * time.Second)
}
func TestRedisCluster_Brpop(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.LPush("command", "update system...")
redis.LPush("request", "visit page")
_, e := redis.BRPop("job", "command", "request", "0")
assert.NotNil(t, e)
}
func TestRedisCluster_BrpopTimout(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
go func() {
redis.BRPopTimeout(5, "command", "update system...")
}()
time.Sleep(1 * time.Second)
redis.LPush("command", "update system...")
redis.LPush("request", "visit page")
time.Sleep(1 * time.Second)
}
func TestRedisCluster_Brpoplpush(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
go func() {
redis.BRPopLPush("command", "update system...", 5)
}()
time.Sleep(1 * time.Second)
redis.LPush("command", "update system...")
redis.LPush("request", "visit page")
time.Sleep(1 * time.Second)
}
func TestRedisCluster_Decr(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.Decr("godis")
assert.Nil(t, err)
assert.Equal(t, int64(-1), s)
s, err = redis.Decr("godis")
assert.Nil(t, err)
assert.Equal(t, int64(-2), s)
}
func TestRedisCluster_DecrBy(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.DecrBy("godis", 10)
assert.Nil(t, err)
assert.Equal(t, int64(-10), s)
s, err = redis.DecrBy("godis", -10)
assert.Nil(t, err)
assert.Equal(t, int64(0), s)
}
func TestRedisCluster_Del(t *testing.T) {
cluster := NewRedisCluster(clusterOption)
_, _ = cluster.Set("godis", "good")
count, err := cluster.Del("godis", "godis1", "godis2", "godis3", "godis4", "godis5")
assert.NotNil(t, err)
assert.Equal(t, int64(0), count)
count, err = cluster.Del("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1), count)
str, err := cluster.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "", str)
}
func TestRedisCluster_Echo(t *testing.T) {
redis := NewRedisCluster(clusterOption)
s, err := redis.Echo("godis")
assert.Nil(t, err)
assert.Equal(t, "godis", s)
}
func TestRedisCluster_Eval(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.Eval(`return redis.call("get",KEYS[1])`, 1, "godis")
assert.Nil(t, err)
assert.Equal(t, "good", s)
s, err = redis.Eval(`return redis.call("set",KEYS[1],ARGV[1])`, 1, "eval", "godis")
assert.Nil(t, err)
assert.Equal(t, "OK", s)
s, err = redis.Eval(`return redis.call("get",KEYS[1])`, 1, "eval")
assert.Nil(t, err)
assert.Equal(t, "godis", s)
}
func TestRedisCluster_Exists(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
c, e := redis.Exists("godis")
assert.Nil(t, e)
assert.Equal(t, int64(1), c)
}
func TestRedisCluster_Expire(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.Expire("godis", 1)
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
time.Sleep(2 * time.Second)
ret, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "", ret)
}
func TestRedisCluster_ExpireAt(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.ExpireAt("godis", time.Now().Add(1*time.Second).Unix())
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
time.Sleep(2 * time.Second)
ret, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "", ret)
}
func TestRedisCluster_Geo(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
c, err := redis.GeoAdd("godis", 121, 37, "a")
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
c, err = redis.GeoAddByMap("godis", map[string]GeoCoordinate{
"b": {
longitude: 122,
latitude: 37,
},
"c": {
longitude: 123,
latitude: 37,
},
"d": {
longitude: 124,
latitude: 37,
},
"e": {
longitude: 125,
latitude: 37,
},
})
assert.Nil(t, err)
assert.Equal(t, int64(4), c)
arr, err := redis.GeoHash("godis", "a")
assert.Nil(t, err)
assert.Equal(t, []string{"www43rts870"}, arr)
_, err = redis.GeoPos("godis", "b")
assert.Nil(t, err)
d, err := redis.GeoDist("godis", "a", "b", GeoUnitKm)
assert.Nil(t, err)
assert.Equal(t, 88.8291, d)
resp, err := redis.GeoRadius("godis", 121, 37, 500, GeoUnitKm,
NewGeoRadiusParam().WithCoord().WithDist())
assert.Nil(t, err)
t.Log(resp)
resp, err = redis.GeoRadiusByMember("godis", "a", 500, GeoUnitKm,
NewGeoRadiusParam().WithCoord().WithDist())
assert.Nil(t, err)
t.Log(resp)
}
func TestRedisCluster_Get(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "good", s)
}
func TestRedisCluster_GetSet(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.GetSet("godis", "good")
assert.Nil(t, err)
assert.Equal(t, "", s)
s, err = redis.GetSet("godis", "good1")
assert.Nil(t, err)
assert.Equal(t, "good", s)
}
func TestRedisCluster_Getbit(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.GetBit("godis", 1)
assert.Nil(t, err)
assert.Equal(t, true, s)
}
func TestRedisCluster_Getrange(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.GetRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, "good", s)
s, err = redis.GetRange("godis", 0, 1)
assert.Nil(t, err)
assert.Equal(t, "go", s)
}
func TestRedisCluster_Hdel(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HDel("godis", "a")
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
s, err = redis.HDel("godis", "a")
assert.Nil(t, err)
assert.Equal(t, int64(0), s)
}
func TestRedisCluster_Hexists(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HExists("godis", "a")
assert.Nil(t, err)
assert.Equal(t, true, s)
s, err = redis.HExists("godis", "b")
assert.Nil(t, err)
assert.Equal(t, false, s)
}
func TestRedisCluster_Hget(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HGet("godis", "a")
assert.Nil(t, err)
assert.Equal(t, "1", s)
}
func TestRedisCluster_HgetAll(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HGetAll("godis")
assert.Nil(t, err)
assert.Equal(t, map[string]string{"a": "1"}, s)
}
func TestRedisCluster_HincrBy(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HIncrBy("godis", "a", 1)
assert.Nil(t, err)
assert.Equal(t, int64(2), s)
s, err = redis.HIncrBy("godis", "b", 5)
assert.Nil(t, err)
assert.Equal(t, int64(5), s)
}
func TestRedisCluster_HincrByFloat(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
ret, err := redis.HIncrByFloat("godis", "a", 1.5)
assert.Nil(t, err)
assert.Equal(t, 2.5, ret)
ret, err = redis.HIncrByFloat("godis", "b", 5.0987)
assert.Nil(t, err)
assert.Equal(t, 5.0987, ret)
}
func TestRedisCluster_Hkeys(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HKeys("godis")
assert.Nil(t, err)
assert.Equal(t, []string{"a"}, s)
}
func TestRedisCluster_Hlen(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HLen("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
}
func TestRedisCluster_Hmget(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HMGet("godis", "a")
assert.Nil(t, err)
assert.Equal(t, []string{"1"}, s)
}
func TestRedisCluster_Hmset(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HMSet("godis", map[string]string{"b": "2", "c": "3"})
assert.Nil(t, err)
assert.Equal(t, "OK", s)
c, _ := redis.HLen("godis")
assert.Equal(t, int64(3), c)
}
func TestRedisCluster_Hscan(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
for i := 0; i < 1000; i++ {
redis.HSet("godis", fmt.Sprintf("a%d", i), fmt.Sprintf("%d", i))
}
c, err := redis.HLen("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1000), c)
params := NewScanParams().Match("a*").Count(10)
cursor := "0"
total := 0
for {
result, err := redis.HScan("godis", cursor, params)
assert.Nil(t, err)
total += len(result.Results)
cursor = result.Cursor
if result.Cursor == "0" {
break
}
}
//total contains key and value
assert.Equal(t, 2000, total)
}
func TestRedisCluster_Hset(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
ret, err := redis.HSet("godis", "a", "1")
assert.Nil(t, err)
assert.Equal(t, int64(1), ret)
s, err := redis.HLen("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
}
func TestRedisCluster_Hsetnx(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HGet("godis", "a")
assert.Nil(t, err)
assert.Equal(t, "1", s)
ret, err := redis.HSetNx("godis", "a", "2")
assert.Nil(t, err)
assert.Equal(t, int64(0), ret)
s, err = redis.HGet("godis", "a")
assert.Nil(t, err)
assert.Equal(t, "1", s)
}
func TestRedisCluster_Hvals(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.HSet("godis", "a", "1")
s, err := redis.HVals("godis")
assert.Nil(t, err)
assert.Equal(t, []string{"1"}, s)
}
func TestRedisCluster_Incr(t *testing.T) {
cluster := NewRedisCluster(clusterOption)
clearKeys(cluster)
for i := 0; i < 10000; i++ {
cluster.Incr("godis")
}
reply, _ := cluster.Get("godis")
assert.Equal(t, "10000", reply)
}
func TestRedisCluster_IncrBy(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
var group sync.WaitGroup
ch := make(chan bool, 2)
for i := 0; i < 100000; i++ {
group.Add(1)
ch <- true
go func() {
defer group.Done()
_, err := redis.IncrBy("godis", 2)
assert.Nil(t, err)
<-ch
}()
}
group.Wait()
reply, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "200000", reply)
}
func TestRedisCluster_IncrByFloat(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.IncrByFloat("godis", 1.5)
assert.Nil(t, err)
assert.Equal(t, 1.5, s)
s, err = redis.IncrByFloat("godis", 1.62)
assert.Nil(t, err)
assert.Equal(t, 3.12, s)
}
func TestRedisCluster_Keys(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
}
func TestRedisCluster_Lindex(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.LPush("godis", "1", "2", "3")
assert.Nil(t, err)
assert.Equal(t, int64(3), s)
el, err := redis.LIndex("godis", 0)
assert.Nil(t, err)
assert.Equal(t, "1", el)
el, err = redis.LIndex("godis", -1)
assert.Nil(t, err)
assert.Equal(t, "3", el)
el, err = redis.LIndex("godis", 3)
assert.Nil(t, err)
assert.Equal(t, "", el)
}
func TestRedisCluster_List(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.LPush("godis", "1", "2", "3")
assert.Nil(t, err)
assert.Equal(t, int64(3), s)
s, err = redis.LInsert("godis", ListOptionBefore, "2", "1.5")
assert.Nil(t, err)
assert.Equal(t, int64(4), s)
s, err = redis.LInsert("godis", ListOptionAfter, "3", "3.5")
assert.Nil(t, err)
assert.Equal(t, int64(5), s)
s, err = redis.LInsert("godis", ListOptionBefore, "2", "1.5")
assert.Nil(t, err)
assert.Equal(t, int64(6), s)
s, err = redis.LInsert("godis", ListOptionBefore, "1.5", "1.4")
assert.Nil(t, err)
assert.Equal(t, int64(7), s)
arr, err := redis.LRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"1", "1.4", "1.5", "1.5", "2", "3", "3.5"}, arr)
llen, err := redis.LLen("godis")
assert.Nil(t, err)
assert.Equal(t, int64(7), llen)
lpop, err := redis.LPop("godis")
assert.Nil(t, err)
assert.Equal(t, "1", lpop)
rpop, err := redis.RPop("godis")
assert.Nil(t, err)
assert.Equal(t, "3.5", rpop)
s, err = redis.RPush("godis", "4")
assert.Nil(t, err)
assert.Equal(t, int64(6), s)
rpoplpush, err := redis.RPopLPush("godis", "0.5")
assert.NotNil(t, err)
assert.Equal(t, "", rpoplpush)
arr, err = redis.LRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"1.4", "1.5", "1.5", "2", "3", "4"}, arr)
llen, err = redis.LLen("0.5")
assert.Nil(t, err)
assert.Equal(t, int64(0), llen)
s, err = redis.LRem("godis", 0, "1.5")
assert.Nil(t, err)
assert.Equal(t, int64(2), s)
arr, err = redis.LRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"1.4", "2", "3", "4"}, arr)
lset, err := redis.LSet("godis", 2, "2.0")
assert.Nil(t, err)
assert.Equal(t, "OK", lset)
arr, err = redis.LRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"1.4", "2", "2.0", "4"}, arr)
lset, err = redis.LSet("godis", 4, "2.0")
assert.NotNil(t, err)
assert.Equal(t, "", lset)
ltrim, err := redis.LTrim("godis", 1, 2)
assert.Nil(t, err)
assert.Equal(t, "OK", ltrim)
arr, err = redis.LRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"2", "2.0"}, arr)
redis.LPushX("godis", "1")
redis.RPushX("godis", "3")
arr, err = redis.LRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"1", "2", "2.0", "3"}, arr)
}
func TestRedisCluster_Persist(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.Expire("godis", 100)
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
s, err = redis.Persist("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
c, err := redis.TTL("godis")
assert.Nil(t, err)
assert.Equal(t, int64(-1), c)
}
func TestRedisCluster_Pexpire(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.PExpire("godis", 1000)
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
time.Sleep(2 * time.Second)
ret, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "", ret)
}
func TestRedisCluster_PexpireAt(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.PExpireAt("godis", time.Now().Add(1*time.Second).UnixNano()/1e6)
assert.Nil(t, err)
assert.Equal(t, int64(1), s)
time.Sleep(2 * time.Second)
ret, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "", ret)
}
func TestRedisCluster_Pfadd(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
c, err := redis.PfAdd("godis", "a", "b", "c", "d")
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
c, err = redis.PfCount("godis")
assert.Nil(t, err)
assert.Equal(t, int64(4), c)
c, err = redis.PfAdd("godis1", "a", "b", "c", "d")
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
c, err = redis.PfCount("godis1")
assert.Nil(t, err)
assert.Equal(t, int64(4), c)
s, err := redis.PfMerge("godis3", "godis", "godis1")
assert.NotNil(t, err)
assert.Equal(t, "", s)
c, err = redis.PfCount("godis3")
assert.Nil(t, err)
assert.Equal(t, int64(0), c)
}
func TestRedisCluster_Psetex(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.PSetEx("godis", 1000, "good")
assert.Nil(t, err)
assert.Equal(t, "OK", s)
time.Sleep(2 * time.Second)
get, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "good", get)
}
func TestRedisCluster_Psubscribe(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
pubsub := &RedisPubSub{
OnMessage: func(channel, message string) {
t.Logf("receive message ,channel:%s,message:%s", channel, message)
},
OnSubscribe: func(channel string, subscribedChannels int) {
t.Logf("receive subscribe command ,channel:%s,subscribedChannels:%d", channel, subscribedChannels)
},
OnUnSubscribe: func(channel string, subscribedChannels int) {
t.Logf("receive unsubscribe command ,channel:%s,subscribedChannels:%d", channel, subscribedChannels)
},
OnPMessage: func(pattern string, channel, message string) {
t.Logf("receive pmessage ,pattern:%s,channel:%s,message:%s", pattern, channel, message)
},
OnPSubscribe: func(pattern string, subscribedChannels int) {
t.Logf("receive psubscribe command ,pattern:%s,subscribedChannels:%d", pattern, subscribedChannels)
},
OnPUnSubscribe: func(pattern string, subscribedChannels int) {
t.Logf("receive punsubscribe command ,pattern:%s,subscribedChannels:%d", pattern, subscribedChannels)
},
OnPong: func(channel string) {
t.Logf("receive pong ,channel:%s", channel)
},
}
go func() {
redis.PSubscribe(pubsub, "godis")
}()
//sleep mills, ensure message can publish to subscribers
time.Sleep(500 * time.Millisecond)
redis.Publish("godis", "publish a message to godis channel")
//sleep mills, ensure message can publish to subscribers
time.Sleep(500 * time.Millisecond)
}
func TestRedisCluster_Pttl(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.PTTL("godis")
assert.Nil(t, err)
assert.Equal(t, int64(-1), s)
}
func TestRedisCluster_Rename(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, e := redis.Rename("godis", "godis1")
assert.NotNil(t, e)
assert.Equal(t, "", s)
redis.Set("godis", "good")
c, e := redis.RenameNx("godis", "godis1")
assert.NotNil(t, e)
assert.Equal(t, int64(0), c)
}
func TestRedisCluster_Scan(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
for i := 0; i < 1000; i++ {
redis.Set(fmt.Sprintf("{godis}%d", i), fmt.Sprintf("godis%d", i))
}
params := NewScanParams().Match("{godis}*").Count(10)
cursor := "0"
total := 0
for {
result, err := redis.Scan(cursor, params)
assert.Nil(t, err)
total += len(result.Results)
cursor = result.Cursor
if result.Cursor == "0" {
break
}
}
assert.Equal(t, 1000, total)
}
func TestRedisCluster_ScriptLoad(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
sha, err := redis.ScriptLoad("godis1", `return redis.call("get",KEYS[1])`)
assert.Nil(t, err)
bools, err := redis.ScriptExists("godis1", sha)
assert.Nil(t, err)
assert.Equal(t, []bool{true}, bools)
s, err := redis.EvalSha(sha, 1, "godis")
assert.Nil(t, err)
assert.Equal(t, "good", s)
}
func TestRedisCluster_Sdiff(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.SAdd("godis1", "1", "2", "3")
redis.SAdd("godis2", "2", "3", "4")
_, e := redis.SDiff("godis1", "godis2")
assert.NotNil(t, e)
_, e = redis.SDiffStore("godis3", "godis1", "godis2")
assert.NotNil(t, e)
_, e = redis.SInter("godis1", "godis2")
assert.NotNil(t, e)
_, e = redis.SInterStore("godis4", "godis1", "godis2")
assert.NotNil(t, e)
_, e = redis.SUnion("godis1", "godis2")
assert.NotNil(t, e)
_, e = redis.SUnionStore("godis5", "godis1", "godis2")
assert.NotNil(t, e)
}
func TestRedisCluster_Set(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
ret, err := redis.Set("godis", "good")
assert.Nil(t, err)
assert.Equal(t, "OK", ret)
}
func TestRedisCluster_SetWithParams(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.SetWithParams("godis", "good", "xx")
assert.Nil(t, err)
assert.Equal(t, "", s)
redis.Set("godis", "good")
s, err = redis.SetWithParams("godis", "good1", "xx")
assert.Nil(t, err)
assert.Equal(t, "OK", s)
get, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "good1", get)
}
func TestRedisCluster_SetWithParamsAndTime(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.SetWithParamsAndTime("godis", "good", "nx", "px", 1500)
assert.Nil(t, err)
assert.Equal(t, "OK", s)
s, err = redis.SetWithParamsAndTime("godis", "good", "nx", "px", 1500)
assert.Nil(t, err)
assert.Equal(t, "", s)
}
func TestRedisCluster_Setbit(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "a")
c, err := redis.GetBit("godis", 1)
assert.Nil(t, err)
assert.Equal(t, true, c)
c, err = redis.SetBit("godis", 6, "1")
assert.Nil(t, err)
assert.Equal(t, false, c)
c, err = redis.SetBitWithBool("godis", 7, false)
assert.Nil(t, err)
assert.Equal(t, true, c)
get, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "b", get)
}
func TestRedisCluster_Setex(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.SetEx("godis", 1, "good")
assert.Nil(t, err)
assert.Equal(t, "OK", s)
time.Sleep(2 * time.Second)
get, err := redis.Get("godis")
assert.Nil(t, err)
assert.Equal(t, "", get)
}
func TestRedisCluster_Setnx(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.SetNx("godis", "good1")
assert.Nil(t, err)
assert.Equal(t, int64(0), s)
}
func TestRedisCluster_Setrange(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
c, err := redis.SetRange("godis", 5, " ok")
assert.Nil(t, err)
assert.Equal(t, int64(8), c)
}
func TestRedisCluster_Smembers(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
c, err := redis.SAdd("godis", "1", "2", "3")
assert.Nil(t, err)
assert.Equal(t, int64(3), c)
c, err = redis.SCard("godis")
assert.Nil(t, err)
assert.Equal(t, int64(3), c)
b, err := redis.SIsMember("godis", "1")
assert.Nil(t, err)
assert.Equal(t, true, b)
arr, err := redis.SMembers("godis")
assert.Nil(t, err)
assert.Equal(t, []string{"1", "2", "3"}, arr)
s, err := redis.SRandMember("godis")
assert.Nil(t, err)
assert.Contains(t, []string{"1", "2", "3"}, s)
arr, err = redis.SRandMemberBatch("godis", 2)
assert.Nil(t, err)
assert.Len(t, arr, 2)
c, err = redis.SRem("godis", "1")
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
spop, err := redis.SPop("godis")
assert.Nil(t, err)
assert.Contains(t, []string{"2", "3"}, spop)
arr, err = redis.SPopBatch("godis", 2)
assert.Nil(t, err)
assert.Subset(t, []string{"2", "3"}, arr)
}
func TestRedisCluster_Smove(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.SAdd("godis", "1", "2")
redis.SAdd("godis1", "3", "4")
_, e := redis.SMove("godis", "godis1", "2")
assert.NotNil(t, e)
}
func TestRedisCluster_Sort(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.LPush("godis", "3", "2", "1", "4", "6", "5")
p := NewSortParams().Desc()
arr, e := redis.Sort("godis", p)
assert.Nil(t, e)
assert.Equal(t, []string{"6", "5", "4", "3", "2", "1"}, arr)
p = NewSortParams().Asc()
arr, e = redis.Sort("godis", p)
assert.Nil(t, e)
assert.Equal(t, []string{"1", "2", "3", "4", "5", "6"}, arr)
_, e = redis.SortStore("godis", "godis1", p)
assert.NotNil(t, e)
}
func TestRedisCluster_Sscan(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
for i := 0; i < 1000; i++ {
redis.SAdd("godis", fmt.Sprintf("%d", i))
}
c, err := redis.SCard("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1000), c)
params := NewScanParams().Match("*").Count(10)
cursor := "0"
total := 0
for {
result, err := redis.SScan("godis", cursor, params)
assert.Nil(t, err)
total += len(result.Results)
cursor = result.Cursor
if result.Cursor == "0" {
break
}
}
assert.Equal(t, 1000, total)
}
func TestRedisCluster_Strlen(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.StrLen("godis")
assert.Nil(t, err)
assert.Equal(t, int64(4), s)
}
func TestRedisCluster_Subscribe(t *testing.T) {
cluster := NewRedisCluster(clusterOption)
clearKeys(cluster)
pubsub := &RedisPubSub{
OnMessage: func(channel, message string) {
t.Logf("receive message ,channel:%s,message:%s", channel, message)
},
OnSubscribe: func(channel string, subscribedChannels int) {
t.Logf("receive subscribe command ,channel:%s,subscribedChannels:%d", channel, subscribedChannels)
},
OnUnSubscribe: func(channel string, subscribedChannels int) {
t.Logf("receive unsubscribe command ,channel:%s,subscribedChannels:%d", channel, subscribedChannels)
},
OnPMessage: func(pattern string, channel, message string) {
t.Logf("receive pmessage ,pattern:%s,channel:%s,message:%s", pattern, channel, message)
},
OnPSubscribe: func(pattern string, subscribedChannels int) {
t.Logf("receive psubscribe command ,pattern:%s,subscribedChannels:%d", pattern, subscribedChannels)
},
OnPUnSubscribe: func(pattern string, subscribedChannels int) {
t.Logf("receive punsubscribe command ,pattern:%s,subscribedChannels:%d", pattern, subscribedChannels)
},
OnPong: func(channel string) {
t.Logf("receive pong ,channel:%s", channel)
},
}
go func() {
cluster.Subscribe(pubsub, "godis")
}()
//sleep mills, ensure message can publish to subscribers
time.Sleep(500 * time.Millisecond)
cluster.Publish("godis", "publish a message to godis channel")
//sleep mills, ensure message can publish to subscribers
time.Sleep(500 * time.Millisecond)
}
func TestRedisCluster_Substr(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
redis.Set("godis", "good")
s, err := redis.SubStr("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, "good", s)
}
func TestRedisCluster_Ttl(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, err := redis.TTL("godis")
assert.Nil(t, err)
assert.Equal(t, int64(-2), s)
}
func TestRedisCluster_Type(t *testing.T) {
redis := NewRedisCluster(clusterOption)
redis.Set("godis", "good")
s, err := redis.Type("godis")
assert.Nil(t, err)
assert.Equal(t, "string", s)
}
func TestRedisCluster_Zadd(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
zaddParam := NewZAddParams().NX()
c, err := redis.ZAdd("godis", 1, "a", zaddParam)
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
c, err = redis.ZAddByMap("godis", map[string]float64{"b": 2, "c": 3, "d": 4, "e": 5}, zaddParam)
assert.Nil(t, err)
assert.Equal(t, int64(4), c)
c, err = redis.ZCard("godis")
assert.Nil(t, err)
assert.Equal(t, int64(5), c)
score, err := redis.ZScore("godis", "a")
assert.Nil(t, err)
assert.Equal(t, float64(1), score)
//zcount include the boundary
c, err = redis.ZCount("godis", 2, 5)
assert.Nil(t, err)
assert.Equal(t, int64(4), c)
f, err := redis.ZIncrBy("godis", 1.5, "e", zaddParam)
assert.Nil(t, err)
assert.Equal(t, 6.5, f)
c, err = redis.ZRem("godis", "a")
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
arr, err := redis.ZRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"b", "c", "d", "e"}, arr)
arr, err = redis.ZRangeByScore("godis", 2, 6.5)
assert.Nil(t, err)
assert.Equal(t, []string{"b", "c", "d", "e"}, arr)
arr, err = redis.ZRevRangeByScore("godis", 6.5, 2)
assert.Nil(t, err)
assert.Equal(t, []string{"e", "d", "c", "b"}, arr)
arr, err = redis.ZRevRange("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []string{"e", "d", "c", "b"}, arr)
tuples, err := redis.ZRangeByScoreWithScores("godis", 2, 6.5)
assert.Nil(t, err)
assert.Equal(t, []Tuple{
{element: "b", score: 2},
{element: "c", score: 3},
{element: "d", score: 4},
{element: "e", score: 6.5},
}, tuples)
tuples, err = redis.ZRangeWithScores("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []Tuple{
{element: "b", score: 2},
{element: "c", score: 3},
{element: "d", score: 4},
{element: "e", score: 6.5},
}, tuples)
tuples, err = redis.ZRevRangeByScoreWithScores("godis", 6.5, 2)
assert.Nil(t, err)
assert.Equal(t, []Tuple{
{element: "e", score: 6.5},
{element: "d", score: 4},
{element: "c", score: 3},
{element: "b", score: 2},
}, tuples)
tuples, err = redis.ZRevRangeWithScores("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, []Tuple{
{element: "e", score: 6.5},
{element: "d", score: 4},
{element: "c", score: 3},
{element: "b", score: 2},
}, tuples)
arr, err = redis.ZRangeByScoreBatch("godis", 2, 6.5, 0, 2)
assert.Nil(t, err)
assert.Equal(t, []string{"b", "c"}, arr)
tuples, err = redis.ZRangeByScoreWithScoresBatch("godis", 2, 6.5, 0, 2)
assert.Nil(t, err)
assert.Equal(t, []Tuple{
{element: "b", score: 2},
{element: "c", score: 3},
}, tuples)
tuples, err = redis.ZRevRangeByScoreWithScoresBatch("godis", 6.5, 2, 0, 2)
assert.Nil(t, err)
assert.Equal(t, []Tuple{
{element: "e", score: 6.5},
{element: "d", score: 4},
}, tuples)
c, err = redis.ZRemRangeByScore("godis", 2, 2.5)
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
c, err = redis.ZLexCount("godis", "-", "+")
assert.Nil(t, err)
assert.Equal(t, int64(3), c)
arr, err = redis.ZRangeByLex("godis", "-", "+")
assert.Nil(t, err)
assert.Equal(t, []string{"c", "d", "e"}, arr)
arr, err = redis.ZRangeByLexBatch("godis", "-", "+", 0, 2)
assert.Nil(t, err)
assert.Equal(t, []string{"c", "d"}, arr)
arr, err = redis.ZRevRangeByLex("godis", "+", "-")
assert.Nil(t, err)
assert.Equal(t, []string{"e", "d", "c"}, arr)
arr, err = redis.ZRevRangeByLexBatch("godis", "+", "-", 0, 2)
assert.Nil(t, err)
assert.Equal(t, []string{"e", "d"}, arr)
c, err = redis.ZRemRangeByLex("godis", "[c", "[d")
assert.Nil(t, err)
assert.Equal(t, int64(2), c)
c, err = redis.ZCard("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1), c) //{"e":6.5}
redis.ZAddByMap("godis", map[string]float64{"b": 2, "c": 3, "d": 4}, zaddParam)
c, err = redis.ZRank("godis", "d")
assert.Nil(t, err)
assert.Equal(t, int64(2), c)
c, err = redis.ZRevRank("godis", "d")
assert.Nil(t, err)
assert.Equal(t, int64(1), c)
c, err = redis.ZRank("godis", "f")
assert.Nil(t, err)
assert.Equal(t, int64(-1), c) //f is not in godis
c, err = redis.ZRemRangeByRank("godis", 0, -1)
assert.Nil(t, err)
assert.Equal(t, int64(4), c) //f is not in godis
}
func TestRedisCluster_Zscan(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
for i := 0; i < 1000; i++ {
redis.ZAdd("godis", float64(i), fmt.Sprintf("a%d", i))
}
c, err := redis.ZCard("godis")
assert.Nil(t, err)
assert.Equal(t, int64(1000), c)
params := NewScanParams().Match("*").Count(10)
cursor := "0"
total := 0
for {
result, err := redis.ZScan("godis", cursor, params)
assert.Nil(t, err)
total += len(result.Results)
cursor = result.Cursor
if result.Cursor == "0" {
break
}
}
assert.Equal(t, 2000, total)
}
func TestRedisCluster_Zinterstore(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
c, err := redis.ZAddByMap("godis1", map[string]float64{"a": 1, "b": 2, "c": 3})
assert.Nil(t, err)
assert.Equal(t, int64(3), c)
c, err = redis.ZAddByMap("godis2", map[string]float64{"a": 1, "b": 2})
assert.Nil(t, err)
assert.Equal(t, int64(2), c)
c, err = redis.ZInterStore("godis3", "godis1", "godis2")
assert.NotNil(t, err)
assert.Equal(t, int64(0), c)
param := newZParams().Aggregate(AggregateSum)
c, err = redis.ZInterStoreWithParams("godis3", param, "godis1", "godis2")
assert.NotNil(t, err)
assert.Equal(t, int64(0), c)
c, err = redis.ZUnionStore("godis3", "godis1", "godis2")
assert.NotNil(t, err)
assert.Equal(t, int64(0), c)
param = newZParams().Aggregate(AggregateMax)
c, err = redis.ZUnionStoreWithParams("godis3", param, "godis1", "godis2")
assert.NotNil(t, err)
assert.Equal(t, int64(0), c)
}
func TestRedisCluster_Mset(t *testing.T) {
redis := NewRedisCluster(clusterOption)
clearKeys(redis)
s, e := redis.MSet("godis1", "good", "godis2", "good")
assert.NotNil(t, e)
assert.Equal(t, "", s)
c, e := redis.MSetNx("godis1", "good", "godis2", "good")
assert.NotNil(t, e)
assert.Equal(t, int64(0), c)
arr, e := redis.MGet("godis", "godis1", "godis2")
assert.NotNil(t, e)
assert.Empty(t, arr)
}
func TestRedisCluster_Basic(t *testing.T) {
cluster := NewRedisCluster(clusterOption)
clearKeys(cluster)
cluster.connectionHandler.cache.slots.Range(func(key, value interface{}) bool {
cluster.connectionHandler.cache.slots.Delete(key)
return true
})
s, err := cluster.Echo("godis")
assert.Nil(t, err)
assert.Equal(t, "godis", s)
cmd := newRedisClusterCommand(cluster.MaxAttempts, cluster.connectionHandler)
cmd.execute = func(redis *Redis) (interface{}, error) {
return redis.Echo("godis")
}
resp, err := cmd.runWithRetries([]byte("godis"), cluster.MaxAttempts, false, newRedirectError("redirect error"))
assert.NotNil(t, err)
assert.Nil(t, resp)
resp, err = cmd.runWithRetries([]byte("godis"), cluster.MaxAttempts, false,
newMovedDataError("move data error", "localhost", 9000, 10000))
assert.NotNil(t, err)
assert.Nil(t, resp)
resp, err = cmd.runWithRetries([]byte("godis"), cluster.MaxAttempts, false,
newAskDataError("move data error", "localhost", 9000, 10000))
assert.NotNil(t, err)
assert.Nil(t, resp)
}

Comment ( 0 )

Sign in for post a comment

Go
1
https://gitee.com/piaohao/godis.git
git@gitee.com:piaohao/godis.git
piaohao
godis
godis
master

Help Search