Search in sources :

Example 1 with ProbeBuilder

use of io.strimzi.api.kafka.model.ProbeBuilder in project strimzi by strimzi.

the class RollingUpdateST method testClusterOperatorFinishAllRollingUpdates.

@IsolatedTest("Deleting Pod of Shared Cluster Operator")
@Tag(ROLLING_UPDATE)
void testClusterOperatorFinishAllRollingUpdates(ExtensionContext extensionContext) {
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, 3, 3).editMetadata().withNamespace(namespace).endMetadata().build());
    Map<String, String> kafkaPods = PodUtils.podSnapshot(namespace, kafkaSelector);
    Map<String, String> zkPods = PodUtils.podSnapshot(namespace, zkSelector);
    // Changes to readiness probe should trigger a rolling update
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        kafka.getSpec().getKafka().setReadinessProbe(new ProbeBuilder().withTimeoutSeconds(6).build());
        kafka.getSpec().getZookeeper().setReadinessProbe(new ProbeBuilder().withTimeoutSeconds(6).build());
    }, namespace);
    TestUtils.waitFor("rolling update starts", Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_STATUS_TIMEOUT, () -> kubeClient(namespace).listPods(namespace).stream().filter(pod -> pod.getStatus().getPhase().equals("Running")).map(pod -> pod.getStatus().getPhase()).collect(Collectors.toList()).size() < kubeClient().listPods().size());
    LabelSelector coLabelSelector = kubeClient(INFRA_NAMESPACE).getDeployment(INFRA_NAMESPACE, ResourceManager.getCoDeploymentName()).getSpec().getSelector();
    LOGGER.info("Deleting Cluster Operator pod with labels {}", coLabelSelector);
    kubeClient(INFRA_NAMESPACE).deletePodsByLabelSelector(coLabelSelector);
    LOGGER.info("Cluster Operator pod deleted");
    RollingUpdateUtils.waitTillComponentHasRolled(namespace, zkSelector, 3, zkPods);
    TestUtils.waitFor("rolling update starts", Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_STATUS_TIMEOUT, () -> kubeClient(namespace).listPods().stream().map(pod -> pod.getStatus().getPhase()).collect(Collectors.toList()).contains("Pending"));
    LOGGER.info("Deleting Cluster Operator pod with labels {}", coLabelSelector);
    kubeClient(INFRA_NAMESPACE).deletePodsByLabelSelector(coLabelSelector);
    LOGGER.info("Cluster Operator pod deleted");
    RollingUpdateUtils.waitTillComponentHasRolled(namespace, kafkaSelector, 3, kafkaPods);
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) CoreMatchers.is(org.hamcrest.CoreMatchers.is) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) INFRA_NAMESPACE(io.strimzi.systemtest.Constants.INFRA_NAMESPACE) KafkaUser(io.strimzi.api.kafka.model.KafkaUser) KafkaResources.kafkaStatefulSetName(io.strimzi.api.kafka.model.KafkaResources.kafkaStatefulSetName) MetricsCollector(io.strimzi.systemtest.metrics.MetricsCollector) ConfigMapKeySelector(io.fabric8.kubernetes.api.model.ConfigMapKeySelector) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Map(java.util.Map) Killing(io.strimzi.systemtest.k8s.Events.Killing) Tag(org.junit.jupiter.api.Tag) StUtils(io.strimzi.systemtest.utils.StUtils) Matchers.hasAllOfReasons(io.strimzi.systemtest.matchers.Matchers.hasAllOfReasons) ProbeBuilder(io.strimzi.api.kafka.model.ProbeBuilder) RollingUpdateUtils(io.strimzi.systemtest.utils.RollingUpdateUtils) ACCEPTANCE(io.strimzi.systemtest.Constants.ACCEPTANCE) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) List(java.util.List) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) Pattern(java.util.regex.Pattern) SCALABILITY(io.strimzi.systemtest.Constants.SCALABILITY) AbstractST(io.strimzi.systemtest.AbstractST) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) ExternalLoggingBuilder(io.strimzi.api.kafka.model.ExternalLoggingBuilder) ParallelSuite(io.strimzi.systemtest.annotations.ParallelSuite) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) HashMap(java.util.HashMap) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ArrayList(java.util.ArrayList) JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) JmxPrometheusExporterMetricsBuilder(io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) TestUtils(io.strimzi.test.TestUtils) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ROLLING_UPDATE(io.strimzi.systemtest.Constants.ROLLING_UPDATE) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) KafkaUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils) InternalKafkaClient(io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient) ComponentType(io.strimzi.systemtest.resources.ComponentType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Constants(io.strimzi.systemtest.Constants) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) IsolatedTest(io.strimzi.systemtest.annotations.IsolatedTest) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) ConfigMapKeySelectorBuilder(io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) ProbeBuilder(io.strimzi.api.kafka.model.ProbeBuilder) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) IsolatedTest(io.strimzi.systemtest.annotations.IsolatedTest) Tag(org.junit.jupiter.api.Tag)

Example 2 with ProbeBuilder

use of io.strimzi.api.kafka.model.ProbeBuilder in project strimzi by strimzi.

the class ResourceUtils method createKafka.

