Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: Cabinfever_B <[email protected]>
  • Loading branch information
CabinfeverB committed Mar 3, 2022
1 parent 2d81e5c commit 32023ef
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/schedule/placement/region_rule_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ func (s *testRuleSuite) TestRegionRuleFitCache(c *C) {
c.Log(testcase.name)
c.Assert(cache.IsUnchanged(testcase.region, testcase.rules, mockStores(3)), Equals, testcase.unchanged)
}
for _, testcase := range testcases {
c.Log(testcase.name)
c.Assert(cache.IsUnchanged(testcase.region, testcase.rules, mockStoresNoHeartbeat(3)), Equals, false)
}
// Invalid Input4
c.Assert(cache.IsUnchanged(mockRegion(3, 0), addExtraRules(0), nil), IsFalse)
// Invalid Input5
Expand Down Expand Up @@ -207,3 +211,11 @@ func mockStores(num int) []*core.StoreInfo {
}
return stores
}

func mockStoresNoHeartbeat(num int) []*core.StoreInfo {
stores := make([]*core.StoreInfo, 0, num)
for i := 1; i <= num; i++ {
stores = append(stores, core.NewStoreInfo(&metapb.Store{Id: uint64(i)}))
}
return stores
}

0 comments on commit 32023ef

Please sign in to comment.