Skip to content

Commit

Permalink
ci improve
Browse files Browse the repository at this point in the history
  • Loading branch information
JNSimba committed Mar 11, 2024
1 parent 5074ea4 commit a2438cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.lifecycle.Startables;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerLoggerFactory;

import java.io.BufferedReader;
Expand All @@ -43,12 +43,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;
import java.util.stream.Stream;

import static org.awaitility.Awaitility.given;
import static org.awaitility.Durations.ONE_SECOND;

public abstract class DorisTestBase {
protected static final Logger LOG = LoggerFactory.getLogger(DorisTestBase.class);
Expand All @@ -64,7 +59,6 @@ public abstract class DorisTestBase {
protected static final String USERNAME = "root";
protected static final String PASSWORD = "";
protected static final GenericContainer DORIS_CONTAINER = createDorisContainer();
protected static final int DEFAULT_PARALLELISM = 4;

protected static String getFenodes() {
return DORIS_CONTAINER.getHost() + ":8030";
Expand All @@ -75,22 +69,17 @@ protected static String getFenodes() {
}

public static void startContainers() {
LOG.info("Starting doris containers...");
Startables.deepStart(Stream.of(DORIS_CONTAINER)).join();
given().ignoreExceptions()
.await()
.atMost(300, TimeUnit.SECONDS)
.pollInterval(ONE_SECOND)
.untilAsserted(DorisTestBase::initializeJdbcConnection);
try {
LOG.info("Starting doris containers...");
// singleton doris container
DORIS_CONTAINER.start();
initializeJdbcConnection();
} catch (Exception ex) {
LOG.error("Failed to start containers doris, ", ex);
}
LOG.info("Containers doris are started.");
}

public static void stopContainers() {
LOG.info("Stopping doris containers...");
DORIS_CONTAINER.stop();
LOG.info("Containers doris are stopped.");
}

public static GenericContainer createDorisContainer() {
LOG.info("Create doris containers...");
GenericContainer container =
Expand All @@ -100,7 +89,9 @@ public static GenericContainer createDorisContainer() {
.withPrivilegedMode(true)
.withLogConsumer(
new Slf4jLogConsumer(
DockerLoggerFactory.getLogger(DORIS_DOCKER_IMAGE)));
DockerLoggerFactory.getLogger(DORIS_DOCKER_IMAGE)))
.withExposedPorts(8030, 9030, 8040, 9060)
.waitingFor(Wait.forLogMessage(".*register be exec success.*\\n", 1));

container.setPortBindings(
Lists.newArrayList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ private void initializeDorisTable() throws Exception {
DriverManager.getConnection(
String.format(URL, DORIS_CONTAINER.getHost()), USERNAME, PASSWORD);
Statement statement = connection.createStatement()) {
statement.execute(String.format("CREATE DATABASE IF NOT EXISTS %s", DATABASE));
statement.execute(String.format("DROP TABLE IF EXISTS %s.%s", DATABASE, TABLE_1));
statement.execute(String.format("DROP TABLE IF EXISTS %s.%s", DATABASE, TABLE_2));
statement.execute(String.format("DROP TABLE IF EXISTS %s.%s", DATABASE, TABLE_3));
Expand Down

0 comments on commit a2438cc

Please sign in to comment.