public static Kafka createKafka(String namespace, String name, int replicas, String image, int healthDelay, int healthTimeout) {
    Probe probe = new ProbeBuilder().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).withFailureThreshold(10).withSuccessThreshold(4).withPeriodSeconds(33).build();
    ObjectMeta meta = new ObjectMetaBuilder().withNamespace(namespace).withName(name).withLabels(Labels.fromMap(singletonMap("my-user-label", "cromulent")).toMap()).build();
    KafkaBuilder builder = new KafkaBuilder();
    return builder.withMetadata(meta).withNewSpec().withNewKafka().withReplicas(replicas).withImage(image).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withLivenessProbe(probe).withReadinessProbe(probe).withStorage(new EphemeralStorage()).endKafka().withNewZookeeper().withReplicas(replicas).withImage(image + "-zk").withLivenessProbe(probe).withReadinessProbe(probe).endZookeeper().endSpec().build();
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) ProbeBuilder(io.strimzi.api.kafka.model.ProbeBuilder) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) Probe(io.strimzi.api.kafka.model.Probe) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage)

Example 3 with ProbeBuilder

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

the class RollingUpdateST method testBrokerConfigurationChangeTriggerRollingUpdate.

@ParallelNamespaceTest
@Tag(ROLLING_UPDATE)
void testBrokerConfigurationChangeTriggerRollingUpdate(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, 3, 3).build());
    Map<String, String> kafkaPods = PodUtils.podSnapshot(namespaceName, kafkaSelector);
    Map<String, String> zkPods = PodUtils.podSnapshot(namespaceName, zkSelector);
    // Changes to readiness probe should trigger a rolling update
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        kafka.getSpec().getKafka().setReadinessProbe(new ProbeBuilder().withTimeoutSeconds(6).build());
    }, namespaceName);
    RollingUpdateUtils.waitTillComponentHasRolled(namespaceName, kafkaSelector, 3, kafkaPods);
    assertThat(PodUtils.podSnapshot(namespaceName, zkSelector), is(zkPods));
}
Also used : ProbeBuilder(io.strimzi.api.kafka.model.ProbeBuilder) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) Tag(org.junit.jupiter.api.Tag)

Example 4 with ProbeBuilder

use of io.strimzi.api.kafka.model.ProbeBuilder in project strimzi by strimzi.

the class RollingUpdateST method testBrokerConfigurationChangeTriggerRollingUpdate.

@ParallelNamespaceTest
@Tag(ROLLING_UPDATE)
void testBrokerConfigurationChangeTriggerRollingUpdate(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, 3, 3).build());
    Map<String, String> kafkaPods = PodUtils.podSnapshot(namespaceName, kafkaSelector);
    Map<String, String> zkPods = PodUtils.podSnapshot(namespaceName, zkSelector);
    // Changes to readiness probe should trigger a rolling update
    KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
        kafka.getSpec().getKafka().setReadinessProbe(new ProbeBuilder().withTimeoutSeconds(6).build());
    }, namespaceName);
    RollingUpdateUtils.waitTillComponentHasRolled(namespaceName, kafkaSelector, 3, kafkaPods);
    assertThat(PodUtils.podSnapshot(namespaceName, zkSelector), is(zkPods));
}
Also used : ProbeBuilder(io.strimzi.api.kafka.model.ProbeBuilder) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) Tag(org.junit.jupiter.api.Tag)

Example 5 with ProbeBuilder

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

the class ResourceUtils method createKafka.

public static Kafka createKafka(String namespace, String name, int replicas, String image, int healthDelay, int healthTimeout) {
    Probe probe = new ProbeBuilder().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).withFailureThreshold(10).withSuccessThreshold(4).withPeriodSeconds(33).build();
    ObjectMeta meta = new ObjectMetaBuilder().withNamespace(namespace).withName(name).withLabels(Labels.fromMap(singletonMap("my-user-label", "cromulent")).toMap()).build();
    KafkaBuilder builder = new KafkaBuilder();
    return builder.withMetadata(meta).withNewSpec().withNewKafka().withReplicas(replicas).withImage(image).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withLivenessProbe(probe).withReadinessProbe(probe).withStorage(new EphemeralStorage()).endKafka().withNewZookeeper().withReplicas(replicas).withImage(image + "-zk").withLivenessProbe(probe).withReadinessProbe(probe).endZookeeper().endSpec().build();
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) ProbeBuilder(io.strimzi.api.kafka.model.ProbeBuilder) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) Probe(io.strimzi.api.kafka.model.Probe) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage)

Aggregations

ProbeBuilder (io.strimzi.api.kafka.model.ProbeBuilder)6 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)4 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)4 Tag (org.junit.jupiter.api.Tag)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)2 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)2 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)2 ConfigMapKeySelector (io.fabric8.kubernetes.api.model.ConfigMapKeySelector)2 ConfigMapKeySelectorBuilder (io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder)2 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)2 ObjectMetaBuilder (io.fabric8.kubernetes.api.model.ObjectMetaBuilder)2 Quantity (io.fabric8.kubernetes.api.model.Quantity)2 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)2 ExternalLoggingBuilder (io.strimzi.api.kafka.model.ExternalLoggingBuilder)2 JmxPrometheusExporterMetrics (io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics)2 JmxPrometheusExporterMetricsBuilder (io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder)2 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)2 KafkaResources (io.strimzi.api.kafka.model.KafkaResources)2