use of io.strimzi.test.container.StrimziKafkaContainer in project smallrye-reactive-messaging by smallrye.
the class BrokerRestartTest method testWithBrokerRestart.
@Test
public void testWithBrokerRestart() throws Exception {
int sendBatchSize = 10;
try (StrimziKafkaContainer kafka = KafkaBrokerExtension.createKafkaContainer()) {
kafka.start();
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).put("topic", topic);
KafkaSource<Integer, String> source = createSource(config, groupId);
CountDownLatch receiveLatch = new CountDownLatch(sendBatchSize * 2);
subscribe(source.getStream(), receiveLatch);
sendMessages(0, sendBatchSize);
try (StrimziKafkaContainer ignored = restart(kafka, 5)) {
sendMessages(sendBatchSize, sendBatchSize);
waitForMessages(receiveLatch);
checkConsumedMessages();
}
}
}
use of io.strimzi.test.container.StrimziKafkaContainer in project smallrye-reactive-messaging by smallrye.
the class KafkaBrokerExtension method startKafkaBroker.
public static StrimziKafkaContainer startKafkaBroker(int port) {
StrimziKafkaContainer kafka = createKafkaContainer().withPort(port);
kafka.start();
await().until(kafka::isRunning);
return kafka;
}
use of io.strimzi.test.container.StrimziKafkaContainer in project apicurio-registry by Apicurio.
the class KafkaTestContainerManager method start.
@Override
public Map<String, String> start() {
log.info("Starting the Kafka Test Container");
kafka = new StrimziKafkaContainer();
kafka.addEnv("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "1");
kafka.addEnv("KAFKA_TRANSACTION_STATE_LOG_MIN_ISR", "1");
kafka.withLogConsumer(new Slf4jLogConsumer(LoggerFactory.getLogger("kafka-testcontainer")));
kafka.start();
String bootstrapServers = kafka.getBootstrapServers();
return Map.of("bootstrap.servers", bootstrapServers, "registry.events.kafka.config.bootstrap.servers", bootstrapServers, "registry.kafkasql.bootstrap.servers", bootstrapServers);
}
use of io.strimzi.test.container.StrimziKafkaContainer in project smallrye-reactive-messaging by smallrye.
the class BrokerRestartTest method testAcknowledgementUsingThrottledStrategyEvenAfterBrokerRestart.
@Test
public void testAcknowledgementUsingThrottledStrategyEvenAfterBrokerRestart() throws Exception {
try (StrimziKafkaContainer kafka = KafkaBrokerExtension.createKafkaContainer()) {
kafka.start();
await().until(kafka::isRunning);
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).with("topic", topic).with("auto.commit.interval.ms", 10);
Multi<IncomingKafkaRecord<Integer, String>> stream = createSource(config, groupId).getStream().invoke(IncomingKafkaRecord::ack);
CountDownLatch latch = new CountDownLatch(100);
subscribe(stream, latch);
try (final StrimziKafkaContainer ignored = restart(kafka, 3)) {
sendMessages(0, 100);
waitForMessages(latch);
checkConsumedMessages(0, 100);
waitForCommits(source, 100);
}
}
}
use of io.strimzi.test.container.StrimziKafkaContainer in project smallrye-reactive-messaging by smallrye.
the class BrokerRestartTest method testResumingPausingWhileBrokerIsDown.
@Test
public void testResumingPausingWhileBrokerIsDown() throws Exception {
try (StrimziKafkaContainer kafka = KafkaBrokerExtension.createKafkaContainer()) {
kafka.start();
await().until(kafka::isRunning);
String groupId = UUID.randomUUID().toString();
MapBasedConfig config = createConsumerConfig(groupId).with("topic", topic).with(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafka.getBootstrapServers()).with(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, 6000);
createSource(config, groupId);
source.getStream().subscribe().withSubscriber(AssertSubscriber.create(1));
waitForPartitionAssignment();
ReactiveKafkaConsumer<Integer, String> consumer = source.getConsumer();
await().until(() -> !consumer.getAssignments().await().indefinitely().isEmpty());
assertThat(consumer.pause().await().indefinitely()).isNotEmpty();
consumer.resume().await().indefinitely();
assertThat(consumer.paused().await().indefinitely()).isEmpty();
kafka.stop();
await().until(() -> !kafka.isRunning());
assertThat(consumer.pause().await().indefinitely()).isNotEmpty();
consumer.resume().await().indefinitely();
assertThat(consumer.paused().await().indefinitely()).isEmpty();
}
}
Aggregations