@Container
- KafkaContainer kafka =
+ KafkaContainer KAFKA =
new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.0"))
.withNetwork(network)
.withNetworkAliases("kafka")
- .withKraft();
+ .withKraft()
+ .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("KAFKA"));
@Container
- GenericContainer backend1 =
+ GenericContainer BACKEND_1 =
new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
.withImagePullPolicy(NEVER_PULL)
.withNetwork(network)
.withNetworkAliases("backend-1")
.withCommand(
+ "--chat.backend.instance-id=backend-1",
"--chat.backend.services=kafka",
"--chat.backend.kafka.bootstrap-servers=kafka:9102"
- );
+ )
+ .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("BACKEND-1"));
@Container
- GenericContainer backend2 =
+ GenericContainer BACKEND_2 =
new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
.withImagePullPolicy(NEVER_PULL)
.withNetwork(network)
.withNetworkAliases("backend-2")
.withCommand(
+ "--chat.backend.instance-id=backend-2",
"--chat.backend.services=kafka",
"--chat.backend.kafka.bootstrap-servers=kafka:9102"
- );
+ )
+ .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("BACKEND-2"));
@Container
- GenericContainer backend3 =
+ GenericContainer BACKEND_3 =
new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
.withImagePullPolicy(NEVER_PULL)
.withNetwork(network)
.withNetworkAliases("backend-3")
.withCommand(
+ "--chat.backend.instance-id=backend-3",
"--chat.backend.services=kafka",
"--chat.backend.kafka.bootstrap-servers=kafka:9102"
- );
+ )
+ .withLogConsumer(new Slf4jLogConsumer(log, true).withPrefix("BACKEND-3"));
@BeforeAll
@Test
void test() throws InterruptedException
{
- Thread.sleep(60000);
- }
-
-
- @BeforeEach
- void setUpLogging()
- {
- 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);
+ Thread.sleep(15000);
}
}