Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: reduce mcs test duration #7435

Merged
merged 16 commits into from
Dec 8, 2023
Merged
6 changes: 6 additions & 0 deletions pkg/schedule/operator/operator_controller.go
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,12 @@
}
}

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

Check warning on line 805 in pkg/schedule/operator/operator_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/schedule/operator/operator_controller.go#L805

Added line #L805 was not covered by tests
}

// 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
Loading