Search in sources :

Example 21 with Storage

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

the class KafkaAssemblyOperatorMockTest method data.

public static Iterable<KafkaAssemblyOperatorMockTest.Params> data() {
    int[] replicas = { 1, 3 };
    int[] storageOptions = { 0, 1, 2 };
    Storage[] kafkaStorageConfigs = { new EphemeralStorage(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(true).build(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(false).build() };
    SingleVolumeStorage[] zkStorageConfigs = { new EphemeralStorage(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(true).build(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(false).build() };
    ResourceRequirements[] resources = { new ResourceRequirementsBuilder().addToLimits("cpu", new Quantity("5000m")).addToLimits("memory", new Quantity("5000m")).addToRequests("cpu", new Quantity("5000")).addToRequests("memory", new Quantity("5000m")).build() };
    List<KafkaAssemblyOperatorMockTest.Params> result = new ArrayList();
    for (int replicaCount : replicas) {
        for (int storage : storageOptions) {
            for (ResourceRequirements resource : resources) {
                result.add(new KafkaAssemblyOperatorMockTest.Params(replicaCount, zkStorageConfigs[storage], replicaCount, kafkaStorageConfigs[storage], resource));
            }
        }
    }
    return result;
}
Also used : ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) ArrayList(java.util.ArrayList) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) Quantity(io.fabric8.kubernetes.api.model.Quantity) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) Checkpoint(io.vertx.junit5.Checkpoint) Storage(io.strimzi.api.kafka.model.storage.Storage) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage)

Example 22 with Storage

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

the class KafkaAssemblyOperatorMockTest method testReconcileUpdatesKafkaPersistentVolumes.

@ParameterizedTest
@MethodSource("data")
public void testReconcileUpdatesKafkaPersistentVolumes(Params params, VertxTestContext context) {
    init(params);
    assumeTrue(kafkaStorage instanceof PersistentClaimStorage, "Parameterized Test only runs for Params with Kafka Persistent storage");
    String originalStorageClass = Storage.storageClass(kafkaStorage);
    Checkpoint async = context.checkpoint();
    initialReconcile(context).onComplete(context.succeeding(v -> context.verify(() -> {
        assertStorageClass(context, KafkaCluster.kafkaClusterName(CLUSTER_NAME), originalStorageClass);
        // Try to update the storage class
        String changedClass = originalStorageClass + "2";
        Kafka patchedPersistenceKafka = new KafkaBuilder(cluster).editSpec().editKafka().withNewPersistentClaimStorage().withStorageClass(changedClass).withSize("123").endPersistentClaimStorage().endKafka().endSpec().build();
        kafkaAssembly(NAMESPACE, CLUSTER_NAME).patch(patchedPersistenceKafka);
        LOGGER.info("Updating with changed storage class");
    }))).compose(v -> operator.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME))).onComplete(context.succeeding(v -> context.verify(() -> {
        // Check the storage class was not changed
        assertStorageClass(context, KafkaCluster.kafkaClusterName(CLUSTER_NAME), originalStorageClass);
        async.flag();
    })));
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) CoreMatchers.is(org.hamcrest.CoreMatchers.is) DeletionPropagation(io.fabric8.kubernetes.api.model.DeletionPropagation) Storage(io.strimzi.api.kafka.model.storage.Storage) StatefulSetStatus(io.fabric8.kubernetes.api.model.apps.StatefulSetStatus) PodTemplateSpec(io.fabric8.kubernetes.api.model.PodTemplateSpec) MockKube(io.strimzi.test.mockkube.MockKube) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AfterAll(org.junit.jupiter.api.AfterAll) Resource(io.fabric8.kubernetes.client.dsl.Resource) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) ResourceRequirements(io.fabric8.kubernetes.api.model.ResourceRequirements) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Ca(io.strimzi.operator.cluster.model.Ca) BeforeAll(org.junit.jupiter.api.BeforeAll) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) ResourceUtils(io.strimzi.operator.cluster.ResourceUtils) AbstractModel(io.strimzi.operator.cluster.model.AbstractModel) StatefulSetOperator(io.strimzi.operator.cluster.operator.resource.StatefulSetOperator) MethodSource(org.junit.jupiter.params.provider.MethodSource) KafkaVersion(io.strimzi.operator.cluster.model.KafkaVersion) Set(java.util.Set) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) Collectors(java.util.stream.Collectors) StatefulSetSpec(io.fabric8.kubernetes.api.model.apps.StatefulSetSpec) List(java.util.List) EphemeralStorage(io.strimzi.api.kafka.model.storage.EphemeralStorage) KafkaConfiguration(io.strimzi.operator.cluster.model.KafkaConfiguration) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) StrimziPodSet(io.strimzi.api.kafka.model.StrimziPodSet) PasswordGenerator(io.strimzi.operator.common.PasswordGenerator) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) Optional(java.util.Optional) Checkpoint(io.vertx.junit5.Checkpoint) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) ClusterOperatorConfig(io.strimzi.operator.cluster.ClusterOperatorConfig) MockCertManager(io.strimzi.operator.common.operator.MockCertManager) VertxTestContext(io.vertx.junit5.VertxTestContext) KafkaList(io.strimzi.api.kafka.KafkaList) Matchers.aMapWithSize(org.hamcrest.Matchers.aMapWithSize) Container(io.fabric8.kubernetes.api.model.Container) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) HashMap(java.util.HashMap) Storage.deleteClaim(io.strimzi.api.kafka.model.storage.Storage.deleteClaim) Crds(io.strimzi.api.kafka.Crds) ZookeeperCluster(io.strimzi.operator.cluster.model.ZookeeperCluster) AtomicReference(java.util.concurrent.atomic.AtomicReference) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) FeatureGates(io.strimzi.operator.cluster.FeatureGates) ArrayList(java.util.ArrayList) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) KafkaCluster(io.strimzi.operator.cluster.model.KafkaCluster) ClusterOperator(io.strimzi.operator.cluster.ClusterOperator) KafkaVersionTestUtils(io.strimzi.operator.cluster.KafkaVersionTestUtils) PodSpec(io.fabric8.kubernetes.api.model.PodSpec) ZookeeperLeaderFinder(io.strimzi.operator.cluster.operator.resource.ZookeeperLeaderFinder) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) Matchers.hasSize(org.hamcrest.Matchers.hasSize) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) Collections.singletonMap(java.util.Collections.singletonMap) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Volume(io.fabric8.kubernetes.api.model.Volume) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) StrimziPodSetList(io.strimzi.api.kafka.StrimziPodSetList) KubernetesVersion(io.strimzi.operator.KubernetesVersion) Vertx(io.vertx.core.Vertx) StatefulSet(io.fabric8.kubernetes.api.model.apps.StatefulSet) Reconciliation(io.strimzi.operator.common.Reconciliation) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) Checkpoint(io.vertx.junit5.Checkpoint) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) Reconciliation(io.strimzi.operator.common.Reconciliation) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 23 with Storage

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

