@@ -70,6 +70,8 @@ import (
7070 filter "github.com/pingcap/tidb/util/table-filter"
7171 "github.com/stretchr/testify/require"
7272 "github.com/stretchr/testify/suite"
73+ "github.com/tikv/client-go/v2/testutils"
74+ pd "github.com/tikv/pd/client"
7375)
7476
7577const (
@@ -1162,6 +1164,8 @@ func (s *tableRestoreSuite) TestCheckClusterResource() {
11621164 require .NoError (s .T (), err )
11631165 mockStore , err := storage .NewLocalStorage (dir )
11641166 require .NoError (s .T (), err )
1167+ _ , _ , pdClient , err := testutils .NewMockTiKV ("" , nil )
1168+ require .NoError (s .T (), err )
11651169 for _ , ca := range cases {
11661170 server := httptest .NewTLSServer (http .HandlerFunc (func (w http.ResponseWriter , req * http.Request ) {
11671171 var err error
@@ -1178,9 +1182,11 @@ func (s *tableRestoreSuite) TestCheckClusterResource() {
11781182
11791183 url := strings .TrimPrefix (server .URL , "https://" )
11801184 cfg := & config.Config {TiDB : config.DBStore {PdAddr : url }}
1185+ pdCli := & mockPDClient {Client : pdClient , leaderAddr : url }
11811186 targetInfoGetter := & TargetInfoGetterImpl {
1182- cfg : cfg ,
1183- tls : tls ,
1187+ cfg : cfg ,
1188+ tls : tls ,
1189+ pdCli : pdCli ,
11841190 }
11851191 preInfoGetter := & PreImportInfoGetterImpl {
11861192 cfg : cfg ,
@@ -1195,6 +1201,7 @@ func (s *tableRestoreSuite) TestCheckClusterResource() {
11951201 checkTemplate : template ,
11961202 preInfoGetter : preInfoGetter ,
11971203 precheckItemBuilder : theCheckBuilder ,
1204+ pdCli : pdCli ,
11981205 }
11991206 var sourceSize int64
12001207 err = rc .store .WalkDir (ctx , & storage.WalkOption {}, func (path string , size int64 ) error {
@@ -1231,6 +1238,15 @@ func (mockTaskMetaMgr) CheckTasksExclusively(ctx context.Context, action func(ta
12311238 return err
12321239}
12331240
1241+ type mockPDClient struct {
1242+ pd.Client
1243+ leaderAddr string
1244+ }
1245+
1246+ func (m * mockPDClient ) GetLeaderAddr () string {
1247+ return m .leaderAddr
1248+ }
1249+
12341250func (s * tableRestoreSuite ) TestCheckClusterRegion () {
12351251 type testCase struct {
12361252 stores pdtypes.StoresInfo
@@ -1246,6 +1262,8 @@ func (s *tableRestoreSuite) TestCheckClusterRegion() {
12461262 }
12471263 return regions
12481264 }
1265+ _ , _ , pdClient , err := testutils .NewMockTiKV ("" , nil )
1266+ require .NoError (s .T (), err )
12491267
12501268 testCases := []testCase {
12511269 {
@@ -1321,10 +1339,12 @@ func (s *tableRestoreSuite) TestCheckClusterRegion() {
13211339
13221340 url := strings .TrimPrefix (server .URL , "https://" )
13231341 cfg := & config.Config {TiDB : config.DBStore {PdAddr : url }}
1342+ pdCli := & mockPDClient {Client : pdClient , leaderAddr : url }
13241343
13251344 targetInfoGetter := & TargetInfoGetterImpl {
1326- cfg : cfg ,
1327- tls : tls ,
1345+ cfg : cfg ,
1346+ tls : tls ,
1347+ pdCli : pdCli ,
13281348 }
13291349 dbMetas := []* mydump.MDDatabaseMeta {}
13301350 preInfoGetter := & PreImportInfoGetterImpl {
@@ -1341,6 +1361,7 @@ func (s *tableRestoreSuite) TestCheckClusterRegion() {
13411361 preInfoGetter : preInfoGetter ,
13421362 dbInfos : make (map [string ]* checkpoints.TidbDBInfo ),
13431363 precheckItemBuilder : theCheckBuilder ,
1364+ pdCli : pdCli ,
13441365 }
13451366
13461367 preInfoGetter .dbInfosCache = rc .dbInfos
0 commit comments