use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaBrokerConfigurationBuilderTest method testPersistentStorageLogDirs.
@ParallelTest
public void testPersistentStorageLogDirs() {
Storage storage = new PersistentClaimStorageBuilder().withSize("1Ti").withStorageClass("aws-ebs").withDeleteClaim(true).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}"));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaBrokerConfigurationBuilderTest method testPerBrokerJbodStorageLogDirs.
@ParallelTest
public void testPerBrokerJbodStorageLogDirs() {
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).withBrokerId("2").withLogDirs(VolumeUtils.createVolumeMounts(storage, "/var/lib/kafka", false)).build();
assertThat(configuration, isEquivalent("broker.id=2", "node.id=2", "log.dirs=/var/lib/kafka/data-1/kafka-log2,/var/lib/kafka/data-2/kafka-log2,/var/lib/kafka/data-5/kafka-log2"));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi-kafka-operator 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));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi-kafka-operator 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));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi-kafka-operator by strimzi.
the class StorageDiffTest method testPersistentDiffWithOverridesBeingRemoved.
@ParallelTest
public void testPersistentDiffWithOverridesBeingRemoved() {
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 removed for existing nodes => not allowed
assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent3, persistent, 2, 2).isEmpty(), is(false));
assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent3, persistent2, 2, 2).isEmpty(), is(false));
assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent, 2, 2).isEmpty(), is(false));
// Overrides removed for new nodes => allowed
assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent3, persistent2, 1, 2).isEmpty(), is(true));
// Overrides removed for removed nodes => allowed
assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent3, persistent2, 2, 1).isEmpty(), is(true));
// Overrides removed for non-existing nodes => allowed
assertThat(new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent3, persistent2, 1, 1).isEmpty(), is(true));
}
Aggregations