smjn commented on code in PR #19774: URL: https://github.com/apache/kafka/pull/19774#discussion_r2099537447
########## tests/kafkatest/tests/core/share_group_command_test.py: ########## @@ -0,0 +1,128 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from ducktape.utils.util import wait_until +from ducktape.tests.test import Test +from ducktape.mark import matrix +from ducktape.mark.resource import cluster + +from kafkatest.services.kafka import KafkaService, quorum +from kafkatest.services.console_share_consumer import ConsoleShareConsumer +from kafkatest.services.security.security_config import SecurityConfig + +import os +import re + +TOPIC = "topic-share-group-command" + + +class ShareGroupCommandTest(Test): + """ + Tests ShareGroupCommand + """ + # Root directory for persistent output + PERSISTENT_ROOT = "/mnt/share_group_command" + COMMAND_CONFIG_FILE = os.path.join(PERSISTENT_ROOT, "command.properties") + + def __init__(self, test_context): + super(ShareGroupCommandTest, self).__init__(test_context) + self.num_brokers = 1 + self.topics = { + TOPIC: {'partitions': 1, 'replication-factor': 1} + } + + def start_kafka(self, security_protocol, interbroker_security_protocol): + self.kafka = KafkaService( + self.test_context, self.num_brokers, + None, security_protocol=security_protocol, + interbroker_security_protocol=interbroker_security_protocol, topics=self.topics, + controller_num_nodes_override=self.num_brokers) + self.kafka.start() + + def start_share_consumer(self): + self.share_consumer = ConsoleShareConsumer(self.test_context, num_nodes=self.num_brokers, kafka=self.kafka, topic=TOPIC, + share_consumer_timeout_ms=None) + self.share_consumer.start() + + def setup_and_verify(self, security_protocol, group=None, describe_members=False): + self.start_kafka(security_protocol, security_protocol) + self.start_share_consumer() + share_consumer_node = self.share_consumer.nodes[0] + wait_until(lambda: self.share_consumer.alive(share_consumer_node), + timeout_sec=20, backoff_sec=.2, err_msg="Share consumer was too slow to start") + kafka_node = self.kafka.nodes[0] + if security_protocol is not SecurityConfig.PLAINTEXT: + prop_file = str(self.kafka.security_config.client_config()) + self.logger.debug(prop_file) + kafka_node.account.ssh("mkdir -p %s" % self.PERSISTENT_ROOT, allow_fail=False) + kafka_node.account.create_file(self.COMMAND_CONFIG_FILE, prop_file) + + # Verify ShareConsumerGroupCommand lists expected consumer groups + command_config_file = self.COMMAND_CONFIG_FILE + + if group: + if describe_members: + def has_expected_share_group_member(): + output = self.kafka.describe_share_group_members(group=group,node=kafka_node,command_config=command_config_file) + return len(output) == 1 and all("test-share-group" in line for line in output) + wait_until(has_expected_share_group_member,timeout_sec=10, err_msg="Timed out waiting to describe members of the share group.") Review Comment: nit: some formatting issues are present - no space after `,` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org