Skip to content

Commit

Permalink
Add offline check test
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Jul 13, 2023
1 parent 066e286 commit 1af975a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/api/region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ func (suite *regionTestSuite) TestRegionCheck() {
core.SetApproximateKeys(10),
core.SetApproximateSize(10))
downPeer := &metapb.Peer{Id: 13, StoreId: 2}
r = r.Clone(core.WithAddPeer(downPeer), core.WithDownPeers([]*pdpb.PeerStats{{Peer: downPeer, DownSeconds: 3600}}), core.WithPendingPeers([]*metapb.Peer{downPeer}))
r = r.Clone(
core.WithAddPeer(downPeer),
core.WithDownPeers([]*pdpb.PeerStats{{Peer: downPeer, DownSeconds: 3600}}),
core.WithPendingPeers([]*metapb.Peer{downPeer}))
re := suite.Require()
mustRegionHeartbeat(re, suite.svr, r)
url := fmt.Sprintf("%s/region/id/%d", suite.urlPrefix, r.GetID())
Expand Down Expand Up @@ -201,6 +204,15 @@ func (suite *regionTestSuite) TestRegionCheck() {
suite.NoError(tu.ReadGetJSON(re, testDialClient, url, &r7))
histKeys := []*histItem{{Start: 1000, End: 1999, Count: 1}}
suite.Equal(histKeys, r7)

mustPutStore(re, suite.svr, 2, metapb.StoreState_Offline, metapb.NodeState_Removing, []*metapb.StoreLabel{})
mustRegionHeartbeat(re, suite.svr, r)
url = fmt.Sprintf("%s/regions/check/%s", suite.urlPrefix, "offline-peer")
r8 := &RegionsInfo{}
suite.NoError(tu.ReadGetJSON(re, testDialClient, url, r8))
r4.Adjust()
suite.Equal(1, r8.Count)
suite.Equal(r.GetID(), r8.Regions[0].ID)
}

func (suite *regionTestSuite) TestRegions() {
Expand Down

0 comments on commit 1af975a

Please sign in to comment.