Skip to content

Commit d8bd792

Browse files
disksingyou06
authored andcommitted
fix integration test (#673)
Signed-off-by: disksing <i@disksing.com>
1 parent f653acf commit d8bd792

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

integration_tests/store_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ type checkRequestClient struct {
118118

119119
func (c *checkRequestClient) SendRequest(ctx context.Context, addr string, req *tikvrpc.Request, timeout time.Duration) (*tikvrpc.Response, error) {
120120
resp, err := c.Client.SendRequest(ctx, addr, req, timeout)
121+
if err != nil {
122+
return resp, err
123+
}
121124
if c.priority != req.Priority {
122125
if resp.Resp != nil {
123126
if getResp, ok := resp.Resp.(*kvrpcpb.GetResponse); ok {

internal/locate/region_request3_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
299299
region = &Region{
300300
meta: region.GetMeta(),
301301
}
302-
region.lastAccess = time.Now().Unix()
302+
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
303303
region.meta.Peers = append(region.meta.Peers, peer)
304304
atomic.StorePointer(&region.store, unsafe.Pointer(regionStore))
305305

@@ -374,7 +374,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
374374
s.False(replicaSelector.region.isValid())
375375

376376
// Test switching to tryFollower if leader is unreachable
377-
region.lastAccess = time.Now().Unix()
377+
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
378378
replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req)
379379
s.Nil(err)
380380
s.NotNil(replicaSelector)
@@ -563,7 +563,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
563563
assertRPCCtxEqual(rpcCtx, replicaSelector.replicas[regionStore.workTiKVIdx], nil)
564564

565565
// Test accessFollower state filtering label-not-match stores.
566-
region.lastAccess = time.Now().Unix()
566+
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
567567
refreshEpochs(regionStore)
568568
labels := []*metapb.StoreLabel{
569569
{
@@ -585,7 +585,7 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
585585
}
586586

587587
// Test accessFollower state with leaderOnly option
588-
region.lastAccess = time.Now().Unix()
588+
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
589589
refreshEpochs(regionStore)
590590
for i := 0; i < 5; i++ {
591591
replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req, WithLeaderOnly())
@@ -598,15 +598,15 @@ func (s *testRegionRequestToThreeStoresSuite) TestReplicaSelector() {
598598
}
599599

600600
// Test accessFollower state with kv.ReplicaReadMixed request type.
601-
region.lastAccess = time.Now().Unix()
601+
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
602602
refreshEpochs(regionStore)
603603
req.ReplicaReadType = kv.ReplicaReadMixed
604604
replicaSelector, err = newReplicaSelector(cache, regionLoc.Region, req)
605605
s.NotNil(replicaSelector)
606606
s.Nil(err)
607607

608608
// Invalidate the region if the leader is not in the region.
609-
region.lastAccess = time.Now().Unix()
609+
atomic.StoreInt64(&region.lastAccess, time.Now().Unix())
610610
replicaSelector.updateLeader(&metapb.Peer{Id: s.cluster.AllocID(), StoreId: s.cluster.AllocID()})
611611
s.False(region.isValid())
612612
// Don't try next replica if the region is invalidated.

0 commit comments

Comments
 (0)