Copilot commented on code in PR #22561:
URL: https://github.com/apache/kafka/pull/22561#discussion_r3419014086


##########
tests/kafkatest/tests/streams/streams_static_membership_streams_protocol_test.py:
##########
@@ -0,0 +1,192 @@
+# 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.
+
+import re
+
+from ducktape.mark import matrix
+from ducktape.mark.resource import cluster
+from ducktape.tests.test import Test
+
+from kafkatest.services.kafka import KafkaService, quorum
+from kafkatest.services.streams import 
StaticMemberPersistentProcessIdTestService
+from kafkatest.services.verifiable_producer import VerifiableProducer
+from kafkatest.tests.streams.utils import verify_running, verify_stopped, 
stop_processors
+
+
+class StreamsStaticMembershipStreamsProtocolTest(Test):
+    """
+    Streams group protocol specific static membership test.
+    This test verifies the following behavior under the streams group protocol:
+
+    1. The bounced static member reuses the same persisted processId.
+    2. Surviving members do not reconcile because of another member's 
temporary bounce.
+    """
+
+    input_topic = "inputTopic"
+    running_message = "REBALANCING -> RUNNING"
+    stopped_message = "Static membership persistent-process-id test closed"
+    processed_message = "PROCESSED"
+
+    num_threads = 3
+    num_bounces = 3
+    group_protocol = "streams"
+
+    initial_process_id_pattern = re.compile(r"No process id found on disk, got 
fresh process id ([0-9a-fA-F-]+)")
+    random_process_id_pattern = re.compile(r"Created new process id: 
([0-9a-fA-F-]+)")
+    reused_process_id_pattern = re.compile(r"Reading UUID from process file: 
([0-9a-fA-F-]+)")
+
+    def __init__(self, test_context):
+        super(StreamsStaticMembershipStreamsProtocolTest, 
self).__init__(test_context)
+        self.topics = {
+            self.input_topic: {"partitions": 18},
+        }
+
+        self.kafka = KafkaService(self.test_context, num_nodes=3,
+                                  zk=None, topics=self.topics, 
controller_num_nodes_override=1)
+
+        self.producer = VerifiableProducer(self.test_context,
+                                           1,
+                                           self.kafka,
+                                           self.input_topic,
+                                           throughput=1000,
+                                           acks=1)
+
+    @cluster(num_nodes=8)
+    @matrix(metadata_quorum=[quorum.isolated_kraft])
+    def 
test_temporary_static_rejoin_does_not_trigger_survivor_reconciliation(self, 
metadata_quorum):
+        self.kafka.start()
+
+        processor1 = 
StaticMemberPersistentProcessIdTestService(self.test_context, self.kafka, 
"consumer-A", self.num_threads, self.group_protocol)
+        processor2 = 
StaticMemberPersistentProcessIdTestService(self.test_context, self.kafka, 
"consumer-B", self.num_threads, self.group_protocol)
+        processor3 = 
StaticMemberPersistentProcessIdTestService(self.test_context, self.kafka, 
"consumer-C", self.num_threads, self.group_protocol)
+
+        processors = [processor1, processor2, processor3]
+
+        self.producer.start()
+
+        for processor in processors:
+            processor.CLEAN_NODE_ENABLED = False
+            processor.INPUT_TOPIC = self.input_topic
+            verify_running(processor, self.running_message)
+
+        self.verify_processing(processors)
+
+        baseline_process_ids = {
+            processor: self.assert_initial_process_id_persisted(processor)
+            for processor in processors
+        }
+
+        for _ in range(self.num_bounces):
+            for bounced in processors:
+                checkpoints = {
+                    processor: {
+                        "log": self._line_count(processor, processor.LOG_FILE),
+                        "stdout": self._line_count(processor, 
processor.STDOUT_FILE),
+                    }
+                    for processor in processors
+                }
+
+                verify_stopped(bounced, self.stopped_message)
+                verify_running(bounced, self.running_message)
+
+                self.assert_same_process_id_reused(bounced, 
checkpoints[bounced]["log"], baseline_process_ids[bounced])
+
+                for survivor in processors:
+                    if survivor is bounced:
+                        continue
+                    self.assert_survivor_was_unaffected(survivor, 
checkpoints[survivor]["log"])

Review Comment:
   `checkpoints` captures both log and stdout line counts, but only the log 
checkpoint is used. The extra stdout `awk` call adds SSH overhead inside the 
bounce loops without affecting assertions; simplifying this avoids unnecessary 
remote commands and makes the intent clearer.



##########
streams/src/test/java/org/apache/kafka/streams/tests/StaticMemberPersistentProcessIdTestClient.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package org.apache.kafka.streams.tests;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.common.serialization.Serdes;
+import org.apache.kafka.common.utils.internals.Exit;
+import org.apache.kafka.common.utils.Utils;
+import org.apache.kafka.streams.KafkaStreams;
+import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.StreamsConfig;
+import org.apache.kafka.streams.kstream.KStream;
+import org.apache.kafka.streams.kstream.Materialized;
+import org.apache.kafka.streams.state.KeyValueBytesStoreSupplier;
+import org.apache.kafka.streams.state.Stores;
+
+import java.util.Objects;
+import java.util.Properties;
+
+public class StaticMemberPersistentProcessIdTestClient {
+
+    private static final String TEST_NAME = 
"StaticMemberPersistentProcessIdTestClient";
+
+    @SuppressWarnings("unchecked")
+    public static void main(final String[] args) throws Exception {
+        if (args.length < 1) {
+            System.err.println(TEST_NAME + " requires one argument 
(properties-file) but none provided: ");
+        }
+
+        System.out.println("StreamsTest instance started");
+
+        final String propFileName = args[0];
+        final Properties streamsProperties = Utils.loadProps(propFileName);

Review Comment:
   The argument length check prints an error but then continues and 
unconditionally reads `args[0]`, which would throw 
`ArrayIndexOutOfBoundsException` if the class is ever invoked incorrectly (and 
can also proceed if `Exit.exit` is overridden in tests). Consider exiting early 
after reporting the error.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to