Skip to content

Commit

Permalink
kie-issues#746: set timeout for testcontainers after waitingFor invoc…
Browse files Browse the repository at this point in the history
…ation (apache#1932)

Co-authored-by: jstastny-cz <jan.stastny@ibm.com>
  • Loading branch information
2 people authored and rgdoliveira committed Dec 13, 2023
1 parent 8af67cf commit bc8016b
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoGenericContainer;
import org.kie.kogito.testcontainers.KogitoKafkaContainer;
import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer;
Expand Down Expand Up @@ -94,7 +95,7 @@ public void start() {
final Network network = Network.newNetwork();
sharedDependencyContainers.values().stream()
.map(c -> c.withNetwork(network))
.map(c -> c.waitingFor(Wait.forListeningPort()))
.map(c -> c.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT))
.forEach(GenericContainer::start);
configureKafkaToService(sharedDependencyContainers.values(), serviceContainers.values().toArray(GenericContainer[]::new));
startServices(network);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class JobServiceContainer extends KogitoGenericContainer<JobServiceContai
public JobServiceContainer() {
super(NAME);
addExposedPort(PORT);
waitingFor(Wait.forHttp("/q/health/live").forStatusCode(200));
waitingFor(Wait.forHttp("/q/health/live").forStatusCode(200)).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
addEnv("QUARKUS_HTTP_PORT", Integer.toString(PORT));
addEnv("QUARKUS_LOG_CATEGORY__ORG_KIE_KOGITO_JOBS_SERVICE__LEVEL", "DEBUG");
withAccessToHost(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public ExplainabilityServiceMessagingContainer(String kafkaBootstrapServers, int
addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaBootstrapServers);
addEnv("TRUSTY_EXPLAINABILITY_NUMBEROFSAMPLES", String.valueOf(numberOfSamples));
addExposedPort(8080);
waitingFor(Wait.forListeningPort());
waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public InfinispanTrustyServiceContainer(String infinispanServerList, String kafk
addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaBootstrapServer);
addEnv("TRUSTY_EXPLAINABILITY_ENABLED", String.valueOf(explainabilityEnabled));
addExposedPort(8080);
waitingFor(Wait.forListeningPort());
waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public class QuarkusKogitoServiceContainer extends KogitoServiceContainer {
public QuarkusKogitoServiceContainer(String kafkaBootstrapServer, String kogitoServiceUrl) {
super(kogitoServiceUrl);
addEnv("KAFKA_BOOTSTRAP_SERVERS", kafkaBootstrapServer);
waitingFor(Wait.forListeningPort());
waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public class SpringBootKogitoServiceContainer extends KogitoServiceContainer {
public SpringBootKogitoServiceContainer(String kafkaBootstrapServer, String kogitoServiceUrl) {
super(kogitoServiceUrl);
addEnv("KOGITO_ADDON_TRACING_DECISION_KAFKA_BOOTSTRAPADDRESS", kafkaBootstrapServer);
waitingFor(Wait.forLogMessage(".*Started KogitoApplication in.*", 1));
waitingFor(Wait.forLogMessage(".*Started KogitoApplication in.*", 1)).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@
import org.kie.kogito.index.postgresql.model.ProcessInstanceEntity;
import org.kie.kogito.index.postgresql.model.ProcessInstanceErrorEntity;
import org.kie.kogito.index.postgresql.model.UserTaskInstanceEntity;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer;
import org.testcontainers.containers.wait.strategy.Wait;

public class DDLSchemaExporter {

public static void main(String[] args) {
try (KogitoPostgreSqlContainer postgresql = new KogitoPostgreSqlContainer()) {
postgresql.waitingFor(Wait.forListeningPort());
postgresql.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
postgresql.start();
Map<String, String> settings = new HashMap<>();
settings.put(Environment.URL, postgresql.getJdbcUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.file.Paths;

import org.kie.kogito.test.resources.TestResource;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoGenericContainer;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.wait.strategy.Wait;
Expand All @@ -41,7 +42,7 @@ public abstract class AbstractDataIndexContainer extends KogitoGenericContainer<
public AbstractDataIndexContainer(String containerName) {
super(containerName);
addExposedPort(PORT);
waitingFor(Wait.forListeningPort());
waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
addEnv("KOGITO_PROTOBUF_FOLDER", "/home/kogito/data/protobufs/");
withAccessToHost(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.kie.kogito.index.test.containers.DataIndexPostgreSqlContainer;
import org.kie.kogito.test.resources.TestResource;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -44,7 +45,7 @@ public void start() {
Network network = Network.newNetwork();
postgresql.withNetwork(network);
postgresql.withNetworkAliases("postgresql");
postgresql.waitingFor(Wait.forListeningPort());
postgresql.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
postgresql.start();

dataIndex.addProtoFileFolder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.kie.kogito.index.test.containers.DataIndexOracleContainer;
import org.kie.kogito.index.test.containers.KogitoKafkaContainerWithoutBridge;
import org.kie.kogito.test.resources.TestResource;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoOracleSqlContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void start() {
oracle.start();
kafka.withNetwork(network);
kafka.withNetworkAliases("kafka");
kafka.waitingFor(Wait.forListeningPort());
kafka.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
kafka.start();
String kafkaURL = kafka.getBootstrapServers();
properties.put("kafka.bootstrap.servers", kafkaURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.kie.kogito.index.test.containers.DataIndexPostgreSqlContainer;
import org.kie.kogito.index.test.containers.KogitoKafkaContainerWithoutBridge;
import org.kie.kogito.test.resources.TestResource;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -51,11 +52,11 @@ public void start() {
Network network = Network.newNetwork();
postgresql.withNetwork(network);
postgresql.withNetworkAliases("postgresql");
postgresql.waitingFor(Wait.forListeningPort());
postgresql.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
postgresql.start();
kafka.withNetwork(network);
kafka.withNetworkAliases("kafka");
kafka.waitingFor(Wait.forListeningPort());
kafka.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
kafka.start();
String kafkaURL = kafka.getBootstrapServers();
properties.put("kafka.bootstrap.servers", kafkaURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType;
import org.kie.kogito.persistence.oracle.model.CacheEntity;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoOracleSqlContainer;
import org.testcontainers.containers.wait.strategy.Wait;

public class DDLSchemaExporter {

public static void main(String[] args) {
try (KogitoOracleSqlContainer oracle = new KogitoOracleSqlContainer()) {
oracle.waitingFor(Wait.forListeningPort());
oracle.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
oracle.start();
Map<String, String> settings = new HashMap<>();
settings.put(Environment.URL, oracle.getJdbcUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.hibernate.tool.schema.TargetType;
import org.kie.kogito.persistence.postgresql.model.CacheEntity;
import org.kie.kogito.testcontainers.Constants;
import org.kie.kogito.testcontainers.KogitoPostgreSqlContainer;
import org.testcontainers.containers.wait.strategy.Wait;

public class DDLSchemaExporter {

public static void main(String[] args) {
try (KogitoPostgreSqlContainer postgresql = new KogitoPostgreSqlContainer()) {
postgresql.waitingFor(Wait.forListeningPort());
postgresql.waitingFor(Wait.forListeningPort()).withStartupTimeout(Constants.CONTAINER_START_TIMEOUT);
postgresql.start();
Map<String, String> settings = new HashMap<>();
settings.put(Environment.URL, postgresql.getJdbcUrl());
Expand Down

0 comments on commit bc8016b

Please sign in to comment.