the class KafkaBrokerConfigurationBuilderTest method testJbodStorageLogDirs.

@ParallelTest
public void testJbodStorageLogDirs() {
    SingleVolumeStorage vol1 = new PersistentClaimStorageBuilder().withId(1).withSize("1Ti").withStorageClass("aws-ebs").withDeleteClaim(true).build();
    SingleVolumeStorage vol2 = new EphemeralStorageBuilder().withId(2).withSizeLimit("5Gi").build();
    SingleVolumeStorage vol5 = new PersistentClaimStorageBuilder().withId(5).withSize("10Ti").withStorageClass("aws-ebs").withDeleteClaim(false).build();
    Storage storage = new JbodStorageBuilder().withVolumes(vol1, vol2, vol5).build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withLogDirs(VolumeUtils.createVolumeMounts(storage, "/var/lib/kafka", false)).build();
    assertThat(configuration, isEquivalent("log.dirs=/var/lib/kafka/data-1/kafka-log${STRIMZI_BROKER_ID},/var/lib/kafka/data-2/kafka-log${STRIMZI_BROKER_ID},/var/lib/kafka/data-5/kafka-log${STRIMZI_BROKER_ID}"));
}
Also used : JbodStorageBuilder(io.strimzi.api.kafka.model.storage.JbodStorageBuilder) Storage(io.strimzi.api.kafka.model.storage.Storage) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) EphemeralStorageBuilder(io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 24 with Storage

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

the class KafkaBrokerConfigurationBuilderTest method testEphemeralStorageLogDirs.

@ParallelTest
public void testEphemeralStorageLogDirs() {
    Storage storage = new EphemeralStorageBuilder().withSizeLimit("5Gi").build();
    String configuration = new KafkaBrokerConfigurationBuilder(Reconciliation.DUMMY_RECONCILIATION).withLogDirs(VolumeUtils.createVolumeMounts(storage, "/var/lib/kafka", false)).build();
    assertThat(configuration, isEquivalent("log.dirs=/var/lib/kafka/data/kafka-log${STRIMZI_BROKER_ID}"));
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) EphemeralStorageBuilder(io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 25 with Storage

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

the class ZookeeperClusterTest method testStorageValidationAfterInitialDeployment.

@ParallelTest
public void testStorageValidationAfterInitialDeployment() {
    assertThrows(InvalidResourceException.class, () -> {
        Storage oldStorage = new PersistentClaimStorageBuilder().withSize("100Gi").build();
        Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configurationJson, zooConfigurationJson)).editSpec().editZookeeper().withStorage(new PersistentClaimStorageBuilder().build()).endZookeeper().endSpec().build();
        ZookeeperCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, oldStorage, replicas);
    });
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) Kafka(io.strimzi.api.kafka.model.Kafka) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

Storage (io.strimzi.api.kafka.model.storage.Storage)56 PersistentClaimStorageBuilder (io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder)46 ParallelTest (io.strimzi.test.annotations.ParallelTest)42 JbodStorageBuilder (io.strimzi.api.kafka.model.storage.JbodStorageBuilder)20 SingleVolumeStorage (io.strimzi.api.kafka.model.storage.SingleVolumeStorage)18 EphemeralStorageBuilder (io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder)16 Kafka (io.strimzi.api.kafka.model.Kafka)14 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)14 PersistentClaimStorage (io.strimzi.api.kafka.model.storage.PersistentClaimStorage)10 PersistentClaimStorageOverrideBuilder (io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder)9 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)8 Quantity (io.fabric8.kubernetes.api.model.Quantity)8 ResourceRequirements (io.fabric8.kubernetes.api.model.ResourceRequirements)8 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)8 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)8 EphemeralStorage (io.strimzi.api.kafka.model.storage.EphemeralStorage)8 Checkpoint (io.vertx.junit5.Checkpoint)8 ArrayList (java.util.ArrayList)8 Container (io.fabric8.kubernetes.api.model.Container)6 DeletionPropagation (io.fabric8.kubernetes.api.model.DeletionPropagation)6