Copilot commented on code in PR #100:
URL: 
https://github.com/apache/doris-kafka-connector/pull/100#discussion_r3734716594


##########
src/test/java/org/apache/doris/kafka/connector/e2e/sink/DorisTlsITCase.java:
##########
@@ -0,0 +1,216 @@
+/*
+ * 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.doris.kafka.connector.e2e.sink;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.time.Duration;
+import java.util.Properties;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.apache.doris.kafka.connector.cfg.DorisSinkConnectorConfig;
+import org.apache.doris.kafka.connector.cfg.DorisTlsOptions;
+import org.apache.doris.kafka.connector.e2e.doris.DorisCustomerServiceImpl;
+import org.apache.doris.kafka.connector.e2e.kafka.KafkaContainerService;
+import org.apache.doris.kafka.connector.e2e.kafka.KafkaContainerServiceImpl;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Verifies Kafka Connect Stream Load against an externally supplied TLS 
Doris cluster. */
+public class DorisTlsITCase {
+
+    private static final String RUN_ID = 
UUID.randomUUID().toString().replace("-", "");
+    private static final String DATABASE = "kafka_tls_it_" + RUN_ID;
+    private static final String TABLE = "sink";
+    private static final String TOPIC = "kafka_tls_it_" + RUN_ID;
+    private static final String CONNECTOR_NAME = "kafka-tls-it-" + RUN_ID;
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+    private static DorisCustomerServiceImpl dorisService;
+    private static KafkaContainerService kafkaService;
+    private static KafkaProducer<String, String> producer;
+    private static boolean databaseCreated;
+    private static boolean connectorRegistered;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        Assume.assumeTrue(
+                "External Doris is required",
+                Boolean.parseBoolean(
+                        
System.getProperty(DorisCustomerServiceImpl.CUSTOMER_ENV, "false")));
+        Assume.assumeTrue(
+                "External Doris TLS is required",
+                Boolean.parseBoolean(
+                        
System.getProperty(DorisCustomerServiceImpl.DORIS_ENABLE_TLS, "false")));
+        dorisService = new DorisCustomerServiceImpl();
+        Assume.assumeTrue(
+                "External Doris HTTP TLS is required",
+                
dorisService.getTlsOptions().isEnabledFor(DorisTlsOptions.Protocol.HTTP));
+
+        kafkaService = new KafkaContainerServiceImpl();
+        kafkaService.startContainer();
+        kafkaService.startConnector();
+
+        dorisService.startContainer();
+
+        Properties properties = new Properties();
+        properties.put(
+                ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, 
kafkaService.getInstanceHostAndPort());
+        properties.put(
+                ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, 
StringSerializer.class.getName());
+        properties.put(
+                ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, 
StringSerializer.class.getName());
+        producer = new KafkaProducer<>(properties);
+
+        executeSql("CREATE DATABASE " + DATABASE);
+        databaseCreated = true;
+        executeSql(
+                "CREATE TABLE "
+                        + DATABASE
+                        + "."
+                        + TABLE
+                        + " (id INT, name STRING) ENGINE=OLAP UNIQUE KEY(id) "
+                        + "DISTRIBUTED BY HASH(id) BUCKETS AUTO "
+                        + "PROPERTIES ('replication_num' = '1')");
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        if (kafkaService != null && connectorRegistered) {
+            kafkaService.deleteKafkaConnector(CONNECTOR_NAME);
+        }
+        if (producer != null) {
+            producer.close(Duration.ofSeconds(10));
+        }
+        if (dorisService != null && databaseCreated) {
+            try {
+                executeSql("DROP DATABASE IF EXISTS " + DATABASE);
+            } finally {
+                dorisService.close();
+            }
+        } else if (dorisService != null) {
+            dorisService.close();
+        }
+    }

Review Comment:
   `KafkaContainerServiceImpl` owns a Kafka container and a non-daemon 
connector executor, but this integration test never calls 
`kafkaService.close()`. When the test is run, those resources can outlive the 
class and prevent the test JVM from terminating; close the service in a 
`finally` block so cleanup also runs after setup/test failures.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to