This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new a310bcb5c6e MINOR: system-tests: fix KafkaServer#leader (#22168)
a310bcb5c6e is described below
commit a310bcb5c6eb421351a38fbad1504c0d0174779c
Author: Gaurav Narula <[email protected]>
AuthorDate: Tue Apr 28 18:27:57 2026 +0100
MINOR: system-tests: fix KafkaServer#leader (#22168)
PR #7136 standardised the output format for TopicCommand to print `none`
when the leader for a TP is unknown. `KafkaServer#leader` in
system-tests however fails to account for this change and possibly
panics trying to type cast `none` to an integer.
This change fixes the regression so that we parse the value correctly
and return None if the leader is undefined.
Reviewers: Chia-Ping Tsai <[email protected]>, Federico Valeri
<[email protected]>
---
tests/kafkatest/services/kafka/kafka.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/kafkatest/services/kafka/kafka.py
b/tests/kafkatest/services/kafka/kafka.py
index be5a5201ce4..8d98b96e283 100644
--- a/tests/kafkatest/services/kafka/kafka.py
+++ b/tests/kafkatest/services/kafka/kafka.py
@@ -1657,10 +1657,11 @@ class KafkaService(KafkaPathResolverMixin, JmxMixin,
Service):
# e.g. Topic: test_topic Partition: 0 Leader: 3
Replicas: 3,2 Isr: 3,2
if not requested_partition_line:
raise Exception("Error finding partition state for topic %s
and partition %d." % (topic, partition))
- leader_idx = int(requested_partition_line.split()[5]) # 6th column
from above
+ leader_idx_str = requested_partition_line.split()[5] # 6th column
from above
+ leader_idx = int(leader_idx_str) if leader_idx_str != "none" else
None
- self.logger.info("Leader for topic %s and partition %d is now: %d" %
(topic, partition, leader_idx))
- return self.get_node(leader_idx)
+ self.logger.info("Leader for topic %s and partition %d is now: %s" %
(topic, partition, leader_idx))
+ return self.get_node(leader_idx) if leader_idx is not None and
leader_idx != -1 else None
def cluster_id(self):
""" Get the current cluster id