From ba57f2d5f4d679bc8bb6e96716c0c61950323a3c Mon Sep 17 00:00:00 2001 From: Jianjun Liao Date: Tue, 23 Apr 2024 14:28:06 +0800 Subject: [PATCH] fix unit test Signed-off-by: Jianjun Liao --- br/pkg/restore/split/mock_pd_client.go | 7 ++++++- br/pkg/restore/split/split_test.go | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/br/pkg/restore/split/mock_pd_client.go b/br/pkg/restore/split/mock_pd_client.go index cc01d68ecfc45..4bd709260e90a 100644 --- a/br/pkg/restore/split/mock_pd_client.go +++ b/br/pkg/restore/split/mock_pd_client.go @@ -74,8 +74,13 @@ func (c *MockPDClientForSplit) setRegions(boundaries [][]byte) []*metapb.Region StartKey: boundaries[i-1], EndKey: boundaries[i], } + p := &metapb.Peer{ + Id: c.lastRegionID, + StoreId: 1, + } c.Regions.SetRegion(&pdtypes.Region{ - Meta: r, + Meta: r, + Leader: p, }) ret = append(ret, r) } diff --git a/br/pkg/restore/split/split_test.go b/br/pkg/restore/split/split_test.go index 99bfdd88383bf..9ca523fe214f4 100644 --- a/br/pkg/restore/split/split_test.go +++ b/br/pkg/restore/split/split_test.go @@ -504,6 +504,10 @@ func TestPaginateScanRegion(t *testing.T) { StartKey: []byte{1}, EndKey: []byte{2}, }, + Leader: &metapb.Peer{ + Id: 1, + StoreId: 1, + }, }) mockPDClient.Regions.SetRegion(&pdtypes.Region{ Meta: &metapb.Region{ @@ -511,6 +515,10 @@ func TestPaginateScanRegion(t *testing.T) { StartKey: []byte{4}, EndKey: []byte{5}, }, + Leader: &metapb.Peer{ + Id: 4, + StoreId: 1, + }, }) _, err = PaginateScanRegion(ctx, mockClient, []byte{1}, []byte{5}, 3) @@ -525,6 +533,10 @@ func TestPaginateScanRegion(t *testing.T) { StartKey: []byte{2}, EndKey: []byte{3}, }, + Leader: &metapb.Peer{ + Id: 2, + StoreId: 1, + }, }, { Meta: &metapb.Region{ @@ -532,6 +544,10 @@ func TestPaginateScanRegion(t *testing.T) { StartKey: []byte{3}, EndKey: []byte{4}, }, + Leader: &metapb.Peer{ + Id: 3, + StoreId: 1, + }, }, } mockPDClient.scanRegions.beforeHook = func() {