Skip to content

Commit

Permalink
make test happy
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Sep 13, 2024
1 parent 3113929 commit ba8b5c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions server/schedulers/evict_leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ type evictLeaderSchedulerConfig struct {
cluster opt.Cluster
}

func (conf *evictLeaderSchedulerConfig) getStores() []uint64 {
conf.mu.RLock()
defer conf.mu.RUnlock()
stores := make([]uint64, 0, len(conf.StoreIDWithRanges))
for storeID := range conf.StoreIDWithRanges {
stores = append(stores, storeID)
}
return stores
}

func (conf *evictLeaderSchedulerConfig) BuildWithArgs(args []string) error {
if len(args) != 1 {
return errs.ErrSchedulerConfig.FastGenByArgs("id")
Expand Down Expand Up @@ -189,6 +199,11 @@ func newEvictLeaderScheduler(opController *schedule.OperatorController, conf *ev
}
}

// EvictStoreIDs returns the IDs of the evict-stores.
func (s *evictLeaderScheduler) EvictStoreIDs() []uint64 {
return s.conf.getStores()
}

func (s *evictLeaderScheduler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
s.handler.ServeHTTP(w, r)
}
Expand Down
6 changes: 3 additions & 3 deletions tests/server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ func (s *clusterTestSuite) TestTransferLeaderForScheduler(c *C) {
"store_id": 2,
})
// Check scheduler updated.
c.Assert(len(rc.GetSchedulers()), Equals, 5)
c.Assert(len(rc.GetSchedulers()), Equals, 4)
checkEvictLeaderSchedulerExist(c, rc, true)
checkEvictLeaderStoreIDs(c, rc, []uint64{1, 2})

Expand All @@ -1248,7 +1248,7 @@ func (s *clusterTestSuite) TestTransferLeaderForScheduler(c *C) {
time.Sleep(time.Second)
c.Assert(leaderServer.GetRaftCluster().IsPrepared(), IsTrue)
// Check scheduler updated.
c.Assert(len(rc.GetSchedulers()), Equals, 5)
c.Assert(len(rc.GetSchedulers()), Equals, 4)
checkEvictLeaderSchedulerExist(c, rc, true)
checkEvictLeaderStoreIDs(c, rc, []uint64{1, 2})

Expand All @@ -1266,7 +1266,7 @@ func (s *clusterTestSuite) TestTransferLeaderForScheduler(c *C) {
time.Sleep(time.Second)
c.Assert(leaderServer.GetRaftCluster().IsPrepared(), IsTrue)
// Check scheduler updated
c.Assert(len(rc.GetSchedulers()), Equals, 5)
c.Assert(len(rc.GetSchedulers()), Equals, 4)
checkEvictLeaderSchedulerExist(c, rc, true)
checkEvictLeaderStoreIDs(c, rc, []uint64{1, 2})

Expand Down

0 comments on commit ba8b5c2

Please sign in to comment.