From 78ace348decc495461d5bf0999668f5bc40cf692 Mon Sep 17 00:00:00 2001 From: 3pointer Date: Fri, 8 Sep 2023 12:16:34 +0800 Subject: [PATCH] fix unstable test --- store/gcworker/gc_worker_test.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/store/gcworker/gc_worker_test.go b/store/gcworker/gc_worker_test.go index 559ef4cbc2951..e51628520c8a2 100644 --- a/store/gcworker/gc_worker_test.go +++ b/store/gcworker/gc_worker_test.go @@ -1167,14 +1167,22 @@ func TestResolveLockRangeMeetRegionEnlargeCausedByRegionMerge(t *testing.T) { if region.GetId() == s.initRegion.regionID { return []*txnlock.Lock{{Key: []byte("a")}, {Key: []byte("b")}}, &tikv.KeyLocation{ - Region: tikv.NewRegionVerID(s.initRegion.regionID, 0, 0), + Region: tikv.NewRegionVerID( + region.GetId(), + region.GetRegionEpoch().ConfVer, + region.GetRegionEpoch().Version, + ), } } // second time scan locks if region.GetId() == region2 { return []*txnlock.Lock{{Key: []byte("o")}, {Key: []byte("p")}}, &tikv.KeyLocation{ - Region: tikv.NewRegionVerID(region2, 0, 0), + Region: tikv.NewRegionVerID( + region.GetId(), + region.GetRegionEpoch().ConfVer, + region.GetRegionEpoch().Version, + ), } } return []*txnlock.Lock{}, nil @@ -1206,7 +1214,10 @@ func TestResolveLockRangeMeetRegionEnlargeCausedByRegionMerge(t *testing.T) { } for i, lock := range locks { if bytes.Compare(key, lock.Key) <= 0 { - return locks[i:], &tikv.KeyLocation{Region: tikv.NewRegionVerID(s.initRegion.regionID, 0, 0)} + return locks[i:], &tikv.KeyLocation{Region: tikv.NewRegionVerID( + regionMeta.GetId(), + regionMeta.GetRegionEpoch().ConfVer, + regionMeta.GetRegionEpoch().Version)} } } } @@ -1219,7 +1230,7 @@ func TestResolveLockRangeMeetRegionEnlargeCausedByRegionMerge(t *testing.T) { } return loc, nil } - _, err := tikv.ResolveLocksForRange(gcContext(), mockGCLockResolver, 1, []byte(""), []byte("z"), tikv.NewNoopBackoff, 10) + _, err := tikv.ResolveLocksForRange(gcContext(), mockGCLockResolver, 1, []byte(""), []byte("z"), tikv.NewGcResolveLockMaxBackoffer, 10) require.NoError(t, err) require.Len(t, resolvedLock, 4) expects := [][]byte{[]byte("a"), []byte("b"), []byte("o"), []byte("p")}