Search in sources :

Example 6 with EphemeralStorageBuilder

use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder in project strimzi by strimzi.

the class KafkaClusterTest method testStorageReverting.

@ParallelTest
public void testStorageReverting() {
    Storage jbod = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-st1").withDeleteClaim(true).withId(1).withSize("1000Gi").build()).build();
    Storage ephemeral = new EphemeralStorageBuilder().build();
    Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build();
    // Test Storage changes and how the are reverted
    Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withStorage(jbod).endKafka().endSpec().build();
    KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, ephemeral, replicas);
    // Storage is reverted
    assertThat(kc.getStorage(), is(ephemeral));
    // Warning status condition is set
    assertThat(kc.getWarningConditions().size(), is(1));
    assertThat(kc.getWarningConditions().get(0).getReason(), is("KafkaStorage"));
    kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withStorage(jbod).endKafka().endSpec().build();
    kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, persistent, replicas);
    // Storage is reverted
    assertThat(kc.getStorage(), is(persistent));
    // Warning status condition is set
    assertThat(kc.getWarningConditions().size(), is(1));
    assertThat(kc.getWarningConditions().get(0).getReason(), is("KafkaStorage"));
    kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withStorage(ephemeral).endKafka().endSpec().build();
    kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, jbod, replicas);
    // Storage is reverted
    assertThat(kc.getStorage(), is(jbod));
    // Warning status condition is set
    assertThat(kc.getWarningConditions().size(), is(1));
    assertThat(kc.getWarningConditions().get(0).getReason(), is("KafkaStorage"));
    kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withStorage(persistent).endKafka().endSpec().build();
    kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, jbod, replicas);
    // Storage is reverted
    assertThat(kc.getStorage(), is(jbod));
    // Warning status condition is set
    assertThat(kc.getWarningConditions().size(), is(1));
    assertThat(kc.getWarningConditions().get(0).getReason(), is("KafkaStorage"));
}
Also used : JbodStorageBuilder(io.strimzi.api.kafka.model.storage.JbodStorageBuilder) Storage(io.strimzi.api.kafka.model.storage.Storage) Kafka(io.strimzi.api.kafka.model.Kafka) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) EphemeralStorageBuilder(io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 7 with EphemeralStorageBuilder

use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder 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 8 with EphemeralStorageBuilder

use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder 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 9 with EphemeralStorageBuilder

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

the class StorageDiffTest method testCrossDiff.

@ParallelTest
public void testCrossDiff() {
    Storage jbod = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-st1").withDeleteClaim(true).withId(1).withSize("1000Gi").build()).build();
    Storage ephemeral = new EphemeralStorageBuilder().build();
    Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build();
    StorageDiff diffJbodEphemeral = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, ephemeral, 3, 3);
    StorageDiff diffPersistentEphemeral = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, ephemeral, 3, 3);
    StorageDiff diffJbodPersistent = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, persistent, 3, 3);
    assertThat(diffJbodEphemeral.changesType(), is(true));
    assertThat(diffPersistentEphemeral.changesType(), is(true));
    assertThat(diffJbodPersistent.changesType(), is(true));
    assertThat(diffJbodEphemeral.isEmpty(), is(false));
    assertThat(diffPersistentEphemeral.isEmpty(), is(false));
    assertThat(diffJbodPersistent.isEmpty(), is(false));
    assertThat(diffJbodEphemeral.isVolumesAddedOrRemoved(), is(false));
    assertThat(diffPersistentEphemeral.isVolumesAddedOrRemoved(), is(false));
    assertThat(diffJbodPersistent.isVolumesAddedOrRemoved(), is(false));
}
Also used : JbodStorageBuilder(io.strimzi.api.kafka.model.storage.JbodStorageBuilder) Storage(io.strimzi.api.kafka.model.storage.Storage) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) EphemeralStorageBuilder(io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 10 with EphemeralStorageBuilder

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

the class StorageDiffTest method testEphemeralDiff.

@ParallelTest
public void testEphemeralDiff() {
    Storage ephemeral = new EphemeralStorageBuilder().build();
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, ephemeral, ephemeral, 3, 3).changesType(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, ephemeral, ephemeral, 3, 3).isEmpty(), is(true));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, ephemeral, ephemeral, 3, 3).shrinkSize(), is(false));
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) EphemeralStorageBuilder(io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

EphemeralStorageBuilder (io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder)20 ParallelTest (io.strimzi.test.annotations.ParallelTest)18 Storage (io.strimzi.api.kafka.model.storage.Storage)16 JbodStorageBuilder (io.strimzi.api.kafka.model.storage.JbodStorageBuilder)14 PersistentClaimStorageBuilder (io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder)14 Kafka (io.strimzi.api.kafka.model.Kafka)8 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)8 SingleVolumeStorage (io.strimzi.api.kafka.model.storage.SingleVolumeStorage)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)2 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)2 Condition (io.strimzi.api.kafka.model.status.Condition)2 EphemeralStorage (io.strimzi.api.kafka.model.storage.EphemeralStorage)2 Test (org.junit.jupiter.api.Test)2