Search in sources :

Example 51 with PersistentClaimStorageBuilder

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

the class StorageDiffTest method testJbodDiffWithNewVolume.

@ParallelTest
public void testJbodDiffWithNewVolume() {
    Storage jbod = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("1000Gi").build()).build();
    Storage jbod2 = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("1000Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(true).withId(1).withSize("1000Gi").build()).build();
    Storage jbod3 = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-st1").withDeleteClaim(false).withId(0).withSize("100Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(true).withId(1).withSize("1000Gi").build()).build();
    Storage jbod4 = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(2).withSize("1000Gi").build()).build();
    Storage jbod5 = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(true).withId(1).withSize("1000Gi").build()).build();
    Storage jbod6 = new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("1000Gi").build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-st1").withDeleteClaim(true).withId(2).withSize("5000Gi").build()).build();
    // Volume added
    StorageDiff diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, jbod2, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(true));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // Volume removed
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod2, jbod, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(true));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // Volume added with changes
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, jbod3, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(false));
    assertThat(diff.shrinkSize(), is(true));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // No volume added, but with changes
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod2, jbod3, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(false));
    assertThat(diff.shrinkSize(), is(true));
    assertThat(diff.isVolumesAddedOrRemoved(), is(false));
    // Volume removed from the beginning
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod3, jbod5, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(true));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // Volume added to the beginning
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod5, jbod3, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(true));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // Volume replaced with another ID and another volume which is kept changed
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod3, jbod6, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(false));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // Volume replaced with another ID in single volume broker
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, jbod4, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(true));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
    // Volume replaced with another ID without chenging the volumes which are kept
    diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod2, jbod6, 3, 3);
    assertThat(diff.changesType(), is(false));
    assertThat(diff.isEmpty(), is(true));
    assertThat(diff.shrinkSize(), is(false));
    assertThat(diff.isVolumesAddedOrRemoved(), is(true));
}
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) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 52 with PersistentClaimStorageBuilder

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

the class StorageDiffTest method testPersistentDiffWithOverrides.

@ParallelTest
public void testPersistentDiffWithOverrides() {
    Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build();
    Storage persistent2 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az1").build()).build();
    Storage persistent3 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az2").build()).build();
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, 3, 3).changesType(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, 3, 3).isEmpty(), is(true));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, 3, 3).shrinkSize(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 3, 3).changesType(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 3, 3).isEmpty(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 3, 3).shrinkSize(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 3, 3).changesType(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 3, 3).isEmpty(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 3, 3).shrinkSize(), is(false));
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) PersistentClaimStorageOverrideBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 53 with PersistentClaimStorageBuilder

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

the class StorageDiffTest method testPersistentDiffWithOverridesBeingAdded.

@ParallelTest
public void testPersistentDiffWithOverridesBeingAdded() {
    Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build();
    Storage persistent2 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(0).withStorageClass("gp2-ssd-az1").build()).build();
    Storage persistent3 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(0).withStorageClass("gp2-ssd-az1").build(), new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az2").build()).build();
    // Test no changes
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, 2, 2).isEmpty(), is(true));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent2, 2, 2).isEmpty(), is(true));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent3, persistent3, 2, 2).isEmpty(), is(true));
    // Overrides added for existing nodes => not allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 2, 2).isEmpty(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent3, 2, 2).isEmpty(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 2, 2).isEmpty(), is(false));
    // Overrides added for new nodes => allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 1, 2).isEmpty(), is(true));
    // Overrides added for removed nodes => allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 2, 1).isEmpty(), is(true));
    // Overrides added for non-existing nodes => allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, 1, 1).isEmpty(), is(true));
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) PersistentClaimStorageOverrideBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 54 with PersistentClaimStorageBuilder

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

the class StorageDiffTest method testPersistentDiffWithOverridesBeingAddedAndRemoved.

@ParallelTest
public void testPersistentDiffWithOverridesBeingAddedAndRemoved() {
    Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(0).withStorageClass("gp2-ssd-az1").build()).build();
    Storage persistent2 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az2").build()).build();
    // Test no changes
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, 2, 2).isEmpty(), is(true));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent2, 2, 2).isEmpty(), is(true));
    // Overrides added and removed for existing nodes => not allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent, 2, 2).isEmpty(), is(false));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 2, 2).isEmpty(), is(false));
    // Overrides added for new nodes but removed for old => not allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 1, 2).isEmpty(), is(false));
    // Overrides removed for new nodes but added for old => not allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent, 1, 2).isEmpty(), is(false));
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) PersistentClaimStorageOverrideBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 55 with PersistentClaimStorageBuilder

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

the class StorageDiffTest method testPersistentDiffWithOverridesChangesToExistingOverrides.

@ParallelTest
public void testPersistentDiffWithOverridesChangesToExistingOverrides() {
    Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(0).withStorageClass("gp2-ssd-az1").build(), new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az2").build()).build();
    Storage persistent2 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(0).withStorageClass("gp2-ssd-az1").build(), new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("new-sc").build()).build();
    // Test no changes when the diff is the same
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, 2, 2).isEmpty(), is(true));
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent2, 2, 2).isEmpty(), is(true));
    // Override changed for node which does not exist => is allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 1, 1).isEmpty(), is(true));
    // Override changed for node which is being scaled up => is allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 1, 2).isEmpty(), is(true));
    // Override changed for existing node  => is not allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 2, 2).isEmpty(), is(false));
    // Override changed for node being scaled down => is allowed
    assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, 2, 1).isEmpty(), is(true));
}
Also used : Storage(io.strimzi.api.kafka.model.storage.Storage) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) PersistentClaimStorageOverrideBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

PersistentClaimStorageBuilder (io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder)95 ParallelTest (io.strimzi.test.annotations.ParallelTest)64 JbodStorageBuilder (io.strimzi.api.kafka.model.storage.JbodStorageBuilder)52 Storage (io.strimzi.api.kafka.model.storage.Storage)45 Kafka (io.strimzi.api.kafka.model.Kafka)38 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)36 PersistentVolumeClaim (io.fabric8.kubernetes.api.model.PersistentVolumeClaim)23 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)22 SingleVolumeStorage (io.strimzi.api.kafka.model.storage.SingleVolumeStorage)21 JbodStorage (io.strimzi.api.kafka.model.storage.JbodStorage)20 ArrayList (java.util.ArrayList)19 PersistentClaimStorageOverrideBuilder (io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder)17 Quantity (io.fabric8.kubernetes.api.model.Quantity)16 EphemeralStorageBuilder (io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder)16 List (java.util.List)16 TopologySpreadConstraint (io.fabric8.kubernetes.api.model.TopologySpreadConstraint)15 KRaftNotSupported (io.strimzi.systemtest.annotations.KRaftNotSupported)14 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)14 Map (java.util.Map)14 CoreMatchers.is (org.hamcrest.CoreMatchers.is)14