diff --git a/chunjun-e2e/pom.xml b/chunjun-e2e/pom.xml
index 01b8774bcb..709b5c7b82 100644
--- a/chunjun-e2e/pom.xml
+++ b/chunjun-e2e/pom.xml
@@ -22,6 +22,14 @@
+
+ com.dtstack.chunjun
+ chunjun-clients
+ ${project.version}
+ test
+
+
+
org.testcontainers
testcontainers
@@ -30,15 +38,15 @@
- com.github.noraui
- ojdbc8
- 12.2.0.1
+ org.testcontainers
+ jdbc
+ ${testcontainers.version}
test
org.testcontainers
- jdbc
+ oracle-xe
${testcontainers.version}
test
@@ -58,16 +66,16 @@
- com.dtstack.chunjun
- chunjun-clients
- ${project.version}
+ org.postgresql
+ postgresql
+ 42.2.19
test
- org.postgresql
- postgresql
- 42.2.19
+ com.github.noraui
+ ojdbc8
+ 12.2.0.1
test
diff --git a/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/containers/oracle/OracleContainer.java b/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/containers/oracle/OracleContainer.java
deleted file mode 100644
index 999c88d732..0000000000
--- a/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/containers/oracle/OracleContainer.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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 com.dtstack.chunjun.connector.containers.oracle;
-
-import org.testcontainers.containers.JdbcDatabaseContainer;
-import org.testcontainers.containers.wait.strategy.WaitStrategy;
-import org.testcontainers.containers.wait.strategy.WaitStrategyTarget;
-import org.testcontainers.images.builder.ImageFromDockerfile;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Paths;
-import java.time.Duration;
-
-public class OracleContainer extends JdbcDatabaseContainer {
- private static final URL ORACLE_DOCKERFILE =
- OracleContainer.class.getClassLoader().getResource("docker/oracle/Dockerfile");
-
- private static final String ORACLE_HOST = "chunjun-e2e-oracle11";
-
- private static final String ORACLE_DRIVER_CLASS = "oracle.jdbc.driver.OracleDriver";
-
- private static final Integer ORACLE_PORT = 1521;
-
- private static final String SID = "xe";
-
- private static final String USERNAME = "system";
-
- private static final String PASSWORD = "oracle";
-
- public OracleContainer() throws URISyntaxException {
- super(
- new ImageFromDockerfile(ORACLE_HOST, true)
- .withDockerfile(Paths.get(ORACLE_DOCKERFILE.toURI())));
- withExposedPorts(ORACLE_PORT);
- waitingFor(
- new WaitStrategy() {
- @Override
- public void waitUntilReady(WaitStrategyTarget waitStrategyTarget) {}
-
- @Override
- public WaitStrategy withStartupTimeout(Duration startupTimeout) {
- return null;
- }
- });
- }
-
- @Override
- public String getDriverClassName() {
- return ORACLE_DRIVER_CLASS;
- }
-
- @Override
- public String getJdbcUrl() {
- return "jdbc:oracle:thin:"
- + this.getUsername()
- + "/"
- + this.getPassword()
- + "@"
- + this.getHost()
- + ":"
- + getMappedPort(ORACLE_PORT)
- + ":"
- + this.getSid();
- }
-
- @Override
- public String getUsername() {
- return USERNAME;
- }
-
- @Override
- public String getPassword() {
- return PASSWORD;
- }
-
- @Override
- public String getTestQueryString() {
- return "SELECT 1 FROM DUAL";
- }
-
- public String getSid() {
- return SID;
- }
-
- public Integer getOraclePort() {
- return this.getMappedPort(1521);
- }
-}
diff --git a/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/entity/LaunchCommandBuilder.java b/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/entity/LaunchCommandBuilder.java
index f22f0ba232..7b33839822 100644
--- a/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/entity/LaunchCommandBuilder.java
+++ b/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/entity/LaunchCommandBuilder.java
@@ -19,13 +19,14 @@
package com.dtstack.chunjun.connector.entity;
import com.dtstack.chunjun.enums.ClusterMode;
-import com.dtstack.chunjun.util.GsonUtil;
+import com.google.gson.GsonBuilder;
import org.junit.Assert;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
public class LaunchCommandBuilder {
private List commands;
@@ -55,6 +56,12 @@ public LaunchCommandBuilder withChunJunDistDir(String chunJunDistDir) {
return this;
}
+ public LaunchCommandBuilder withFlinkLibDir(String chunJunDistDir) {
+ commands.add("-flinkLibDir");
+ commands.add(chunJunDistDir);
+ return this;
+ }
+
public LaunchCommandBuilder withFlinkConfDir(String flinkConfDir) {
commands.add("-flinkConfDir");
commands.add(flinkConfDir);
@@ -63,13 +70,13 @@ public LaunchCommandBuilder withFlinkConfDir(String flinkConfDir) {
public LaunchCommandBuilder withFlinkCustomConf(Map properties) {
commands.add("-confProp");
- commands.add(GsonUtil.GSON.toJson(properties));
+ commands.add(new GsonBuilder().create().toJson(properties));
return this;
}
public LaunchCommandBuilder withAddJar(List path) {
commands.add("-addjar");
- commands.add(GsonUtil.GSON.toJson(path));
+ commands.add(new GsonBuilder().create().toJson(path));
return this;
}
@@ -79,6 +86,18 @@ public LaunchCommandBuilder withShipFile(String path) {
return this;
}
+ public LaunchCommandBuilder withParameters(Map parameters) {
+ if (parameters != null && !parameters.isEmpty()) {
+ commands.add("-p");
+ String params =
+ parameters.entrySet().stream()
+ .map(entry -> entry.getKey() + "=" + entry.getValue())
+ .collect(Collectors.joining(","));
+ commands.add(params);
+ }
+ return this;
+ }
+
public String[] builder() {
return commands.toArray(new String[0]);
}
diff --git a/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/test/ChunjunFlinkStandaloneE2eTest.java b/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/test/ChunjunFlinkStandaloneE2eTest.java
deleted file mode 100644
index a5bbc56cfe..0000000000
--- a/chunjun-e2e/src/test/java/com/dtstack/chunjun/connector/test/ChunjunFlinkStandaloneE2eTest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * 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 com.dtstack.chunjun.connector.test;
-
-import com.dtstack.chunjun.client.Launcher;
-import com.dtstack.chunjun.connector.containers.flink.FlinkStandaloneContainer;
-import com.dtstack.chunjun.connector.entity.JobAccumulatorResult;
-import com.dtstack.chunjun.connector.entity.LaunchCommandBuilder;
-import com.dtstack.chunjun.enums.ClusterMode;
-import com.dtstack.chunjun.util.GsonUtil;
-
-import org.apache.flink.api.common.JobStatus;
-import org.apache.flink.api.common.time.Deadline;
-import org.apache.flink.client.deployment.StandaloneClusterId;
-import org.apache.flink.client.program.rest.RestClusterClient;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.configuration.RestOptions;
-import org.apache.flink.runtime.client.JobStatusMessage;
-import org.apache.flink.table.api.ValidationException;
-
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import org.apache.commons.lang.StringUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.Network;
-import org.testcontainers.containers.output.Slf4jLogConsumer;
-import org.testcontainers.containers.wait.strategy.WaitStrategy;
-import org.testcontainers.containers.wait.strategy.WaitStrategyTarget;
-import org.testcontainers.lifecycle.Startables;
-
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.time.Duration;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Stream;
-
-import static org.apache.flink.util.Preconditions.checkState;
-
-/**
- * @author jayce
- * @version 1.0
- * @date 2022/8/11 11:18
- */
-public class ChunjunFlinkStandaloneE2eTest {
- private static final Logger LOG = LoggerFactory.getLogger(ChunjunFlinkStandaloneE2eTest.class);
-
- public static final String CHUNJUN_HOME =
- new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath();
-
- public static final URL FLINK_CONF_DIR_URL =
- ChunjunFlinkStandaloneE2eTest.class
- .getClassLoader()
- .getResource("docker/flink/standalone");
-
- public static final String CHUNJUN_DIST =
- new File(System.getProperty("user.dir")).getParentFile().getAbsolutePath()
- + "/chunjun-dist";
-
- private static final String FLINK_STANDALONE_HOST = "standalone";
-
- public static final int JOB_MANAGER_REST_PORT = 8081;
-
- public static final int JOB_MANAGER_RPC_PORT = 6213;
-
- @ClassRule public static final Network NETWORK = Network.newNetwork();
-
- protected FlinkStandaloneContainer flinkStandaloneContainer;
-
- @Nullable private RestClusterClient restClusterClient;
-
- @Before
- public void before() throws URISyntaxException {
- Assert.assertTrue("chunjun-dist directory must exists", new File(CHUNJUN_DIST).exists());
-
- LOG.info("Starting flink standalone containers...");
-
- flinkStandaloneContainer =
- new FlinkStandaloneContainer(FLINK_STANDALONE_HOST)
- .withCommand(FLINK_STANDALONE_HOST)
- .withNetwork(NETWORK)
- .withNetworkAliases(FLINK_STANDALONE_HOST)
- .withExposedPorts(JOB_MANAGER_REST_PORT, JOB_MANAGER_RPC_PORT)
- .withFileSystemBind(CHUNJUN_DIST, CHUNJUN_DIST)
- .withLogConsumer(new Slf4jLogConsumer(LOG))
- .waitingFor(
- new WaitStrategy() {
- @Override
- public void waitUntilReady(
- WaitStrategyTarget waitStrategyTarget) {}
-
- @Override
- public WaitStrategy withStartupTimeout(
- Duration startupTimeout) {
- return null;
- }
- });
-
- Startables.deepStart(Stream.of(flinkStandaloneContainer)).join();
- LOG.info("Containers are started.");
- }
-
- @After
- public void after() {
- if (restClusterClient != null) {
- restClusterClient.close();
- }
-
- if (flinkStandaloneContainer != null) {
- flinkStandaloneContainer.stop();
- }
- }
-
- public RestClusterClient getRestClusterClient() {
- if (restClusterClient != null) {
- return restClusterClient;
- }
- checkState(
- flinkStandaloneContainer.isRunning(),
- "Cluster client should only be retrieved for a running cluster");
- try {
- final Configuration clientConfiguration = new Configuration();
- clientConfiguration.set(RestOptions.ADDRESS, flinkStandaloneContainer.getHost());
- clientConfiguration.set(
- RestOptions.PORT,
- flinkStandaloneContainer.getMappedPort(JOB_MANAGER_REST_PORT));
- this.restClusterClient =
- new RestClusterClient<>(clientConfiguration, StandaloneClusterId.getInstance());
- } catch (Exception e) {
- throw new IllegalStateException(
- "Failed to create client for Flink container cluster", e);
- }
- return restClusterClient;
- }
-
- protected void submitSyncJobOnStandLone(String syncConf) throws Exception {
- HashMap customProperties = Maps.newHashMap();
- customProperties.put(
- "jobmanager.rpc.port",
- flinkStandaloneContainer.getMappedPort(JOB_MANAGER_RPC_PORT));
- customProperties.put(
- "rest.port", flinkStandaloneContainer.getMappedPort(JOB_MANAGER_REST_PORT));
-
- String[] syncs =
- new LaunchCommandBuilder("sync")
- .withFlinkConfDir(FLINK_CONF_DIR_URL.toURI().getPath())
- .withRunningMode(ClusterMode.standalone)
- .withJobContentPath(syncConf)
- .withChunJunDistDir(CHUNJUN_DIST)
- .withFlinkCustomConf(customProperties)
- .builder();
- Launcher.main(syncs);
- }
-
- public JobAccumulatorResult waitUntilJobFinished(Duration timeout)
- throws ExecutionException, InterruptedException {
- RestClusterClient> clusterClient = getRestClusterClient();
- Deadline deadline = Deadline.fromNow(timeout);
- int i = 0;
- while (deadline.hasTimeLeft()) {
- Collection jobStatusMessages;
- try {
- jobStatusMessages = clusterClient.listJobs().get(10, TimeUnit.SECONDS);
- } catch (Exception e) {
- if (i++ > 10) {
- throw new RuntimeException("Error when fetching job status.", e);
- }
- Thread.sleep(5000L);
- LOG.warn("Error when fetching job status.", e);
- continue;
- }
-
- if (jobStatusMessages != null && !jobStatusMessages.isEmpty()) {
- JobStatusMessage message = jobStatusMessages.iterator().next();
- JobStatus jobStatus = message.getJobState();
- if (jobStatus.isTerminalState()) {
- if (message.getJobState().equals(JobStatus.FINISHED)) {
- CompletableFuture