use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder 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.PersistentClaimStorageOverrideBuilder 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.PersistentClaimStorageOverrideBuilder in project strimzi-kafka-operator 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));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder 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));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageOverrideBuilder in project strimzi-kafka-operator by strimzi.
the class ZookeeperClusterTest method testGeneratePersistentVolumeClaimsWithTemplate.
@ParallelTest
public void testGeneratePersistentVolumeClaimsWithTemplate() {
Kafka ka = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configurationJson, zooConfigurationJson)).editSpec().editZookeeper().withNewTemplate().withNewPersistentVolumeClaim().withNewMetadata().withLabels(singletonMap("testLabel", "testValue")).withAnnotations(singletonMap("testAnno", "testValue")).endMetadata().endPersistentVolumeClaim().endTemplate().withStorage(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az1").build()).build()).endZookeeper().endSpec().build();
ZookeeperCluster zc = ZookeeperCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, ka, VERSIONS);
// Check PVCs
List<PersistentVolumeClaim> pvcs = zc.generatePersistentVolumeClaims();
assertThat(pvcs.size(), is(3));
for (int i = 0; i < 3; i++) {
PersistentVolumeClaim pvc = pvcs.get(i);
assertThat(pvc.getMetadata().getLabels().get("testLabel"), is("testValue"));
assertThat(pvc.getMetadata().getAnnotations().get("testAnno"), is("testValue"));
}
}
Aggregations