Skip to content

Commit

Permalink
tests: reduce mcs test duration (#7435)
Browse files Browse the repository at this point in the history
ref #4399

Signed-off-by: lhy1024 <admin@liudos.us>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
lhy1024 and ti-chi-bot[bot] authored Dec 8, 2023
1 parent d8550f0 commit ab3025c
Show file tree
Hide file tree
Showing 15 changed files with 723 additions and 488 deletions.
6 changes: 6 additions & 0 deletions pkg/schedule/operator/operator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,12 @@ func (oc *Controller) GetFastOpInfluence(cluster *core.BasicCluster, influence O
}
}

// CleanAllOpRecords removes all operators' records.
// It is used in tests only.
func (oc *Controller) CleanAllOpRecords() {
oc.records.ttl.Clear()
}

// AddOpInfluence add operator influence for cluster
func AddOpInfluence(op *Operator, influence OpInfluence, cluster *core.BasicCluster) {
region := cluster.GetRegion(op.RegionID())
Expand Down
7 changes: 7 additions & 0 deletions pkg/statistics/hot_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,10 @@ func (w *HotCache) GetThresholds(kind utils.RWType, storeID uint64) []float64 {
}
return nil
}

// CleanCache cleans the cache.
// This is used for test purpose.
func (w *HotCache) CleanCache() {
w.writeCache.removeAllItem()
w.readCache.removeAllItem()
}
12 changes: 12 additions & 0 deletions pkg/statistics/hot_peer_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,18 @@ func (f *hotPeerCache) removeItem(item *HotPeerStat) {
}
}

// removeAllItem removes all items of the cache.
// It is used for test.
func (f *hotPeerCache) removeAllItem() {
for _, peers := range f.peersOfStore {
for _, peer := range peers.GetAll() {
item := peer.(*HotPeerStat)
item.actionType = utils.Remove
f.updateStat(item)
}
}
}

func (f *hotPeerCache) coldItem(newItem, oldItem *HotPeerStat) {
newItem.HotDegree = oldItem.HotDegree - 1
newItem.AntiCount = oldItem.AntiCount - 1
Expand Down
Loading

0 comments on commit ab3025c

Please sign in to comment.