import org.springframework.kafka.test.context.EmbeddedKafka;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.KafkaContainer;
+import org.testcontainers.containers.Network;
import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.images.ImagePullPolicy;
import org.testcontainers.junit.jupiter.Container;
@Slf4j
class KafkaHandoverIT extends AbstractHandoverIT
{
+ Network network = Network.newNetwork();
+
+
@Container
KafkaContainer kafka =
new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.0"))
+ .withNetwork(network)
.withNetworkAliases("kafka")
.withKraft();
GenericContainer backend1 =
new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
.withImagePullPolicy(NEVER_PULL)
+ .withNetwork(network)
.withNetworkAliases("backend-1")
.withCommand(
"--chat.backend.services=kafka",
GenericContainer backend2 =
new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
.withImagePullPolicy(NEVER_PULL)
+ .withNetwork(network)
.withNetworkAliases("backend-2")
.withCommand(
"--chat.backend.services=kafka",
GenericContainer backend3 =
new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
.withImagePullPolicy(NEVER_PULL)
+ .withNetwork(network)
.withNetworkAliases("backend-3")
.withCommand(
"--chat.backend.services=kafka",
}
@Test
- void test()
+ void test() throws InterruptedException
{
-
+ Thread.sleep(60000);
}
@BeforeEach
void setUpLogging()
{
- Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log);
- backend1.followOutput(logConsumer);
+ Slf4jLogConsumer logConsumer1 = new Slf4jLogConsumer(log, true).withPrefix("BACKEND-1");
+ backend1.followOutput(logConsumer1);
+ Slf4jLogConsumer logConsumer2 = new Slf4jLogConsumer(log, true).withPrefix("BACKEND-2");
+ backend2.followOutput(logConsumer2);
+ Slf4jLogConsumer logConsumer3 = new Slf4jLogConsumer(log, true).withPrefix("BACKEND-3");
+ backend2.followOutput(logConsumer3);
}
}