Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Jun 3, 2024
1 parent e16e3c3 commit 4371db4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/integrations/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,7 @@ func (suite *clientTestSuite) TestGetRegion() {
if r == nil {
return false
}
region.Leader = peers[0]
return reflect.DeepEqual(region, r.Meta) &&
reflect.DeepEqual(peers[0], r.Leader) &&
r.Buckets == nil
Expand Down Expand Up @@ -1375,6 +1376,7 @@ func (suite *clientTestSuite) TestGetPrevRegion() {
r, err := suite.client.GetPrevRegion(context.Background(), []byte{byte(i)})
re.NoError(err)
if i > 0 && i < regionLen {
regions[i-1].Leader = peers[0]
return reflect.DeepEqual(peers[0], r.Leader) &&
reflect.DeepEqual(regions[i-1], r.Meta)
}
Expand Down Expand Up @@ -1416,6 +1418,7 @@ func (suite *clientTestSuite) TestScanRegions() {
})

// Set leader of region3 to nil.
regions[3].Leader = nil
region3 := core.NewRegionInfo(regions[3])
suite.srv.GetRaftCluster().HandleRegionHeartbeat(region3)

Expand All @@ -1437,6 +1440,9 @@ func (suite *clientTestSuite) TestScanRegions() {
t.Log("scanRegions", scanRegions)
t.Log("expect", expect)
for i := range expect {
if scanRegions[i].Meta.GetId() != region3.GetID() {
expect[i].Leader = expect[i].Peers[0]
}
re.Equal(expect[i], scanRegions[i].Meta)

if scanRegions[i].Meta.GetId() == region3.GetID() {
Expand Down Expand Up @@ -1487,6 +1493,7 @@ func (suite *clientTestSuite) TestGetRegionByID() {
if r == nil {
return false
}
region.Leader = peers[0]
return reflect.DeepEqual(region, r.Meta) &&
reflect.DeepEqual(peers[0], r.Leader)
})
Expand Down
2 changes: 1 addition & 1 deletion tools/pd-ctl/tests/region/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ func TestRegionNoLeader(t *testing.T) {
{Id: 6, StoreId: 3}},
RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 1},
}
r := core.NewRegionInfo(metaRegion, nil)
r := core.NewRegionInfo(metaRegion)

cluster.GetLeaderServer().GetRaftCluster().GetBasicCluster().SetRegion(r)

Expand Down

0 comments on commit 4371db4

Please sign in to comment.