Fix flaky test in BalancerHandlerTest
#717
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Source: https://github.com/skiptests/astraea/actions/runs/3060745599/jobs/4939630645#step:5:509
BalancerHandlerTest
裡面有一段邏輯在確保被改變的 topics 數量是 2 個,但是經常發生數量是 0 的情況。被改變的數量是0的源頭是找不到可用的計劃,目前測試裡面是使用
ReplicaSizeCost
來找計劃,而且目前邏輯直接拿第一個計劃來當做結果,加上計劃完全隨機產生,直覺上這樣測試不太能總是通過。這個 PR 採用的修正是,使用一個總是回傳更好分數的 ClusterCost,確保更好的計劃被提出這件事總是成立。這樣做對確認 BalancerHandler 回傳的結果是否正確不影響。