This is an automated email from the ASF dual-hosted git repository.
fjtiradosarti pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 00da2e095 Switch to ComposeContainer constructor to use V2
docker-compose (#1994)
00da2e095 is described below
commit 00da2e095e3eca8e5ff74abfd4751ecbf1e96705
Author: Gonzalo Muñoz <[email protected]>
AuthorDate: Wed Aug 7 13:21:23 2024 +0200
Switch to ComposeContainer constructor to use V2 docker-compose (#1994)
---
.../examples/quarkus/GrafanaDockerComposeIT.java | 22 ++++----
.../org/kie/kogito/quarkus/outbox/OutboxIT.java | 63 ++++++++++++----------
.../springboot/GrafanaDockerComposeIT.java | 22 ++++----
.../org/kie/kogito/springboot/outbox/OutboxIT.java | 63 ++++++++++++----------
4 files changed, 90 insertions(+), 80 deletions(-)
diff --git
a/kogito-quarkus-examples/dmn-drools-quarkus-metrics/src/test/java/org/kie/kogito/examples/quarkus/GrafanaDockerComposeIT.java
b/kogito-quarkus-examples/dmn-drools-quarkus-metrics/src/test/java/org/kie/kogito/examples/quarkus/GrafanaDockerComposeIT.java
index fc0a4a1f7..8642a5594 100644
---
a/kogito-quarkus-examples/dmn-drools-quarkus-metrics/src/test/java/org/kie/kogito/examples/quarkus/GrafanaDockerComposeIT.java
+++
b/kogito-quarkus-examples/dmn-drools-quarkus-metrics/src/test/java/org/kie/kogito/examples/quarkus/GrafanaDockerComposeIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
import org.kie.kogito.testcontainers.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.DockerComposeContainer;
+import org.testcontainers.containers.ComposeContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
@@ -54,24 +54,22 @@ public class GrafanaDockerComposeIT {
private static final String PROJECT_ARTIFACT_ID =
ProjectMetadataProvider.getProjectArtifactId();
@Container
- public static DockerComposeContainer environment;
+ public static ComposeContainer environment;
static {
try {
- environment = new DockerComposeContainer(new
File(GrafanaDockerComposeIT.class.getClassLoader().getResource("./docker-compose.yml").toURI()))
- .withExposedService("grafana_1", GRAFANA_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
- .withLogConsumer("grafana_1", new Slf4jLogConsumer(LOGGER))
- .withExposedService("hello_1", KOGITO_APPLICATION_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
- .withLogConsumer("hello_1", new Slf4jLogConsumer(LOGGER))
- .withExposedService("prometheus_1", PROMETHEUS_PORT,
+ environment = new ComposeContainer(new
File(GrafanaDockerComposeIT.class.getClassLoader().getResource("./docker-compose.yml").toURI()))
+ .withExposedService("grafana-1", GRAFANA_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
+ .withLogConsumer("grafana-1", new Slf4jLogConsumer(LOGGER))
+ .withExposedService("hello-1", KOGITO_APPLICATION_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
+ .withLogConsumer("hello-1", new Slf4jLogConsumer(LOGGER))
+ .withExposedService("prometheus-1", PROMETHEUS_PORT,
Wait.forHttp("/api/v1/targets")
.forResponsePredicate(x ->
x.contains("\"health\":\"up\""))
.withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
- .withLogConsumer("prometheus_1", new
Slf4jLogConsumer(LOGGER))
+ .withLogConsumer("prometheus-1", new
Slf4jLogConsumer(LOGGER))
.withPull(false)
- .withLocalCompose(true)
- //See
https://github.com/testcontainers/testcontainers-java/issues/4565
- .withOptions("--compatibility");
+ .withLocalCompose(true);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
diff --git
a/kogito-quarkus-examples/process-outbox-mongodb-quarkus/src/test/java/org/kie/kogito/quarkus/outbox/OutboxIT.java
b/kogito-quarkus-examples/process-outbox-mongodb-quarkus/src/test/java/org/kie/kogito/quarkus/outbox/OutboxIT.java
index 5832a8f47..13355cfdd 100644
---
a/kogito-quarkus-examples/process-outbox-mongodb-quarkus/src/test/java/org/kie/kogito/quarkus/outbox/OutboxIT.java
+++
b/kogito-quarkus-examples/process-outbox-mongodb-quarkus/src/test/java/org/kie/kogito/quarkus/outbox/OutboxIT.java
@@ -18,20 +18,28 @@
*/
package org.kie.kogito.quarkus.outbox;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.time.Duration;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.kie.kogito.test.quarkus.kafka.KafkaTestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.DockerComposeContainer;
+import org.testcontainers.containers.ComposeContainer;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
import com.jayway.jsonpath.JsonPath;
@@ -42,7 +50,8 @@ import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertTrue;
-//@Testcontainers
+@Testcontainers
+@Disabled
public class OutboxIT {
private static final Logger LOGGER =
LoggerFactory.getLogger(OutboxIT.class);
@@ -55,8 +64,8 @@ public class OutboxIT {
private static final int KAFKA_PORT = 9092;
private static final int DEBEZIUM_PORT = 8083;
- //@Container
- private static DockerComposeContainer COMPOSE;
+ @Container
+ private static ComposeContainer COMPOSE;
private int kogitoPort;
private int debeziumPort;
@@ -64,34 +73,33 @@ public class OutboxIT {
private KafkaTestClient kafkaClient;
- static {
- // Path path = Paths.get("../../docker-compose.yml");
- // if (!path.toFile().exists()) {
- // path = Paths.get("docker-compose.yml");
- // }
- // COMPOSE = new DockerComposeContainer(path.toFile());
- // COMPOSE.withPull(false);
- // COMPOSE.withServices("kafka", "mongodb", "connect",
"sidecar", "kogito");
- // COMPOSE.withExposedService("kogito", KOGITO_PORT);
- // COMPOSE.withExposedService("kafka", KAFKA_PORT);
- // COMPOSE.withExposedService("connect", DEBEZIUM_PORT);
- // COMPOSE.withLogConsumer("kafka", logger());
- // COMPOSE.withLogConsumer("connect", logger());
- // COMPOSE.withLogConsumer("sidecar", logger());
- // COMPOSE.withLogConsumer("kogito", logger());
- // COMPOSE.waitingFor("kafka", Wait.forListeningPort());
- // COMPOSE.waitingFor("sidecar", Wait.forListeningPort());
- // COMPOSE.waitingFor("kogito", Wait.forListeningPort());
- // COMPOSE.withLocalCompose(true);
- // //See
https://github.com/testcontainers/testcontainers-java/issues/4565
- // COMPOSE.withOptions("--compatibility");
+ @BeforeAll
+ static void init() {
+ Path path = Paths.get("../../docker-compose.yml");
+ if (!path.toFile().exists()) {
+ path = Paths.get("docker-compose.yml");
+ }
+ COMPOSE = new ComposeContainer(path.toFile());
+ COMPOSE.withPull(false);
+ COMPOSE.withServices("kafka", "mongodb", "connect", "sidecar",
"kogito");
+ COMPOSE.withExposedService("kogito", KOGITO_PORT);
+ COMPOSE.withExposedService("kafka", KAFKA_PORT);
+ COMPOSE.withExposedService("connect", DEBEZIUM_PORT);
+ COMPOSE.withLogConsumer("kafka", logger());
+ COMPOSE.withLogConsumer("connect", logger());
+ COMPOSE.withLogConsumer("sidecar", logger());
+ COMPOSE.withLogConsumer("kogito", logger());
+ COMPOSE.waitingFor("kafka", Wait.forListeningPort());
+ COMPOSE.waitingFor("sidecar", Wait.forListeningPort());
+ COMPOSE.waitingFor("kogito", Wait.forListeningPort());
+ COMPOSE.withLocalCompose(true);
}
private static Consumer<OutputFrame> logger() {
return new Slf4jLogConsumer(LOGGER);
}
- //@BeforeEach
+ @BeforeEach
void setup() {
kogitoPort = COMPOSE.getServicePort("kogito", KOGITO_PORT);
debeziumPort = COMPOSE.getServicePort("connect", DEBEZIUM_PORT);
@@ -99,7 +107,7 @@ public class OutboxIT {
kafkaClient = new KafkaTestClient("localhost:" + kafkaPort);
}
- //@AfterEach
+ @AfterEach
void close() {
if (kafkaClient != null) {
kafkaClient.shutdown();
@@ -107,7 +115,6 @@ public class OutboxIT {
}
@Test
- @Disabled
public void testSendProcessEvents() throws InterruptedException {
// Check Debezium (Kafka, MongoDB) readiness
await().ignoreExceptions()
diff --git
a/kogito-springboot-examples/dmn-drools-springboot-metrics/src/test/java/org/kie/kogito/examples/springboot/GrafanaDockerComposeIT.java
b/kogito-springboot-examples/dmn-drools-springboot-metrics/src/test/java/org/kie/kogito/examples/springboot/GrafanaDockerComposeIT.java
index 871de1ab3..5fa6e2289 100644
---
a/kogito-springboot-examples/dmn-drools-springboot-metrics/src/test/java/org/kie/kogito/examples/springboot/GrafanaDockerComposeIT.java
+++
b/kogito-springboot-examples/dmn-drools-springboot-metrics/src/test/java/org/kie/kogito/examples/springboot/GrafanaDockerComposeIT.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
import org.kie.kogito.testcontainers.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.DockerComposeContainer;
+import org.testcontainers.containers.ComposeContainer;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.junit.jupiter.Container;
@@ -54,24 +54,22 @@ public class GrafanaDockerComposeIT {
private static final String PROJECT_ARTIFACT_ID =
ProjectMetadataProvider.getProjectArtifactId();
@Container
- public static DockerComposeContainer environment;
+ public static ComposeContainer environment;
static {
try {
- environment = new DockerComposeContainer(new
File(GrafanaDockerComposeIT.class.getClassLoader().getResource("./docker-compose.yml").toURI()))
- .withExposedService("grafana_1", GRAFANA_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
- .withLogConsumer("grafana_1", new Slf4jLogConsumer(LOGGER))
- .withExposedService("hello_1", KOGITO_APPLICATION_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
- .withLogConsumer("hello_1", new Slf4jLogConsumer(LOGGER))
- .withExposedService("prometheus_1", PROMETHEUS_PORT,
+ environment = new ComposeContainer(new
File(GrafanaDockerComposeIT.class.getClassLoader().getResource("./docker-compose.yml").toURI()))
+ .withExposedService("grafana-1", GRAFANA_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
+ .withLogConsumer("grafana-1", new Slf4jLogConsumer(LOGGER))
+ .withExposedService("hello-1", KOGITO_APPLICATION_PORT,
Wait.forListeningPort().withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
+ .withLogConsumer("hello-1", new Slf4jLogConsumer(LOGGER))
+ .withExposedService("prometheus-1", PROMETHEUS_PORT,
Wait.forHttp("/api/v1/targets")
.forResponsePredicate(x ->
x.contains("\"health\":\"up\""))
.withStartupTimeout(STARTUP_MINUTES_TIMEOUT))
- .withLogConsumer("prometheus_1", new
Slf4jLogConsumer(LOGGER))
+ .withLogConsumer("prometheus-1", new
Slf4jLogConsumer(LOGGER))
.withPull(false)
- .withLocalCompose(true)
- //See
https://github.com/testcontainers/testcontainers-java/issues/4565
- .withOptions("--compatibility");
+ .withLocalCompose(true);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
diff --git
a/kogito-springboot-examples/process-outbox-mongodb-springboot/src/test/java/org/kie/kogito/springboot/outbox/OutboxIT.java
b/kogito-springboot-examples/process-outbox-mongodb-springboot/src/test/java/org/kie/kogito/springboot/outbox/OutboxIT.java
index 1379657c3..455d64c24 100644
---
a/kogito-springboot-examples/process-outbox-mongodb-springboot/src/test/java/org/kie/kogito/springboot/outbox/OutboxIT.java
+++
b/kogito-springboot-examples/process-outbox-mongodb-springboot/src/test/java/org/kie/kogito/springboot/outbox/OutboxIT.java
@@ -18,20 +18,28 @@
*/
package org.kie.kogito.springboot.outbox;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.time.Duration;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.kie.kogito.test.springboot.kafka.KafkaTestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.testcontainers.containers.DockerComposeContainer;
+import org.testcontainers.containers.ComposeContainer;
import org.testcontainers.containers.output.OutputFrame;
import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
import com.jayway.jsonpath.JsonPath;
@@ -42,7 +50,8 @@ import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertTrue;
-//@Testcontainers
+@Testcontainers
+@Disabled
public class OutboxIT {
private static final Logger LOGGER =
LoggerFactory.getLogger(OutboxIT.class);
@@ -55,8 +64,8 @@ public class OutboxIT {
private static final int KAFKA_PORT = 9092;
private static final int DEBEZIUM_PORT = 8083;
- //@Container
- private static DockerComposeContainer<?> COMPOSE;
+ @Container
+ private static ComposeContainer COMPOSE;
private int kogitoPort;
private int debeziumPort;
@@ -64,34 +73,33 @@ public class OutboxIT {
private KafkaTestClient kafkaClient;
- static {
- // Path path = Paths.get("../../docker-compose.yml");
- // if (!path.toFile().exists()) {
- // path = Paths.get("docker-compose.yml");
- // }
- // COMPOSE = new DockerComposeContainer<>(path.toFile());
- // COMPOSE.withPull(false);
- // COMPOSE.withServices("kafka", "mongodb", "connect",
"sidecar", "kogito");
- // COMPOSE.withExposedService("kogito", KOGITO_PORT);
- // COMPOSE.withExposedService("kafka", KAFKA_PORT);
- // COMPOSE.withExposedService("connect", DEBEZIUM_PORT);
- // COMPOSE.withLogConsumer("kafka", logger());
- // COMPOSE.withLogConsumer("connect", logger());
- // COMPOSE.withLogConsumer("sidecar", logger());
- // COMPOSE.withLogConsumer("kogito", logger());
- // COMPOSE.waitingFor("kafka", Wait.forListeningPort());
- // COMPOSE.waitingFor("sidecar", Wait.forListeningPort());
- // COMPOSE.waitingFor("kogito", Wait.forListeningPort());
- // COMPOSE.withLocalCompose(true);
- // //See
https://github.com/testcontainers/testcontainers-java/issues/4565
- // COMPOSE.withOptions("--compatibility");
+ @BeforeAll
+ static void init() {
+ Path path = Paths.get("../../docker-compose.yml");
+ if (!path.toFile().exists()) {
+ path = Paths.get("docker-compose.yml");
+ }
+ COMPOSE = new ComposeContainer(path.toFile());
+ COMPOSE.withPull(false);
+ COMPOSE.withServices("kafka", "mongodb", "connect", "sidecar",
"kogito");
+ COMPOSE.withExposedService("kogito", KOGITO_PORT);
+ COMPOSE.withExposedService("kafka", KAFKA_PORT);
+ COMPOSE.withExposedService("connect", DEBEZIUM_PORT);
+ COMPOSE.withLogConsumer("kafka", logger());
+ COMPOSE.withLogConsumer("connect", logger());
+ COMPOSE.withLogConsumer("sidecar", logger());
+ COMPOSE.withLogConsumer("kogito", logger());
+ COMPOSE.waitingFor("kafka", Wait.forListeningPort());
+ COMPOSE.waitingFor("sidecar", Wait.forListeningPort());
+ COMPOSE.waitingFor("kogito", Wait.forListeningPort());
+ COMPOSE.withLocalCompose(true);
}
private static Consumer<OutputFrame> logger() {
return new Slf4jLogConsumer(LOGGER);
}
- // @BeforeEach
+ @BeforeEach
void setup() {
kogitoPort = COMPOSE.getServicePort("kogito", KOGITO_PORT);
debeziumPort = COMPOSE.getServicePort("connect", DEBEZIUM_PORT);
@@ -99,7 +107,7 @@ public class OutboxIT {
kafkaClient = new KafkaTestClient("localhost:" + kafkaPort);
}
- // @AfterEach
+ @AfterEach
void close() {
if (kafkaClient != null) {
kafkaClient.shutdown();
@@ -107,7 +115,6 @@ public class OutboxIT {
}
@Test
- @Disabled
public void testSendProcessEvents() throws InterruptedException {
// Check Debezium (Kafka, MongoDB) readiness
await().ignoreExceptions()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]