use of io.strimzi.api.kafka.model.KafkaTopic in project strimzi-kafka-operator by strimzi.
the class TopicOperatorIT method testKafkaTopicModifiedRetentionChanged.
@Test
public void testKafkaTopicModifiedRetentionChanged() throws Exception {
// create the topic
String topicName = "test-kafkatopic-modified-retention-changed";
KafkaTopic topicResource = createKafkaTopicResource(topicName);
String expectedValue = alterTopicConfigInKube(topicResource.getMetadata().getName(), "retention.ms", currentValue -> Integer.toString(Integer.parseInt(currentValue) + 1));
awaitTopicConfigInKafka(topicName, "retention.ms", expectedValue);
}
use of io.strimzi.api.kafka.model.KafkaTopic in project strimzi-kafka-operator by strimzi.
the class TopicOperatorIT method testKafkaTopicDeleted.
@Test
public void testKafkaTopicDeleted() throws InterruptedException, ExecutionException, TimeoutException {
// create the Topic Resource
String topicName = "test-kafkatopic-deleted";
KafkaTopic topicResource = createKafkaTopicResource(topicName);
deleteInKubeAndAwaitReconciliation(topicName, topicResource);
}
use of io.strimzi.api.kafka.model.KafkaTopic in project strimzi-kafka-operator by strimzi.
the class TopicOperatorIT method testKafkaTopicModifiedWithBadData.
@Test
public void testKafkaTopicModifiedWithBadData() throws Exception {
// create the topicResource
String topicName = "test-kafkatopic-modified-with-bad-data";
KafkaTopic topicResource = createKafkaTopicResource(topicName);
// now change the topicResource
KafkaTopic changedTopic = new KafkaTopicBuilder(operation().inNamespace(NAMESPACE).withName(topicResource.getMetadata().getName()).get()).editOrNewSpec().withPartitions(-1).endSpec().build();
try {
operation().inNamespace(NAMESPACE).withName(topicResource.getMetadata().getName()).replace(changedTopic);
} catch (KubernetesClientException e) {
assertThat(e.getMessage().contains("spec.partitions in body should be greater than or equal to 1"), is(true));
}
}
use of io.strimzi.api.kafka.model.KafkaTopic in project strimzi-kafka-operator 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);
}
use of io.strimzi.api.kafka.model.KafkaTopic in project strimzi-kafka-operator 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();
});
}
Aggregations