fix integration test (#673)

Signed-off-by: disksing <i@disksing.com>
This commit is contained in:
disksing 2023-01-18 20:19:38 +08:00 committed by GitHub
parent 2a02753d9c
commit bd55989520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -118,6 +118,9 @@ type checkRequestClient struct {
func (c *checkRequestClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) {
resp, err := c.Client.SendRequest(ctx, addr, req, timeout)
if err != nil {
return resp, err
}
if c.priority != req.Priority {
if resp.Resp != nil {
if getResp, ok := resp.Resp.(*kvrpcpb.GetResponse); ok {

View File

@ -314,7 +314,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestLearnerReplicaSelector() {
region = &Region{
meta: region.GetMeta(),
}
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
region.meta.Peers = append(region.meta.Peers, tikvLearner)
atomic.StorePointer(&region.store, unsafe.Pointer(regionStore))
@ -325,7 +325,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestLearnerReplicaSelector() {
cache.mu.Unlock()
// Test accessFollower state with kv.ReplicaReadLearner request type.
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
refreshEpochs(regionStore)
req.ReplicaReadType = kv.ReplicaReadLearner
replicaSelector, err := newReplicaSelector(cache, regionLoc.Region, req)
@ -334,7 +334,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestLearnerReplicaSelector() {
accessLearner, _ := replicaSelector.state.(*accessFollower)
// Invalidate the region if the leader is not in the region.
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
rpcCtx, err := replicaSelector.next(s.bo)
s.Nil(err)
// Should swith to the next follower.
@ -365,7 +365,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
region = &Region{
meta: region.GetMeta(),
}
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
region.meta.Peers = append(region.meta.Peers, tiflash)
atomic.StorePointer(&region.store, unsafe.Pointer(regionStore))
@ -429,7 +429,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
s.False(replicaSelector.region.isValid())
// Test switching to tryFollower if leader is unreachable
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req)
s.Nil(err)
s.NotNil(replicaSelector)
@ -613,7 +613,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
AssertRPCCtxEqual(s, rpcCtx, replicaSelector.replicas[regionStore.workTiKVIdx], nil)
// Test accessFollower state filtering label-not-match stores.
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
refreshEpochs(regionStore)
labels := []*metapb.StoreLabel{
{
@ -635,7 +635,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
}
// Test accessFollower state with leaderOnly option
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
refreshEpochs(regionStore)
for i := 0; i < 5; i++ {
replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req, WithLeaderOnly())
@ -648,7 +648,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
}
// Test accessFollower state with kv.ReplicaReadMixed request type.
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
refreshEpochs(regionStore)
req.ReplicaReadType = kv.ReplicaReadMixed
replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req)
@ -656,7 +656,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
s.Nil(err)
// Invalidate the region if the leader is not in the region.
region.lastAccess = time.Now().Unix()
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
replicaSelector.updateLeader(&metapb.Peer{Id: s.cluster.AllocID(), StoreId: s.cluster.AllocID()})
s.False(region.isValid())
// Don't try next replica if the region is invalidated.