AndrewJSchofield commented on code in PR #19836:
URL: https://github.com/apache/kafka/pull/19836#discussion_r2113597258


##########
tests/kafkatest/sanity_checks/test_performance_services.py:
##########
@@ -73,8 +75,24 @@ def test_version(self, version=str(LATEST_2_1), 
metadata_quorum=quorum.zk):
         consumer_perf_data = compute_aggregate_throughput(self.consumer_perf)
         assert consumer_perf_data['records_per_sec'] > 0
 
-        return {
+        results = {
             "producer_performance": producer_perf_data,
             "end_to_end_latency": end_to_end_data,
-            "consumer_performance": consumer_perf_data
+            "consumer_performance": consumer_perf_data,
         }
+
+        if version >= V_4_0_0:

Review Comment:
   This should be `V_4_1_0`.



##########
tests/kafkatest/services/performance/share_consumer_performance.py:
##########
@@ -0,0 +1,133 @@
+# 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.
+
+
+import os
+
+from kafkatest.services.kafka.util import fix_opts_for_new_jvm, 
get_log4j_config_param, get_log4j_config_for_tools
+from kafkatest.services.performance import PerformanceService
+from kafkatest.version import DEV_BRANCH
+
+
+class ShareConsumerPerformanceService(PerformanceService):
+    """
+        See ShareConsumerPerformance tool as the source of truth on these 
settings, but for reference:
+
+        "topic", "REQUIRED: The topic to consume from."
+
+        "group", "The group id to consume on."
+
+        "fetch-size", "The amount of data to fetch in a single request."
+
+        "socket-buffer-size", "The size of the tcp RECV size."
+
+        "consumer.config", "Consumer config properties file."
+    """
+
+    # Root directory for persistent output
+    PERSISTENT_ROOT = "/mnt/share_consumer_performance"
+    LOG_DIR = os.path.join(PERSISTENT_ROOT, "logs")
+    STDOUT_CAPTURE = os.path.join(PERSISTENT_ROOT, 
"share_consumer_performance.stdout")
+    STDERR_CAPTURE = os.path.join(PERSISTENT_ROOT, 
"share_consumer_performance.stderr")
+    LOG_FILE = os.path.join(LOG_DIR, "share_consumer_performance.log")
+    CONFIG_FILE = os.path.join(PERSISTENT_ROOT, "share_consumer.properties")
+
+    logs = {
+        "share_consumer_performance_output": {
+            "path": STDOUT_CAPTURE,
+            "collect_default": True},
+        "share_consumer_performance_stderr": {
+            "path": STDERR_CAPTURE,
+            "collect_default": True},
+        "share_consumer_performance_log": {
+            "path": LOG_FILE,
+            "collect_default": True}
+    }
+
+    def __init__(self, context, num_nodes, kafka, topic, messages, 
group="perf-share-consumer", version=DEV_BRANCH, timeout=10000, settings={}):
+        super(ShareConsumerPerformanceService, self).__init__(context, 
num_nodes)
+        self.kafka = kafka
+        self.security_config = kafka.security_config.client_config()
+        self.topic = topic
+        self.messages = messages
+        self.settings = settings
+        self.group = group
+        self.timeout = timeout
+
+        # These less-frequently used settings can be updated manually after 
instantiation
+        self.fetch_size = None
+        self.socket_buffer_size = None
+
+        for node in self.nodes:
+            node.version = version
+
+    def args(self):
+        """Dictionary of arguments used to start the Share Consumer 
Performance script."""
+        args = {
+            'topic': self.topic,
+            'messages': self.messages,
+            'bootstrap-server': 
self.kafka.bootstrap_servers(self.security_config.security_protocol),
+            'group': self.group,
+            'timeout': self.timeout
+        }
+
+        if self.fetch_size is not None:
+            args['fetch-size'] = self.fetch_size
+
+        if self.socket_buffer_size is not None:
+            args['socket-buffer-size'] = self.socket_buffer_size
+
+        return args
+
+    def start_cmd(self, node):
+        cmd = fix_opts_for_new_jvm(node)
+        cmd += "export LOG_DIR=%s;" % ShareConsumerPerformanceService.LOG_DIR
+        cmd += " export KAFKA_OPTS=%s;" % self.security_config.kafka_opts
+        cmd += " export KAFKA_LOG4J_OPTS=\"%s%s\";" % 
(get_log4j_config_param(node), get_log4j_config_for_tools(node))
+        cmd += " %s" % self.path.script("kafka-share-consumer-perf-test.sh", 
node)
+        for key, value in self.args().items():
+            cmd += " --%s %s" % (key, value)
+
+        cmd += " --consumer.config %s" % 
ShareConsumerPerformanceService.CONFIG_FILE
+
+        for key, value in self.settings.items():
+            cmd += " %s=%s" % (str(key), str(value))
+
+        cmd += " 2>> %(stderr)s | tee -a %(stdout)s" % {'stdout': 
ShareConsumerPerformanceService.STDOUT_CAPTURE,
+                                                        'stderr': 
ShareConsumerPerformanceService.STDERR_CAPTURE}
+        return cmd
+
+    def _worker(self, idx, node):
+        node.account.ssh("mkdir -p %s" % 
ShareConsumerPerformanceService.PERSISTENT_ROOT, allow_fail=False)
+
+        log_config = self.render(get_log4j_config_for_tools(node), 
log_file=ShareConsumerPerformanceService.LOG_FILE)
+        node.account.create_file(get_log4j_config_for_tools(node), log_config)
+        node.account.create_file(ShareConsumerPerformanceService.CONFIG_FILE, 
str(self.security_config))
+        self.security_config.setup_node(node)
+
+        cmd = self.start_cmd(node)
+        self.logger.debug("Share Consumer performance %d command: %s", idx, 
cmd)

Review Comment:
   nit: "consumer" please.



##########
tests/kafkatest/services/kafka/kafka.py:
##########
@@ -1749,6 +1749,29 @@ def list_consumer_groups(self, node=None, 
command_config=None, state=None, type=
         if type is not None:
             cmd += " --type %s" % type
         return self.run_cli_tool(node, cmd)
+    
+    def set_group_offset_reset_strategy(self, group, strategy=None, node=None, 
command_config=None):
+        """ Set the offset reset strategy config for the given group.
+        """
+        if strategy is None:
+            return
+        if node is None:
+            node = self.nodes[0]
+        consumer_group_script = self.path.script("kafka-configs.sh", node)

Review Comment:
   How about `config_script`? This code has nothing to do with consumer groups.



##########
tests/kafkatest/benchmarks/core/benchmark_test.py:
##########
@@ -273,6 +342,62 @@ def test_consumer_throughput(self, 
compression_type="none", security_protocol="P
         self.consumer.group = "test-consumer-group"
         self.consumer.run()
         return compute_aggregate_throughput(self.consumer)
+    
+    @cluster(num_nodes=8)
+    @matrix(security_protocol=['SSL'], 
interbroker_security_protocol=['PLAINTEXT'], tls_version=['TLSv1.2', 'TLSv1.3'],
+            compression_type=["none", "snappy"], 
metadata_quorum=[quorum.isolated_kraft], use_share_groups=[True])
+    @matrix(security_protocol=['PLAINTEXT'], compression_type=["none", 
"snappy"], metadata_quorum=[quorum.isolated_kraft], 
+            use_share_groups=[True])
+    def test_share_consumer_throughput(self, compression_type="none", 
security_protocol="PLAINTEXT", tls_version=None,
+                                 interbroker_security_protocol=None, 
num_consumers=1, client_version=str(DEV_BRANCH), 
+                                 broker_version=str(DEV_BRANCH), 
metadata_quorum=quorum.isolated_kraft, use_share_groups=True):
+        """
+        Consume 1e6 100-byte messages with 1 or more consumers from a topic 
with 6 partitions
+        and report throughput.
+        """
+        client_version = KafkaVersion(client_version)
+        broker_version = KafkaVersion(broker_version)
+        self.validate_versions(client_version, broker_version)
+        if interbroker_security_protocol is None:
+            interbroker_security_protocol = security_protocol
+        self.start_kafka(security_protocol, interbroker_security_protocol, 
broker_version, tls_version)
+        num_records = 1000 * 1000  # 1e6
+
+        # seed kafka w/messages
+        self.producer = ProducerPerformanceService(
+            self.test_context, 1, self.kafka,
+            topic=TOPIC_REP_THREE,
+            num_records=num_records, record_size=DEFAULT_RECORD_SIZE, 
throughput=-1, version=client_version,
+            settings={
+                'acks': 1,
+                'compression.type': compression_type,
+                'batch.size': self.batch_size,
+                'buffer.memory': self.buffer_memory
+            }
+        )
+        self.producer.run()
+
+        share_group = "test-share-consumer-group"
+
+        kafka_node = self.kafka.nodes[0]
+        PERSISTENT_ROOT = "/mnt/share_consumer_performance"
+        COMMAND_CONFIG_FILE = os.path.join(PERSISTENT_ROOT, 
"command.properties")
+
+        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" % PERSISTENT_ROOT, 
allow_fail=False)
+            kafka_node.account.create_file(COMMAND_CONFIG_FILE, prop_file)
+
+        wait_until(lambda: 
self.kafka.set_group_offset_reset_strategy(group=share_group, 
strategy="earliest", command_config=COMMAND_CONFIG_FILE),
+                   timeout_sec=20, backoff_sec=2, err_msg="auto.offset.reset 
not set to earliest")

Review Comment:
   `share.auto.offset.reset` because it's specific to share groups.



-- 
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

Reply via email to