Skip to content

Commit

Permalink
Merge branch 'master' into reset-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rleungx authored Oct 11, 2019
2 parents 0189cd5 + 1fbadf8 commit 824ca0d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions server/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,10 @@ func (s *testOperatorControllerSuite) TestOperatorCount(c *C) {
}

func (s *testOperatorControllerSuite) TestStoreOverloaded(c *C) {
_, opt, err := newTestScheduleConfig()
cfg, opt, err := newTestScheduleConfig()
c.Assert(cfg, NotNil)
c.Assert(err, IsNil)
cfg.StoreBalanceRate = 10
tc := newTestCluster(opt)
hbStreams, cleanup := getHeartBeatStreams(c, tc)
defer cleanup()
Expand All @@ -801,22 +803,28 @@ func (s *testOperatorControllerSuite) TestStoreOverloaded(c *C) {
c.Assert(tc.addRegionStore(2, 40), IsNil)
c.Assert(tc.addRegionStore(1, 10), IsNil)
c.Assert(tc.addLeaderRegion(1, 2, 3, 4), IsNil)
start := time.Now()
op1 := lb.Schedule(tc)[0]
c.Assert(op1, NotNil)
c.Assert(oc.AddOperator(op1), IsTrue)
for i := 0; i < 10; i++ {
if time.Now().Sub(start) >= time.Second*9/10 {
break
}
c.Assert(lb.Schedule(tc), IsNil)
}
c.Assert(oc.RemoveOperator(op1), IsTrue)
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)
for i := 0; i < 100; i++ {
c.Assert(lb.Schedule(tc), NotNil)
}
}

func (s *testOperatorControllerSuite) TestStoreOverloadedWithReplace(c *C) {
_, opt, err := newTestScheduleConfig()
cfg, opt, err := newTestScheduleConfig()
c.Assert(cfg, NotNil)
c.Assert(err, IsNil)
cfg.StoreBalanceRate = 10
tc := newTestCluster(opt)
hbStreams, cleanup := getHeartBeatStreams(c, tc)
defer cleanup()
Expand All @@ -839,7 +847,7 @@ func (s *testOperatorControllerSuite) TestStoreOverloadedWithReplace(c *C) {
op3 := newTestOperator(1, tc.GetRegion(2).GetRegionEpoch(), operator.OpRegion, operator.AddPeer{ToStore: 1, PeerID: 3})
c.Assert(oc.AddOperator(op3), IsFalse)
c.Assert(lb.Schedule(tc), IsNil)
time.Sleep(1 * time.Second)
time.Sleep(2 * time.Second)
c.Assert(lb.Schedule(tc), NotNil)
}

Expand Down

0 comments on commit 824ca0d

Please sign in to comment.