Skip to content

Commit

Permalink
test: add test case for read on the not exist namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
absolute8511 committed Sep 21, 2020
1 parent ea3a70f commit 53e6b83
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,3 +943,32 @@ func testClientReadLocal(t *testing.T, testSameWithPrimary bool, testFailedLocal
zanClient.DoRedis("DEL", pk.ShardingKey(), true, rawKey)
}
}

func TestClientReadOnNotExistNamespace(t *testing.T) {
conf := &Conf{
DialTimeout: time.Second * 2,
ReadTimeout: time.Second * 2,
WriteTimeout: time.Second * 2,
MaxConnWait: time.Second / 4,
TendInterval: 1,
Namespace: "not_exist",
}
conf.LookupList = append(conf.LookupList, pdAddr)
logLevel := int32(2)
if testing.Verbose() {
logLevel = 3
}
SetLogger(logLevel, newTestLogger(t))
zanClient, err := NewZanRedisClient(conf)
assert.Nil(t, err)
zanClient.Start()
defer zanClient.Stop()
time.Sleep(time.Second)

s := time.Now()
_, err = zanClient.KVGet("testset", []byte("getnokey"))
assert.Equal(t, errNoAnyPartitions, err)
cost := time.Since(s)
t.Logf("cost %s", cost)
assert.True(t, cost < conf.MaxConnWait*2)
}

0 comments on commit 53e6b83

Please sign in to comment.