aliehsaeedii commented on code in PR #22769:
URL: https://github.com/apache/kafka/pull/22769#discussion_r3535796837


##########
tests/kafkatest/tests/streams/streams_topology_description_plugin_test.py:
##########
@@ -0,0 +1,122 @@
+# 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 time
+
+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 (
+    INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS,
+    StreamsTopologyDescriptionPluginService,
+)
+
+
+class StreamsTopologyDescriptionPluginTest(Test):
+
+    PUSH_REQUESTED_LOG = "Broker requested topology description push"
+    PUSH_SENDING_LOG = "Sending topology description for group"
+    PUSH_SUCCESS_LOG = "Topology description pushed successfully"
+
+    SOURCE_TOPIC = "topologyDescriptionPluginSource"
+    SINK_TOPIC = "topologyDescriptionPluginSink"
+
+    def __init__(self, test_context):
+        super(StreamsTopologyDescriptionPluginTest, 
self).__init__(test_context=test_context)
+        self.topics = {
+            self.SOURCE_TOPIC: {"partitions": 1, "replication-factor": 1},
+            self.SINK_TOPIC: {"partitions": 1, "replication-factor": 1},
+        }
+
+    def setup_kafka(self, plugin_enabled):
+        server_prop_overrides = [
+            ["group.streams.min.session.timeout.ms", "10000"],
+            ["group.streams.session.timeout.ms", "10000"],
+        ]
+        if plugin_enabled:
+            server_prop_overrides.append(
+                ["group.streams.topology.description.plugin.class", 
INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS])
+        self.kafka = KafkaService(
+            self.test_context,
+            num_nodes=1,
+            zk=None,
+            topics=self.topics,
+            use_streams_groups=True,
+            server_prop_overrides=server_prop_overrides,
+        )
+        self.kafka.start()
+        self.kafka.run_features_command("upgrade", "streams.version", 1)
+
+    @cluster(num_nodes=2)
+    @matrix(metadata_quorum=[quorum.combined_kraft])
+    def test_topology_description_available_with_plugin(self, metadata_quorum):
+        """
+        Test the situation when the broker has the topology description plugin 
configured
+        and the client pushes by default. The broker should solicit a push and 
the client
+        should complete it successfully.
+        """
+        self.setup_kafka(plugin_enabled=True)
+        processor = StreamsTopologyDescriptionPluginService(self.test_context, 
self.kafka)
+        with processor.node.account.monitor_log(processor.LOG_FILE) as monitor:
+            processor.start()
+            monitor.wait_until(self.PUSH_SUCCESS_LOG,
+                               timeout_sec=120,
+                               err_msg="Streams client did not log a 
successful topology description push")
+        processor.stop()
+
+    @cluster(num_nodes=2)
+    @matrix(metadata_quorum=[quorum.combined_kraft])
+    def test_topology_description_not_stored_when_client_opts_out(self, 
metadata_quorum):
+        """
+        Test the situation when the broker has the topology description plugin 
configured
+        but the client opts out via topology.description.push.enabled=false. 
The client
+        should never send a topology description even though the broker 
solicits one.
+        """
+        self.setup_kafka(plugin_enabled=True)
+        processor = StreamsTopologyDescriptionPluginService(
+            self.test_context, self.kafka, 
topology_description_push_enabled=False)
+        processor.start()
+        time.sleep(30)

Review Comment:
   The two negative tests can pass vacuously: `processor.start()` only waits 
for `STREAMS-STARTED`, which is printed right after `KafkaStreams#start()` 
returns — before the client has joined the streams group. If the app crashes or 
never manages to join during the 30s sleep, the `grep -c == 0` assertions still 
pass even though nothing was actually verified.
   
   Consider waiting for a positive liveness signal before doing the negative 
grep — e.g. wait for the `State transition from REBALANCING to RUNNING` line in 
the streams log (which implies successful heartbeats with the coordinator), and 
only then assert the push logs are absent. Same applies to 
`test_topology_description_not_stored_without_plugin` below.



##########
tests/kafkatest/tests/streams/streams_topology_description_plugin_test.py:
##########
@@ -0,0 +1,122 @@
+# 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 time
+
+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 (
+    INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS,
+    StreamsTopologyDescriptionPluginService,
+)
+
+
+class StreamsTopologyDescriptionPluginTest(Test):
+
+    PUSH_REQUESTED_LOG = "Broker requested topology description push"
+    PUSH_SENDING_LOG = "Sending topology description for group"
+    PUSH_SUCCESS_LOG = "Topology description pushed successfully"
+
+    SOURCE_TOPIC = "topologyDescriptionPluginSource"
+    SINK_TOPIC = "topologyDescriptionPluginSink"
+
+    def __init__(self, test_context):
+        super(StreamsTopologyDescriptionPluginTest, 
self).__init__(test_context=test_context)
+        self.topics = {
+            self.SOURCE_TOPIC: {"partitions": 1, "replication-factor": 1},
+            self.SINK_TOPIC: {"partitions": 1, "replication-factor": 1},
+        }
+
+    def setup_kafka(self, plugin_enabled):
+        server_prop_overrides = [
+            ["group.streams.min.session.timeout.ms", "10000"],
+            ["group.streams.session.timeout.ms", "10000"],
+        ]
+        if plugin_enabled:
+            server_prop_overrides.append(
+                ["group.streams.topology.description.plugin.class", 
INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS])
+        self.kafka = KafkaService(
+            self.test_context,
+            num_nodes=1,
+            zk=None,
+            topics=self.topics,
+            use_streams_groups=True,
+            server_prop_overrides=server_prop_overrides,
+        )
+        self.kafka.start()
+        self.kafka.run_features_command("upgrade", "streams.version", 1)
+
+    @cluster(num_nodes=2)
+    @matrix(metadata_quorum=[quorum.combined_kraft])
+    def test_topology_description_available_with_plugin(self, metadata_quorum):
+        """
+        Test the situation when the broker has the topology description plugin 
configured
+        and the client pushes by default. The broker should solicit a push and 
the client
+        should complete it successfully.
+        """
+        self.setup_kafka(plugin_enabled=True)
+        processor = StreamsTopologyDescriptionPluginService(self.test_context, 
self.kafka)
+        with processor.node.account.monitor_log(processor.LOG_FILE) as monitor:
+            processor.start()
+            monitor.wait_until(self.PUSH_SUCCESS_LOG,
+                               timeout_sec=120,
+                               err_msg="Streams client did not log a 
successful topology description push")
+        processor.stop()
+
+    @cluster(num_nodes=2)
+    @matrix(metadata_quorum=[quorum.combined_kraft])
+    def test_topology_description_not_stored_when_client_opts_out(self, 
metadata_quorum):
+        """
+        Test the situation when the broker has the topology description plugin 
configured
+        but the client opts out via topology.description.push.enabled=false. 
The client
+        should never send a topology description even though the broker 
solicits one.

Review Comment:
   Nit on the docstring: "even though the broker solicits one" is true 
broker-side, but it isn't observable in this test. When the client opts out, 
`StreamThread` never sets the wire topology description, so the `Broker 
requested topology description push` log in 
`StreamsGroupHeartbeatRequestManager` is suppressed too (the condition requires 
a non-null wire description). Maybe reword so a future reader doesn't try to 
assert `PUSH_REQUESTED_LOG > 0` here and get confused when it's 0.



##########
tests/kafkatest/tests/streams/streams_broker_compatibility_test.py:
##########
@@ -45,7 +48,8 @@ def __init__(self, test_context):
                                   },
                                   server_prop_overrides=[
                                       
["transaction.state.log.replication.factor", "1"],
-                                      ["transaction.state.log.min.isr", "1"]
+                                      ["transaction.state.log.min.isr", "1"],
+                                      
["group.streams.topology.description.plugin.class", 
INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS]

Review Comment:
   The PR description says the plugin is enabled "for DEV_VERSION", but this 
override applies to every broker version in the matrix. It happens to work 
because `group.streams.topology.description.plugin.class` only exists on trunk 
(not in 4.3 or earlier), so older brokers just log an unknown-config warning 
and ignore it — but that's subtle enough to deserve an inline comment.
   
   Also, since `StreamsBrokerCompatibilityService` runs with the classic 
protocol (no streams groups exist in this test), the plugin is instantiated but 
never exercised. Could you clarify what this addition is meant to verify — that 
a DEV broker with the plugin configured doesn't affect classic-protocol streams 
apps? A short comment stating that intent would help.



##########
tests/kafkatest/tests/streams/streams_broker_compatibility_test.py:
##########
@@ -58,9 +62,10 @@ def __init__(self, test_context):
     
@matrix(broker_version=[str(LATEST_3_0),str(LATEST_3_1),str(LATEST_3_2),str(LATEST_3_3),
                             
str(LATEST_3_4),str(LATEST_3_5),str(LATEST_3_6),str(LATEST_3_7),
                             
str(LATEST_3_8),str(LATEST_3_9),str(LATEST_4_0),str(LATEST_4_1),
-                            str(LATEST_4_2),str(LATEST_4_3)],
+                            str(LATEST_4_2),str(LATEST_4_3),str(DEV_BRANCH)],
             metadata_quorum=[quorum.combined_kraft]
             )
+    

Review Comment:
   Stray whitespace-only line added between the `@matrix` decorator and the 
test method — please remove.



##########
tests/kafkatest/tests/streams/streams_topology_description_plugin_test.py:
##########
@@ -0,0 +1,122 @@
+# 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 time
+
+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 (
+    INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS,
+    StreamsTopologyDescriptionPluginService,
+)
+
+
+class StreamsTopologyDescriptionPluginTest(Test):
+
+    PUSH_REQUESTED_LOG = "Broker requested topology description push"
+    PUSH_SENDING_LOG = "Sending topology description for group"
+    PUSH_SUCCESS_LOG = "Topology description pushed successfully"
+
+    SOURCE_TOPIC = "topologyDescriptionPluginSource"
+    SINK_TOPIC = "topologyDescriptionPluginSink"
+
+    def __init__(self, test_context):
+        super(StreamsTopologyDescriptionPluginTest, 
self).__init__(test_context=test_context)
+        self.topics = {
+            self.SOURCE_TOPIC: {"partitions": 1, "replication-factor": 1},
+            self.SINK_TOPIC: {"partitions": 1, "replication-factor": 1},
+        }
+
+    def setup_kafka(self, plugin_enabled):
+        server_prop_overrides = [
+            ["group.streams.min.session.timeout.ms", "10000"],
+            ["group.streams.session.timeout.ms", "10000"],
+        ]
+        if plugin_enabled:
+            server_prop_overrides.append(
+                ["group.streams.topology.description.plugin.class", 
INMEMORY_TOPOLOGY_DESCRIPTION_PLUGIN_CLASS])
+        self.kafka = KafkaService(
+            self.test_context,
+            num_nodes=1,
+            zk=None,
+            topics=self.topics,
+            use_streams_groups=True,
+            server_prop_overrides=server_prop_overrides,
+        )
+        self.kafka.start()
+        self.kafka.run_features_command("upgrade", "streams.version", 1)
+
+    @cluster(num_nodes=2)
+    @matrix(metadata_quorum=[quorum.combined_kraft])
+    def test_topology_description_available_with_plugin(self, metadata_quorum):

Review Comment:
   Are follow-up scenarios planned for the plugin lifecycle? Three come to mind 
that the in-memory plugin makes observable with exactly the infrastructure this 
PR adds:
   
   1. Broker bounce → re-solicitation: the `InMemoryTopologyDescriptionPlugin` 
loses its state on restart, so after a bounce the broker should solicit again 
and the client should push a second time (happy-path push → bounce → wait for a 
second `Topology description pushed successfully`).
   2. Client restart with the description already stored: restart only the 
streams app while the broker keeps running — since 
`storedDescriptionTopologyEpoch == currentTopologyEpoch`, the broker should 
*not* solicit again.
   3. Multiple members, single push: with 2+ clients in the group, the 
solicitation back-off (`StreamsGroupTopologyDescriptionManager.armIfNotActive`) 
should prevent every member from pushing the same description — e.g. assert the 
second member never sends while the first push succeeds.
   
   No need to grow this PR — just wondering whether these are on the part-2 
list.



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