From 1044804744aa4ff543b87aa77753ea6d454f77e3 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 22 Feb 2024 21:06:43 +0100 Subject: [PATCH] WIP:neu --- .../chat/backend/AbstractHandoverIT.java | 11 +++++++++ .../kafka/chat/backend/KafkaHandoverIT.java | 23 ++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java b/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java index 9d30331e..24baee56 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/AbstractHandoverIT.java @@ -3,6 +3,7 @@ package de.juplo.kafka.chat.backend; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.images.ImagePullPolicy; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; @@ -16,4 +17,14 @@ public abstract class AbstractHandoverIT { } + + + static final ImagePullPolicy NEVER_PULL = new ImagePullPolicy() + { + @Override + public boolean shouldPull(DockerImageName imageName) + { + return false; + } + }; } diff --git a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java index 98800145..09505768 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/KafkaHandoverIT.java @@ -6,6 +6,7 @@ import de.juplo.kafka.chat.backend.implementation.kafka.KafkaTestUtils; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -16,6 +17,8 @@ import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.test.context.EmbeddedKafka; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.images.ImagePullPolicy; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.utility.DockerImageName; @@ -35,32 +38,32 @@ class KafkaHandoverIT extends AbstractHandoverIT @Container GenericContainer backend1 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) + .withImagePullPolicy(NEVER_PULL) .withNetworkAliases("backend-1") .withCommand( "--chat.backend.services=kafka", "--chat.backend.kafka.bootstrap-servers=kafka:9102" - ) - .withExposedPorts(8080); + ); @Container GenericContainer backend2 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) + .withImagePullPolicy(NEVER_PULL) .withNetworkAliases("backend-2") .withCommand( "--chat.backend.services=kafka", "--chat.backend.kafka.bootstrap-servers=kafka:9102" - ) - .withExposedPorts(8080); + ); @Container GenericContainer backend3 = new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT")) + .withImagePullPolicy(NEVER_PULL) .withNetworkAliases("backend-3") .withCommand( "--chat.backend.services=kafka", "--chat.backend.kafka.bootstrap-servers=kafka:9102" - ) - .withExposedPorts(8080); + ); @BeforeAll @@ -73,4 +76,12 @@ class KafkaHandoverIT extends AbstractHandoverIT { } + + + @BeforeEach + void setUpLogging() + { + Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log); + backend1.followOutput(logConsumer); + } } -- 2.20.1