Skip to content

Commit

Permalink
tests: relax check in AutomaticLeadershipBalancingTest
Browse files Browse the repository at this point in the history
  • Loading branch information
ztlpn committed May 16, 2024
1 parent 5e03f89 commit e68016b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/rptest/tests/leadership_transfer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,15 @@ def all_partitions_present(num_nodes, per_node=None):
err_msg="Leadership did not stablize")

shard2leaders = self._get_leaders_by_shard()
self.redpanda.logger.debug(f"Leaders by shard: {shard2leaders}")
expected_on_shard = sum(shard2leaders.values()) / len(shard2leaders)
expected_on_shard = sum(shard2leaders.values()) / (
len(self.redpanda.nodes) * self.redpanda.get_node_cpu_count())
self.redpanda.logger.info(
f"Leaders by shard: avg: {expected_on_shard}, min: {min(shard2leaders.values())}"
f", full stats: {shard2leaders}")
for s, count in shard2leaders.items():
expected_min = math.floor(expected_on_shard * 0.8)
# Check with a lot of slack because leader balancer may not be able to achieve
# balanced counts due to interplay between topic-aware and total counts
# objectives. See https://github.com/redpanda-data/core-internal/issues/1282
expected_min = math.floor(expected_on_shard * 0.5)
assert count >= expected_min, \
f"leader count on shard {s} ({count}) is < {expected_min}"

0 comments on commit e68016b

Please sign in to comment.