hailin0 commented on code in PR #2954:
URL: 
https://github.com/apache/incubator-seatunnel/pull/2954#discussion_r984233745


##########
seatunnel-e2e/seatunnel-spark-connector-v2-e2e/connector-clickhouse-spark-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/clickhouse/ClickhouseIT.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.seatunnel.e2e.spark.v2.clickhouse;
+
+import org.apache.seatunnel.e2e.spark.SparkContainer;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ClickHouseContainer;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.lifecycle.Startables;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+public class ClickhouseIT extends SparkContainer {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ClickhouseIT.class);
+    private static final String CLICKHOUSE_DOCKER_IMAGE = 
"yandex/clickhouse-server";
+    private ClickHouseContainer container;
+
+    @Test
+    public void testFakeSourceToClickhouseSink() throws IOException, 
InterruptedException {
+        Container.ExecResult execResult = 
executeSeaTunnelSparkJob("/clickhouse/fake_to_clickhouse.conf");
+        Assertions.assertEquals(0, execResult.getExitCode());
+    }
+
+    @Test
+    public void testClickhouseSourceToClickhouseSink() throws IOException, 
InterruptedException {
+        Container.ExecResult execResult = 
executeSeaTunnelSparkJob("/clickhouse/clickhouse_to_clickhouse.conf");
+        Assertions.assertEquals(0, execResult.getExitCode());
+        Assertions.assertIterableEquals(generateTestDataset(), queryResult());
+    }
+
+
+    @BeforeEach
+    @SuppressWarnings("checkstyle:MagicNumber")
+    public void startClickHouseContainer() throws ClassNotFoundException {
+        container = new ClickHouseContainer(CLICKHOUSE_DOCKER_IMAGE)
+                .withNetwork(NETWORK)
+                .withNetworkAliases("clickhouse")
+                .withLogConsumer(new Slf4jLogConsumer(LOGGER));
+        Startables.deepStart(Stream.of(container)).join();
+        LOGGER.info("Clickhouse container started");
+        Class.forName(container.getDriverClassName());
+        Awaitility.given().ignoreExceptions()
+                .await()
+                .atLeast(100, TimeUnit.MILLISECONDS)
+                .pollInterval(200, TimeUnit.MILLISECONDS)
+                .atMost(30, TimeUnit.SECONDS)
+                .untilAsserted(this::initializeClickhouseTable);
+        batchInsertData();
+    }
+
+    @SuppressWarnings("checkstyle:MagicNumber")
+    private void initializeClickhouseTable() {
+        try (Connection connection = 
DriverManager.getConnection(container.getJdbcUrl(), container.getUsername(),
+                container.getPassword())) {
+            Statement statement = connection.createStatement();
+            String initializeSourceTableSql = "CREATE TABLE 
default.source_table (" +
+                    "    `name` Nullable(String)," +
+                    "    `age` Nullable(Int32)" +
+                    ")ENGINE = Memory";
+            String initializeSinkTableSql = "CREATE TABLE default.sink_table 
(" +
+                    "    `name` Nullable(String)," +
+                    "    `age` Nullable(Int32)" +
+                    ")ENGINE = Memory";

Review Comment:
   Test all supported datatypes?
   
   reference
   
https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-e2e/seatunnel-flink-connector-v2-e2e/connector-mongodb-flink-e2e/src/test/java/org/apache/seatunnel/e2e/flink/v2/mongodb/MongodbIT.java#L155



##########
seatunnel-e2e/seatunnel-spark-connector-v2-e2e/connector-clickhouse-spark-e2e/pom.xml:
##########
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <parent>
+        <artifactId>seatunnel-spark-connector-v2-e2e</artifactId>
+        <groupId>org.apache.seatunnel</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>connector-clickhouse-spark-e2e</artifactId>

Review Comment:
   move to 
[this](https://github.com/apache/incubator-seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e)
   
   reference
   https://github.com/apache/incubator-seatunnel/pull/2946



##########
seatunnel-e2e/seatunnel-spark-connector-v2-e2e/connector-clickhouse-spark-e2e/src/test/resources/clickhouse/clickhouse_to_clickhouse.conf:
##########
@@ -0,0 +1,60 @@
+#
+# 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.
+#
+######
+###### This config file is a demonstration of streaming processing in 
seatunnel config
+######
+
+env {
+  # You can set spark configuration here
+}
+
+source {
+  # This is a example source plugin **only for test and demonstrate the 
feature source plugin**
+ Clickhouse {
+     host = "clickhouse:8123"
+     database = "default"
+     sql = "select * from source_table"
+     username = "default"
+     password = ""
+     result_table_name = "source_table"
+    }
+  # If you would like to get more information about how to configure seatunnel 
and see full list of source plugins,
+  # please go to 
https://seatunnel.apache.org/docs/connector-v2/source/FakeSource
+}
+
+transform {
+    sql {
+      sql = "select name,age from source_table"
+    }

Review Comment:
   remove?
   
   test all supported fields



##########
seatunnel-e2e/seatunnel-spark-connector-v2-e2e/connector-clickhouse-spark-e2e/src/test/java/org/apache/seatunnel/e2e/spark/v2/clickhouse/ClickhouseIT.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.seatunnel.e2e.spark.v2.clickhouse;
+
+import org.apache.seatunnel.e2e.spark.SparkContainer;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.ClickHouseContainer;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.lifecycle.Startables;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+public class ClickhouseIT extends SparkContainer {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ClickhouseIT.class);
+    private static final String CLICKHOUSE_DOCKER_IMAGE = 
"yandex/clickhouse-server";
+    private ClickHouseContainer container;
+
+    @Test
+    public void testFakeSourceToClickhouseSink() throws IOException, 
InterruptedException {
+        Container.ExecResult execResult = 
executeSeaTunnelSparkJob("/clickhouse/fake_to_clickhouse.conf");
+        Assertions.assertEquals(0, execResult.getExitCode());
+    }
+
+    @Test
+    public void testClickhouseSourceToClickhouseSink() throws IOException, 
InterruptedException {
+        Container.ExecResult execResult = 
executeSeaTunnelSparkJob("/clickhouse/clickhouse_to_clickhouse.conf");
+        Assertions.assertEquals(0, execResult.getExitCode());
+        Assertions.assertIterableEquals(generateTestDataset(), queryResult());
+    }

Review Comment:
   ```suggestion
       @Test
       public void testClickhouseSourceToClickhouseSink() throws IOException, 
InterruptedException {
           Container.ExecResult execResult = 
executeSeaTunnelSparkJob("/clickhouse/fake_to_clickhouse.conf");
           Assertions.assertEquals(0, execResult.getExitCode());
   
           Container.ExecResult execResult = 
executeSeaTunnelSparkJob("/clickhouse/clickhouse_to_clickhouse.conf");
           Assertions.assertEquals(0, execResult.getExitCode());
           Assertions.assertIterableEquals(generateTestDataset(), 
queryResult());
       }
   ```
   merge together



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