use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi by strimzi.
the class KafkaBrokerConfigurationBuilderTest method testPerBrokerPersistentStorageLogDirs.
@ParallelTest
public void testPerBrokerPersistentStorageLogDirs() {
Storage storage = new PersistentClaimStorageBuilder().withSize("1Ti").withStorageClass("aws-ebs").withDeleteClaim(true).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/kafka-log2"));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi 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 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).withConfig(Map.of("default.replication.factor", 3, "min.insync.replicas", 2)).endKafka().endSpec().build();
KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, ephemeral, replicas, false);
// 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).withConfig(Map.of("default.replication.factor", 3, "min.insync.replicas", 2)).endKafka().endSpec().build();
kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, persistent, replicas, false);
// 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).withConfig(Map.of("default.replication.factor", 3, "min.insync.replicas", 2)).endKafka().endSpec().build();
kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, jbod, replicas, false);
// 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).withConfig(Map.of("default.replication.factor", 3, "min.insync.replicas", 2)).endKafka().endSpec().build();
kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, jbod, replicas, false);
// 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"));
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi by strimzi.
the class KafkaClusterTest method testGeneratePersistentVolumeClaimsJbodWithTemplate.
@ParallelTest
public void testGeneratePersistentVolumeClaimsJbodWithTemplate() {
Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configuration, emptyMap())).editSpec().editKafka().withNewTemplate().withNewPersistentVolumeClaim().withNewMetadata().withLabels(singletonMap("testLabel", "testValue")).withAnnotations(singletonMap("testAnno", "testValue")).endMetadata().endPersistentVolumeClaim().endTemplate().withStorage(new JbodStorageBuilder().withVolumes(new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-ssd-az1").build()).build(), new PersistentClaimStorageBuilder().withStorageClass("gp2-st1").withDeleteClaim(true).withId(1).withSize("1000Gi").withOverrides(new PersistentClaimStorageOverrideBuilder().withBroker(1).withStorageClass("gp2-st1-az1").build()).build()).build()).endKafka().endSpec().build();
KafkaCluster kc = KafkaCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS);
// Check PVCs
List<PersistentVolumeClaim> pvcs = kc.generatePersistentVolumeClaims(kc.getStorage());
assertThat(pvcs.size(), is(6));
for (int i = 0; i < 6; i++) {
PersistentVolumeClaim pvc = pvcs.get(i);
assertThat(pvc.getMetadata().getLabels().get("testLabel"), is("testValue"));
assertThat(pvc.getMetadata().getAnnotations().get("testAnno"), is("testValue"));
}
}
use of io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder in project strimzi 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