Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
Signed-off-by: HunDunDM <hundundm@gmail.com>
  • Loading branch information
HunDunDM committed Jul 5, 2021
1 parent 1711722 commit 20690c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
9 changes: 3 additions & 6 deletions server/schedulers/hot_region_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ func (s *testHotWriteRegionSchedulerSuite) checkByteRateOnly(c *C, tc *mockclust

// hot region scheduler is restricted by `hot-region-schedule-limit`.
tc.SetHotRegionScheduleLimit(0)
c.Assert(hb.Schedule(tc), HasLen, 0)
c.Assert(hb.IsScheduleAllowed(tc), IsFalse)
hb.(*hotScheduler).clearPendingInfluence()
tc.SetHotRegionScheduleLimit(int(config.NewTestOptions().GetScheduleConfig().HotRegionScheduleLimit))

// hot region scheduler is restricted by schedule limit.
tc.SetLeaderScheduleLimit(0)
for i := 0; i < 20; i++ {
op := hb.Schedule(tc)[0]
hb.(*hotScheduler).clearPendingInfluence()
Expand All @@ -248,7 +246,6 @@ func (s *testHotWriteRegionSchedulerSuite) checkByteRateOnly(c *C, tc *mockclust
testutil.CheckTransferPeerWithLeaderTransfer(c, op, operator.OpHotRegion, 1, 6)
}
}
tc.SetLeaderScheduleLimit(int(config.NewTestOptions().GetScheduleConfig().LeaderScheduleLimit))

// hot region scheduler is not affect by `balance-region-schedule-limit`.
tc.SetRegionScheduleLimit(0)
Expand Down Expand Up @@ -299,7 +296,7 @@ func (s *testHotWriteRegionSchedulerSuite) checkByteRateOnly(c *C, tc *mockclust
// Region 1 and 2 are the same, cannot move peer to store 5 due to the label.
// Region 3 can only move peer to store 5.
// Region 5 can only move peer to store 6.
tc.SetLeaderScheduleLimit(0)
tc.SetHotRegionScheduleLimit(0)
for i := 0; i < 30; i++ {
op := hb.Schedule(tc)[0]
hb.(*hotScheduler).clearPendingInfluence()
Expand Down Expand Up @@ -532,7 +529,7 @@ func (s *testHotWriteRegionSchedulerSuite) TestWithPendingInfluence(c *C) {
// 1: key rate
tc := mockcluster.NewCluster(ctx, opt)
tc.SetHotRegionCacheHitsThreshold(0)
tc.SetLeaderScheduleLimit(0)
tc.SetHotRegionScheduleLimit(0)
tc.DisableFeature(versioninfo.JointConsensus)
tc.AddRegionStore(1, 20)
tc.AddRegionStore(2, 20)
Expand Down
4 changes: 2 additions & 2 deletions server/schedulers/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (s *testHotRegionSchedulerSuite) TestAbnormalReplica(c *C) {
defer cancel()
opt := config.NewTestOptions()
tc := mockcluster.NewCluster(ctx, opt)
tc.SetLeaderScheduleLimit(0)
tc.SetHotRegionScheduleLimit(0)
hb, err := schedule.CreateScheduler(HotReadRegionType, schedule.NewOperatorController(ctx, nil, nil), core.NewStorage(kv.NewMemoryKV()), nil)
c.Assert(err, IsNil)

Expand All @@ -237,7 +237,7 @@ func (s *testHotRegionSchedulerSuite) TestAbnormalReplica(c *C) {
tc.AddRegionWithReadInfo(3, 1, 512*KB*statistics.ReadReportInterval, 0, statistics.ReadReportInterval, []uint64{2, 3})
tc.SetHotRegionCacheHitsThreshold(0)
c.Assert(tc.IsRegionHot(tc.GetRegion(1)), IsTrue)
c.Assert(hb.Schedule(tc), IsNil)
c.Assert(hb.IsScheduleAllowed(tc), IsFalse)
}

var _ = Suite(&testEvictLeaderSuite{})
Expand Down

0 comments on commit 20690c3

Please sign in to comment.