You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/10 06:58:53 UTC

[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #3048: [Feature][Clickhouse-Connector-V2] Add Clickhouse e2e testcase

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


##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-clickhouse-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/ClickhouseIT.java:
##########
@@ -0,0 +1,341 @@
+/*
+ * 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.connectors.seatunnel.clickhouse;
+
+import org.apache.seatunnel.api.table.type.ArrayType;
+import org.apache.seatunnel.api.table.type.BasicType;
+import org.apache.seatunnel.api.table.type.DecimalType;
+import org.apache.seatunnel.api.table.type.LocalTimeType;
+import org.apache.seatunnel.api.table.type.MapType;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.util.ContainerUtil;
+
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.TestTemplate;
+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.File;
+import java.math.BigDecimal;
+import java.sql.Array;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+import scala.Tuple2;
+
+public class ClickhouseIT extends TestSuiteBase implements TestResource {
+    private static final Logger LOG = LoggerFactory.getLogger(ClickhouseIT.class);
+    private static final String CLICKHOUSE_DOCKER_IMAGE = "yandex/clickhouse-server:latest";
+    private static final String HOST = "clickhouse";
+    private static final String DRIVER_CLASS = "com.clickhouse.jdbc.ClickHouseDriver";
+    private static final String INIT_CLICKHOUSE_PATH = "/init/clickhouse_init.conf";
+    private static final String CLICKHOUSE_JOB_CONFIG = "/clickhouse_to_clickhouse.conf";
+    private static final String DATABASE = "default";
+    private static final String SOURCE_TABLE = "source_table";
+    private static final String SINK_TABLE = "sink_table";
+    private static final String INSERT_SQL = "insert_sql";
+    private static final String COMPARE_SQL = "compare_sql";
+    private static final Tuple2<SeaTunnelRowType, List<SeaTunnelRow>> TEST_DATASET = generateTestDataSet();
+    private static final Config CONFIG = getInitClickhouseConfig();
+    private ClickHouseContainer container;
+    private Connection connection;
+
+    @TestTemplate
+    public void testClickhouse(TestContainer container) throws Exception {
+        Container.ExecResult execResult = container.executeJob(CLICKHOUSE_JOB_CONFIG);
+        Assertions.assertEquals(0, execResult.getExitCode());
+        assertHasData(SINK_TABLE);
+        String columns = String.join(",", generateTestDataSet()._1().getFieldNames());
+        Assertions.assertTrue(compare(String.format(CONFIG.getString(COMPARE_SQL), columns, columns)));

Review Comment:
   could you check these
   
   Check :  source table row count == sink table row count
   Check:   source table row & column == sink table row & column



-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org