Search in sources :

Example 11 with KafkaTopicStatus

use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi-kafka-operator by strimzi.

the class CustomResourceStatusIsolatedST method assertKafkaTopicStatus.

void assertKafkaTopicStatus(long expectedObservedGeneration, String topicName) {
    KafkaTopicStatus kafkaTopicStatus = KafkaTopicResource.kafkaTopicClient().inNamespace(clusterOperator.getDeploymentNamespace()).withName(topicName).get().getStatus();
    assertThat("KafkaTopic status has incorrect Observed Generation", kafkaTopicStatus.getObservedGeneration(), is(expectedObservedGeneration));
}
Also used : KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus)

Example 12 with KafkaTopicStatus

use of io.strimzi.api.kafka.model.status.KafkaTopicStatus in project strimzi-kafka-operator by strimzi.

the class TopicOperatorBaseIT method assertStatusNotReady.

protected void assertStatusNotReady(String topicName, Class<? extends Exception> reason, String message) 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));
                Optional<Condition> unreadyCondition = conditions.stream().filter(condition -> "NotReady".equals(condition.getType()) && "True".equals(condition.getStatus())).findFirst();
                if (unreadyCondition.isPresent()) {
                    if (reason != null) {
                        assertThat(unreadyCondition.get().getReason() + ": " + unreadyCondition.get().getMessage(), is(reason.getSimpleName() + ": " + message));
                    } else {
                        assertThat(unreadyCondition.get().getMessage(), is(message));
                    }
                    return true;
                } else {
                    LOGGER.info(conditions);
                }
            }
        } else {
            LOGGER.info("{} does not exist", topicName);
        }
        return false;
    }, "status ready");
}
Also used : KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) Condition(io.strimzi.api.kafka.model.status.Condition) CoreMatchers.is(org.hamcrest.CoreMatchers.is) DeletionPropagation(io.fabric8.kubernetes.api.model.DeletionPropagation) KubeClusterResource.getInstance(io.strimzi.test.k8s.KubeClusterResource.getInstance) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) TimeoutException(java.util.concurrent.TimeoutException) ConfigEntry(org.apache.kafka.clients.admin.ConfigEntry) NoClusterException(io.strimzi.test.k8s.exceptions.NoClusterException) BooleanSupplier(java.util.function.BooleanSupplier) Collections.singletonList(java.util.Collections.singletonList) AdminClient(org.apache.kafka.clients.admin.AdminClient) Resource(io.fabric8.kubernetes.client.dsl.Resource) MicrometerMetricsOptions(io.vertx.micrometer.MicrometerMetricsOptions) TestInstance(org.junit.jupiter.api.TestInstance) Map(java.util.Map) DeleteTopicsResult(org.apache.kafka.clients.admin.DeleteTopicsResult) KafkaTopicStatus(io.strimzi.api.kafka.model.status.KafkaTopicStatus) Event(io.fabric8.kubernetes.api.model.Event) KubeCluster(io.strimzi.test.k8s.cluster.KubeCluster) VertxOptions(io.vertx.core.VertxOptions) InvalidTopicException(org.apache.kafka.common.errors.InvalidTopicException) Set(java.util.Set) VertxPrometheusOptions(io.vertx.micrometer.VertxPrometheusOptions) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Logger(org.apache.logging.log4j.Logger) AlterConfigsResult(org.apache.kafka.clients.admin.AlterConfigsResult) KafkaTopicBuilder(io.strimzi.api.kafka.model.KafkaTopicBuilder) Optional(java.util.Optional) UnknownTopicOrPartitionException(org.apache.kafka.common.errors.UnknownTopicOrPartitionException) Condition(io.strimzi.api.kafka.model.status.Condition) Pattern(java.util.regex.Pattern) MixedOperation(io.fabric8.kubernetes.client.dsl.MixedOperation) NewPartitions(org.apache.kafka.clients.admin.NewPartitions) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Crds(io.strimzi.api.kafka.Crds) Function(java.util.function.Function) ConfigResource(org.apache.kafka.common.config.ConfigResource) KafkaTopicList(io.strimzi.api.kafka.KafkaTopicList) KubeClusterResource(io.strimzi.test.k8s.KubeClusterResource) TestUtils(io.strimzi.test.TestUtils) CreateTopicsResult(org.apache.kafka.clients.admin.CreateTopicsResult) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) StrimziKafkaCluster(io.strimzi.test.container.StrimziKafkaCluster) Collections.emptyMap(java.util.Collections.emptyMap) Properties(java.util.Properties) AdminClientConfig(org.apache.kafka.clients.admin.AdminClientConfig) Vertx(io.vertx.core.Vertx) NewTopic(org.apache.kafka.clients.admin.NewTopic) IOException(java.io.IOException) CreatePartitionsResult(org.apache.kafka.clients.admin.CreatePartitionsResult) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) LogManager(org.apache.logging.log4j.LogManager) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic)

Aggregations

KafkaTopicStatus (io.strimzi.api.kafka.model.status.KafkaTopicStatus)12 KafkaTopic (io.strimzi.api.kafka.model.KafkaTopic)10 Condition (io.strimzi.api.kafka.model.status.Condition)8 DeletionPropagation (io.fabric8.kubernetes.api.model.DeletionPropagation)6 Quantity (io.fabric8.kubernetes.api.model.Quantity)4 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)4 Service (io.fabric8.kubernetes.api.model.Service)4 KafkaBridgeResources (io.strimzi.api.kafka.model.KafkaBridgeResources)4 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)4 KafkaConnectResources (io.strimzi.api.kafka.model.KafkaConnectResources)4 KafkaMirrorMaker2 (io.strimzi.api.kafka.model.KafkaMirrorMaker2)4 KafkaMirrorMaker2Resources (io.strimzi.api.kafka.model.KafkaMirrorMaker2Resources)4 KafkaResources (io.strimzi.api.kafka.model.KafkaResources)4 KafkaResources.externalBootstrapServiceName (io.strimzi.api.kafka.model.KafkaResources.externalBootstrapServiceName)4 ConnectorPlugin (io.strimzi.api.kafka.model.connect.ConnectorPlugin)4 GenericKafkaListener (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener)4 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)4 KafkaListenerType (io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType)4 KafkaBridgeStatus (io.strimzi.api.kafka.model.status.KafkaBridgeStatus)4 KafkaConnectStatus (io.strimzi.api.kafka.model.status.KafkaConnectStatus)4