Skip to content

Commit

Permalink
Merge pull request redpanda-data#17145 from bharathv/topic_aware_fix
Browse files Browse the repository at this point in the history
ducktape: deflake test_topic_aware_rebalance in debug mode
  • Loading branch information
bharathv authored Mar 18, 2024
2 parents 0ecbec8 + 9c82ef6 commit dc7b8d8
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions tests/rptest/tests/leadership_transfer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,20 @@ def test_self_transfer(self):


class MultiTopicAutomaticLeadershipBalancingTest(RedpandaTest):
topics = (
TopicSpec(partition_count=61, replication_factor=3),
TopicSpec(partition_count=151, replication_factor=3),
TopicSpec(partition_count=263, replication_factor=3),
)

def __init__(self, test_context):
extra_rp_conf = dict(leader_balancer_idle_timeout=20000,
leader_balancer_mode="random_hill_climbing")

super(MultiTopicAutomaticLeadershipBalancingTest,
self).__init__(test_context=test_context,
extra_rp_conf=extra_rp_conf)
self.topics = [
TopicSpec(partition_count=61, replication_factor=3),
TopicSpec(partition_count=151, replication_factor=3),
]
if not self.debug_mode:
self.topics.append(
TopicSpec(partition_count=263, replication_factor=3))

@cluster(num_nodes=3, log_allow_list=RESTART_LOG_ALLOW_LIST)
def test_topic_aware_rebalance(self):
Expand All @@ -132,10 +133,25 @@ def all_partitions_present(nodes: int):
total_leaders = sum(1 if t.leader else 0 for t in tps)
total_nodes = set(t.leader for t in tps if t.leader)

self.logger.debug(
f"Topic: {t.name}, total_leaders: {total_leaders}, total_nodes: {len(total_nodes)}"
)

if len(total_nodes) < nodes:
self.logger.debug(
f"Fewer nodes: {len(total_nodes)} than expected: {nodes}"
)
return False

if total_leaders != t.partition_count:
self.logger.debug(
f"Fewer leaders: {total_leaders} than expected: {t.partition_count}"
)
missing_leaders = [
f"{t.topic}/{t.index}" for t in tps if not t.leader
]
self.logger.debug(
f"partitions without leaders: {missing_leaders}")
return False

return True
Expand Down

0 comments on commit dc7b8d8

Please sign in to comment.