use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi by strimzi.
the class TopicOperatorBaseIT method assertStatusReady.
protected void assertStatusReady(String topicName) throws InterruptedException, ExecutionException, TimeoutException {
waitFor(() -> {
KafkaTopic kafkaTopic = operation().inNamespace(NAMESPACE).withName(topicName).get();
if (kafkaTopic != null) {
KafkaTopicStatus status = kafkaTopic.getStatus();
if (status != null && Objects.equals(status.getObservedGeneration(), kafkaTopic.getMetadata().getGeneration()) && status.getConditions() != null) {
List<Condition> conditions = status.getConditions();
assertThat(conditions.size() > 0, is(true));
if (conditions.stream().anyMatch(condition -> "Ready".equals(condition.getType()) && "True".equals(condition.getStatus()))) {
return true;
} else {
LOGGER.info(conditions);
}
}
} else {
LOGGER.info("{} does not exist", topicName);
}
return false;
}, "status ready for topic " + topicName);
}
use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi-kafka-operator by strimzi.
the class CustomResourceStatusIsolatedST method assertKafkaTopicWrongMinInSyncReplicasStatus.
void assertKafkaTopicWrongMinInSyncReplicasStatus(String topicName, String invalidValue) {
KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(clusterOperator.getDeploymentNamespace()).withName(topicName).get().getStatus();
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getType().equals(NotReady.toString())), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getReason().equals("InvalidRequestException")), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getMessage().contains(String.format("Invalid value %s for configuration min.insync.replicas", invalidValue))), is(true));
}
use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi-kafka-operator by strimzi.
the class CustomResourceStatusIsolatedST method assertKafkaTopicDecreasePartitionsStatus.
void assertKafkaTopicDecreasePartitionsStatus(String topicName) {
KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(clusterOperator.getDeploymentNamespace()).withName(topicName).get().getStatus();
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getType().equals(NotReady.toString())), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getReason().equals("PartitionDecreaseException")), is(true));
assertThat(kafkaTopicStatus.getConditions().stream().anyMatch(condition -> condition.getMessage().contains("Number of partitions cannot be decreased")), is(true));
}
use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi-kafka-operator by strimzi.
the class TopicOperatorBaseIT method assertStatusReady.
protected void assertStatusReady(String topicName) throws InterruptedException, ExecutionException, TimeoutException {
waitFor(() -> {
KafkaTopic kafkaTopic = operation().inNamespace(NAMESPACE).withName(topicName).get();
if (kafkaTopic != null) {
KafkaTopicStatus status = kafkaTopic.getStatus();
if (status != null && Objects.equals(status.getObservedGeneration(), kafkaTopic.getMetadata().getGeneration()) && status.getConditions() != null) {
List<Condition> conditions = status.getConditions();
assertThat(conditions.size() > 0, is(true));
if (conditions.stream().anyMatch(condition -> "Ready".equals(condition.getType()) && "True".equals(condition.getStatus()))) {
return true;
} else {
LOGGER.info(conditions);
}
}
} else {
LOGGER.info("{} does not exist", topicName);
}
return false;
}, "status ready for topic " + topicName);
}
use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi by strimzi.
the class TopicST method testMoreReplicasThanAvailableBrokers.
@ParallelTest
void testMoreReplicasThanAvailableBrokers(ExtensionContext extensionContext) {
final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
int topicReplicationFactor = 5;
int topicPartitions = 5;
KafkaTopic kafkaTopic = KafkaTopicTemplates.topic(TOPIC_CLUSTER_NAME, topicName, topicPartitions, topicReplicationFactor, 1, namespace).build();
resourceManager.createResource(extensionContext, false, kafkaTopic);
assertThat("Topic exists in Kafka CR (Kubernetes)", hasTopicInCRK8s(kafkaTopic, topicName));
assertThat("Topic doesn't exists in Kafka itself", !hasTopicInKafka(topicName, TOPIC_CLUSTER_NAME));
String errorMessage = "org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 5 larger than available brokers: 3";
KafkaTopicUtils.waitForKafkaTopicNotReady(namespace, topicName);
KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(namespace).withName(topicName).get().getStatus();
assertThat(kafkaTopicStatus.getConditions().get(0).getMessage(), containsString(errorMessage));
assertThat(kafkaTopicStatus.getConditions().get(0).getReason(), containsString("CompletionException"));
LOGGER.info("Delete topic {}", topicName);
cmdKubeClient(namespace).deleteByName("kafkatopic", topicName);
KafkaTopicUtils.waitForKafkaTopicDeletion(namespace, topicName);
topicReplicationFactor = 3;
final String newTopicName = "topic-example-new";
kafkaTopic = KafkaTopicTemplates.topic(TOPIC_CLUSTER_NAME, newTopicName, topicPartitions, topicReplicationFactor).editMetadata().withNamespace(namespace).endMetadata().build();
resourceManager.createResource(extensionContext, kafkaTopic);
assertThat("Topic exists in Kafka itself", hasTopicInKafka(newTopicName, TOPIC_CLUSTER_NAME));
assertThat("Topic exists in Kafka CR (Kubernetes)", hasTopicInCRK8s(kafkaTopic, newTopicName));
}
Aggregations