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);
}
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();
}
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));
}
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));
}
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();
}
Aggregations