use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicOperatorMockTest method testNotCreatedInKube.
void testNotCreatedInKube(VertxTestContext context, KafkaTopic kt) throws InterruptedException, ExecutionException {
String kubeName = kt.getMetadata().getName();
String kafkaName = kt.getSpec().getTopicName() != null ? kt.getSpec().getTopicName() : kubeName;
int retention = (Integer) kt.getSpec().getConfig().get("retention.bytes");
createInKube(kt);
Thread.sleep(2000);
LOGGER.info("Topic has not been created");
Topic fromKafka = getFromKafka(kafkaName);
context.verify(() -> assertThat(fromKafka, is(nullValue())));
// Reconcile after no changes
reconcile(context);
// Check things still the same
context.verify(() -> assertThat(fromKafka, is(nullValue())));
// Config change + reconcile
updateInKube(new KafkaTopicBuilder(kt).editSpec().addToConfig("retention.bytes", retention + 1).endSpec().build());
// Another reconciliation
reconcile(context);
// Check things still the same
context.verify(() -> {
assertThat(getFromKafka(kafkaName), is(nullValue()));
context.completeNow();
});
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicOperatorMockTest method testCreatedWithDifferentTopicNameInKube.
@Test
public void testCreatedWithDifferentTopicNameInKube(VertxTestContext context) throws InterruptedException, ExecutionException {
int retention = 100_000_000;
KafkaTopic kt = new KafkaTopicBuilder().withNewMetadata().withName("my-topic").withNamespace(NAMESPACE).addToLabels(Labels.STRIMZI_KIND_LABEL, "topic").endMetadata().withNewSpec().withTopicName(// different to metadata.name
"DIFFERENT").withPartitions(1).withReplicas(1).addToConfig("retention.bytes", retention).endSpec().build();
testCreatedInKube(context, kt);
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicOperatorMockTest method testCreatedInKube.
void testCreatedInKube(VertxTestContext context, KafkaTopic kt) throws InterruptedException, ExecutionException {
String kubeName = kt.getMetadata().getName();
String kafkaName = kt.getSpec().getTopicName() != null ? kt.getSpec().getTopicName() : kubeName;
int retention = (Integer) kt.getSpec().getConfig().get("retention.bytes");
createInKube(kt);
// Check created in Kafka
waitUntilTopicExistsInKafka(kafkaName);
LOGGER.info("Topic has been created");
Topic fromKafka = getFromKafka(kafkaName);
context.verify(() -> assertThat(fromKafka.getTopicName().toString(), is(kafkaName)));
// Reconcile after no changes
reconcile(context);
// Check things still the same
context.verify(() -> assertThat(fromKafka, is(getFromKafka(kafkaName))));
// Config change + reconcile
updateInKube(new KafkaTopicBuilder(kt).editSpec().addToConfig("retention.bytes", retention + 1).endSpec().build());
waitUntilTopicInKafka(kafkaName, config -> Integer.toString(retention + 1).equals(config.get("retention.bytes").value()));
// Another reconciliation
reconcile(context);
// Check things still the same
context.verify(() -> {
assertThat(getFromKafka(kafkaName), is(new Topic.Builder(fromKafka).withConfigEntry("retention.bytes", Integer.toString(retention + 1)).build()));
context.completeNow();
});
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicOperatorMockTest method testCreatedWithSameTopicNameInKube.
@Test
public void testCreatedWithSameTopicNameInKube(VertxTestContext context) throws InterruptedException, ExecutionException {
int retention = 100_000_000;
KafkaTopic kt = new KafkaTopicBuilder().withNewMetadata().withName("my-topic").withNamespace(NAMESPACE).addToLabels(Labels.STRIMZI_KIND_LABEL, "topic").endMetadata().withNewSpec().withTopicName(// the same as metadata.name
"my-topic").withPartitions(1).withReplicas(1).addToConfig("retention.bytes", retention).endSpec().build();
testCreatedInKube(context, kt);
}
use of io.strimzi.api.kafka.model.KafkaTopicBuilder in project strimzi by strimzi.
the class TopicOperatorMockTest method testReconciliationPaused.
@Test
public void testReconciliationPaused(VertxTestContext context) throws InterruptedException, ExecutionException {
LOGGER.info("Test started");
int retention = 100_000_000;
KafkaTopic kt = new KafkaTopicBuilder().withNewMetadata().withName("my-topic").withNamespace(NAMESPACE).addToLabels(Labels.STRIMZI_KIND_LABEL, "topic").addToLabels(Labels.KUBERNETES_NAME_LABEL, "topic-operator").withAnnotations(singletonMap("strimzi.io/pause-reconciliation", "true")).endMetadata().withNewSpec().withPartitions(1).withReplicas(1).addToConfig("retention.bytes", retention).endSpec().build();
testNotCreatedInKube(context, kt);
}
Aggregations