From 46d4567baeeb525acbb5590e26727b646880ab20 Mon Sep 17 00:00:00 2001
From: wudi <676366545@qq.com>
Date: Wed, 11 Sep 2024 10:37:28 +0800
Subject: [PATCH] [Improve](test) improve some ut and itcase (#486)
---
flink-doris-connector/pom.xml | 6 +
.../flink/catalog/DorisCatalogITCase.java | 2 +-
.../container/AbstractContainerTestBase.java | 23 ++
.../flink/container/AbstractE2EService.java | 1 +
.../container/AbstractITCaseService.java | 21 +-
.../container/e2e/Doris2DorisE2ECase.java | 2 +-
.../doris/flink/sink/DorisSinkITCase.java | 35 ++-
.../doris/flink/source/DorisSourceITCase.java | 240 ++++++++++++++++--
.../enumerator/DorisSourceEnumeratorTest.java | 111 ++++++++
9 files changed, 388 insertions(+), 53 deletions(-)
create mode 100644 flink-doris-connector/src/test/java/org/apache/doris/flink/source/enumerator/DorisSourceEnumeratorTest.java
diff --git a/flink-doris-connector/pom.xml b/flink-doris-connector/pom.xml
index 64ca73920..d773339b3 100644
--- a/flink-doris-connector/pom.xml
+++ b/flink-doris-connector/pom.xml
@@ -423,6 +423,12 @@ under the License.
${flink.version}
test
+
+ org.apache.flink
+ flink-connector-test-utils
+ ${flink.version}
+ test
+
com.github.jsqlparser
jsqlparser
diff --git a/flink-doris-connector/src/test/java/org/apache/doris/flink/catalog/DorisCatalogITCase.java b/flink-doris-connector/src/test/java/org/apache/doris/flink/catalog/DorisCatalogITCase.java
index b3a3ce04f..099f6ebd6 100644
--- a/flink-doris-connector/src/test/java/org/apache/doris/flink/catalog/DorisCatalogITCase.java
+++ b/flink-doris-connector/src/test/java/org/apache/doris/flink/catalog/DorisCatalogITCase.java
@@ -146,7 +146,7 @@ public void setup()
props.put("sink.enable-2pc", "false");
catalog = new DorisCatalog(TEST_CATALOG_NAME, connectionOptions, TEST_DB, props);
this.tEnv = TableEnvironment.create(EnvironmentSettings.inStreamingMode());
- tEnv.getConfig().set(TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM, 1);
+ tEnv.getConfig().set(TABLE_EXEC_RESOURCE_DEFAULT_PARALLELISM, DEFAULT_PARALLELISM);
// Use doris catalog.
tEnv.registerCatalog(TEST_CATALOG_NAME, catalog);
tEnv.useCatalog(TEST_CATALOG_NAME);
diff --git a/flink-doris-connector/src/test/java/org/apache/doris/flink/container/AbstractContainerTestBase.java b/flink-doris-connector/src/test/java/org/apache/doris/flink/container/AbstractContainerTestBase.java
index 967e6f363..61e0faac8 100644
--- a/flink-doris-connector/src/test/java/org/apache/doris/flink/container/AbstractContainerTestBase.java
+++ b/flink-doris-connector/src/test/java/org/apache/doris/flink/container/AbstractContainerTestBase.java
@@ -24,11 +24,18 @@
import org.slf4j.LoggerFactory;
import java.sql.Connection;
+import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public abstract class AbstractContainerTestBase {
private static final Logger LOG = LoggerFactory.getLogger(AbstractContainerTestBase.class);
private static ContainerService dorisContainerService;
+ public static final int DEFAULT_PARALLELISM = 2;
@BeforeClass
public static void initContainers() {
@@ -88,4 +95,20 @@ private static void closeDorisContainer() {
dorisContainerService.close();
LOG.info("Doris container was closed.");
}
+
+ // ------------------------------------------------------------------------
+ // test utilities
+ // ------------------------------------------------------------------------
+ public static void assertEqualsInAnyOrder(List