import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Import;
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.junit.jupiter.Container;
+import org.testcontainers.utility.DockerImageName;
import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.DATA_TOPIC;
import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.INFO_TOPIC;
-@SpringBootTest(
- webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
- properties = {
- "spring.main.allow-bean-definition-overriding=true",
- "chat.backend.services=kafka",
- "chat.backend.kafka.client-id-PREFIX=TEST",
- "chat.backend.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
- "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
- "chat.backend.kafka.info-channel-topic=" + INFO_TOPIC,
- "chat.backend.kafka.data-channel-topic=" + DATA_TOPIC,
- "chat.backend.kafka.num-partitions=10",
- })
@Slf4j
class KafkaHandoverIT extends AbstractHandoverIT
{
+ @Container
+ KafkaContainer kafka =
+ new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.4.0"))
+ .withNetworkAliases("kafka")
+ .withKraft();
+
+ @Container
+ GenericContainer backend1 =
+ new GenericContainer(DockerImageName.parse("juplo/chat-backend:0.0.1-SNAPSHOT"))
+ .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"))
+ .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"))
+ .withNetworkAliases("backend-3")
+ .withCommand(
+ "--chat.backend.services=kafka",
+ "--chat.backend.kafka.bootstrap-servers=kafka:9102"
+ )
+ .withExposedPorts(8080);
+
+
@BeforeAll
- public static void setUp()
+ static void setUp()
{
}
- @Container
+ @Test
+ void test()
+ {
+ }
}