C0urante commented on code in PR #14230:
URL: https://github.com/apache/kafka/pull/14230#discussion_r1297376126
##########
tests/kafkatest/directory_layout/kafka_path.py:
##########
@@ -41,14 +41,20 @@
CORE_DEPENDANT_TEST_LIBS_JAR_NAME = "core-dependant-testlibs"
TOOLS_JAR_NAME = "tools"
TOOLS_DEPENDANT_TEST_LIBS_JAR_NAME = "tools-dependant-libs"
+CONNECT_FILE_JAR = "connect-file"
JARS = {
"dev": {
CORE_JAR_NAME: "core/build/*/*.jar",
CORE_LIBS_JAR_NAME: "core/build/libs/*.jar",
CORE_DEPENDANT_TEST_LIBS_JAR_NAME:
"core/build/dependant-testlibs/*.jar",
TOOLS_JAR_NAME: "tools/build/libs/kafka-tools*.jar",
- TOOLS_DEPENDANT_TEST_LIBS_JAR_NAME: "tools/build/dependant-libs*/*.jar"
+ TOOLS_DEPENDANT_TEST_LIBS_JAR_NAME:
"tools/build/dependant-libs*/*.jar",
+ CONNECT_FILE_JAR: "connect/file/build/libs/connect-file*.jar"
+ },
+ # This version of the file connectors do not contain ServiceLoader
manifests
Review Comment:
Nit:
```suggestion
# This version of the file connectors does not contain ServiceLoader
manifests
```
##########
tests/kafkatest/services/connect.py:
##########
@@ -89,7 +89,7 @@ def pids(self, node):
except:
return []
- def set_configs(self, config_template_func,
connector_config_templates=None):
+ def set_configs(self, config_template_func, connector_config_templates=[]):
Review Comment:
Nit: It's generally advisable to avoid using mutable types for default
argument values, since a single shared value is used across all invocations of
that function.
We can do something like this instead:
```python
def set_configs(self, config_template_func,
connector_config_templates=None):
connector_config_templates = [] if connector_config_templates is
None else connector_config_templates
```
##########
tests/kafkatest/tests/connect/connect_plugin_discovery_test.py:
##########
@@ -0,0 +1,77 @@
+# 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.tests.kafka_test import KafkaTest
+from kafkatest.directory_layout.kafka_path import CONNECT_FILE_JAR
+from kafkatest.version import LATEST_3_5
+from kafkatest.services.connect import ConnectStandaloneService,
ConnectServiceBase
+from ducktape.mark import matrix
+from ducktape.mark.resource import cluster
+from ducktape.utils.util import wait_until
+
+
+class ConnectPluginDiscoveryTest(KafkaTest):
+ """
+ Test for the `plugin.discovery` configuration and accompanying
`connect-plugin-path` migration script.
+ """
+
+ FILE_SOURCE_CONNECTOR =
'org.apache.kafka.connect.file.FileStreamSourceConnector'
+ FILE_SINK_CONNECTOR =
'org.apache.kafka.connect.file.FileStreamSinkConnector'
+
+ OFFSETS_FILE = "/mnt/connect.offsets"
+ PLUGIN_PATH = "/mnt/connect-plugin-path"
+
+ def __init__(self, test_context):
+ super(ConnectPluginDiscoveryTest, self).__init__(test_context,
num_zk=1, num_brokers=1)
+
+ self.cc = ConnectStandaloneService(test_context, self.kafka,
[self.PLUGIN_PATH, self.OFFSETS_FILE])
+
+ @cluster(num_nodes=3)
+ @matrix(plugin_discovery=['only_scan', 'hybrid_warn', 'hybrid_fail',
'service_load'],
+ command=[('sync-manifests', '--dry-run'), ('sync-manifests',)])
+ def test_plugin_discovery_migration(self, plugin_discovery, command):
+ # Template parameters
+ self.PLUGIN_DISCOVERY = plugin_discovery
+
+ self.cc.set_configs(lambda node:
self.render("connect-standalone.properties", node=node))
+ # Explicitly clean the plugin path now, because we won't clean it on
start
+ self.cc.clean()
+
+ plugin_location = os.path.join(self.PLUGIN_PATH, "connect-file")
+ for node in self.cc.nodes:
+ # Copy a non-migrated plugin jar into the plugin path
+ node.account.ssh("mkdir -p %s" % plugin_location)
+ node.account.ssh("cp %s %s" % ((self.cc.path.jar(CONNECT_FILE_JAR,
LATEST_3_5)), plugin_location))
+ # Execute a connect-plugin-path command on the non-migrated plugin
path
+ node.account.ssh("%s %s %s %s" % (
+ self.cc.path.script("connect-plugin-path.sh"), "
".join(command),
+ '--plugin-path', self.PLUGIN_PATH))
+
+ migrated = command == ('sync-manifests',)
+ should_start = not (plugin_discovery == 'hybrid_fail' and not migrated)
+ # Do not clean the plugin path during startup
+ self.cc.start(mode=None if should_start else
ConnectServiceBase.STARTUP_MODE_INSTANT, clean=False)
+
+ if should_start:
+ # plugins should be visible in the backwards-compatible modes, or
if the migration finished.
+ expect_discovered = (plugin_discovery == 'only_scan' or
plugin_discovery == 'hybrid_warn') or migrated
Review Comment:
Nit: unnecessary parentheses
```suggestion
expect_discovered = plugin_discovery == 'only_scan' or
plugin_discovery == 'hybrid_warn' or migrated
```
--
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]