Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KAFKA-13234; Transaction system test should clear URPs after broker restarts #11267

Merged
merged 8 commits into from
Sep 1, 2021
2 changes: 1 addition & 1 deletion tests/docker/ducker-ak
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ ducker_test() {
(test -f ./gradlew || gradle) && ./gradlew systemTestLibs
must_popd
if [[ "${debug}" -eq 1 ]]; then
local ducktape_cmd="python3.7 -m debugpy --listen 0.0.0.0:${debugpy_port} --wait-for-client /usr/local/bin/ducktape"
local ducktape_cmd="python3 -m debugpy --listen 0.0.0.0:${debugpy_port} --wait-for-client /usr/local/bin/ducktape"
else
local ducktape_cmd="ducktape"
fi
Expand Down
26 changes: 26 additions & 0 deletions tests/kafkatest/services/kafka/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,32 @@ def delete_topic(self, topic, node=None):
self.logger.info("Running topic delete command...\n%s" % cmd)
node.account.ssh(cmd)

def has_under_replicated_partitions(self):
return len(self.describe_under_replicated_partitions()) > 0

def describe_under_replicated_partitions(self):
"""Use the topic tool to find the under-replicated partitions in the cluster.
:return the under-replicated partitions as a list of dictionaries
(e.g. [{"topic": "foo", "partition": 1}, {"topic": "bar", "partition": 0}, ... ]
"""

node = self.nodes[0]
force_use_zk_connection = not self.all_nodes_topic_command_supports_bootstrap_server()

cmd = fix_opts_for_new_jvm(node)
cmd += "%s --describe --under-replicated-partitions" % \
self.kafka_topics_cmd_with_optional_security_settings(node, force_use_zk_connection)

self.logger.debug("Running topic command to describe under-replicated-partitions\n%s" % cmd)
output = ""
for line in node.account.ssh_capture(cmd):
output += line

under_replicated_partitions = self.parse_describe_topic(output)["partitions"]
self.logger.debug("Found %d under-replicated-partitions" % len(under_replicated_partitions))

return under_replicated_partitions

def describe_topic(self, topic, node=None):
if node is None:
node = self.nodes[0]
Expand Down
4 changes: 4 additions & 0 deletions tests/kafkatest/tests/core/transactions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def bounce_brokers(self, clean_shutdown):
time.sleep(brokerSessionTimeoutSecs + gracePeriodSecs)
self.kafka.start_node(node)

wait_until(lambda: not self.kafka.has_under_replicated_partitions(),
hachikuji marked this conversation as resolved.
Show resolved Hide resolved
timeout_sec = 30,
err_msg="Timed out waiting for under-replicated-partitions to clear after bouncing broker %s" % str(node.account))

def create_and_start_message_copier(self, input_topic, input_partition, output_topic, transactional_id, use_group_metadata):
message_copier = TransactionalMessageCopier(
context=self.test_context,
Expand Down