8000 fix(inkless:test): query topic state from a controller host in switch tests by giuseppelillo · Pull Request #917 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions tests/kafkatest/tests/inkless/inkless_topic_switch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,22 @@ def _rolling_restart(self, clean_shutdown=True, nodes=None):
if node in partition_0_replicas:
self._wait_for_broker_in_isr(node, num_partitions=1)

def _topic_query_node(self):
"""Returns the node to run ``kafka-topics`` from, or None if no node fits.

With an isolated controller quorum, the node is a controller host. The
network partitions in these tests list only brokers, so a controller
host reaches every broker. A broker can't serve as the query node while
a partition cuts off one of its peers: ``kafka-topics --describe``
sends ``ListPartitionReassignments`` to a random unfenced broker. If
that broker is unreachable, the command waits out the client timeout
although every partition has a leader.
"""
controllers = getattr(self.kafka, "isolated_controller_quorum", None)
if controllers:
return controllers.nodes[0]
return next((n for n in self.kafka.nodes if self.kafka.pids(n)), None)

def _wait_for_all_partitions_have_leaders(self, topic=None, num_partitions=None, timeout_sec=120):
if topic is None:
topic = self.topic
Expand All @@ -1233,14 +1249,10 @@ def _wait_for_all_partitions_have_leaders(self, topic=None, num_partitions=None,

def all_partitions_have_leaders():
try:
query_node = None
for candidate in self.kafka.nodes:
if self.kafka.pids(candidate):
query_node = candidate
break
query_node = self._topic_query_node()
if query_node is None:
return False
# Query once through any live broker; per-partition calls are very slow under
# Query once; per-partition calls are very slow under
# the network-degradation faults used by these tests.
describe_output = self.kafka.describe_topic(topic, node=query_node)
for p in range(num_partitions):
Expand Down Expand Up @@ -1269,11 +1281,7 @@ def _wait_for_broker_in_isr(self, node, topic=None, num_partitions=None, timeout

def broker_in_isr():
try:
query_node = None
for candidate in self.kafka.nodes:
if self.kafka.pids(candidate):
query_node = candidate
break
query_node = self._topic_query_node()
if query_node is None:
return False
for p in range(num_partitions):
Expand Down Expand Up @@ -1307,11 +1315,7 @@ def _wait_for_all_partitions_isr_full(self, topic=None, num_partitions=None, tim

def all_isr_full():
try:
query_node = None
for candidate in self.kafka.nodes:
if self.kafka.pids(candidate):
query_node = candidate
break
query_node = self._topic_query_node()
if query_node is None:
return False

Expand Down
Loading
0