use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaSpecCheckerTest method checkKafkaJbodStorage.
@Test
public void checkKafkaJbodStorage() {
Kafka kafka = new KafkaBuilder(ResourceUtils.createKafka(NAMESPACE, NAME, 1, IMAGE, HEALTH_DELAY, HEALTH_TIMEOUT, null, emptyMap(), emptyMap(), new JbodStorageBuilder().withVolumes(new EphemeralStorageBuilder().withId(1).build(), new EphemeralStorageBuilder().withId(2).build()).build(), new EphemeralStorage(), null, null, null, null)).editSpec().editZookeeper().withReplicas(3).endZookeeper().endSpec().build();
KafkaSpecChecker checker = generateChecker(kafka);
List<Condition> warnings = checker.run();
assertThat(warnings, hasSize(1));
Condition warning = warnings.get(0);
assertThat(warning.getReason(), is("KafkaStorage"));
assertThat(warning.getStatus(), is("True"));
assertThat(warning.getMessage(), is("A Kafka cluster with a single replica and ephemeral storage will lose topic messages after any restart or rolling update."));
}
use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder in project strimzi 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}"));
}
use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder in project strimzi by strimzi.
the class ModelUtilsTest method testStorageSerializationAndDeserialization.
@ParallelTest
public void testStorageSerializationAndDeserialization() {
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();
assertThat(ModelUtils.decodeStorageFromJson(ModelUtils.encodeStorageToJson(jbod)), is(jbod));
assertThat(ModelUtils.decodeStorageFromJson(ModelUtils.encodeStorageToJson(ephemeral)), is(ephemeral));
assertThat(ModelUtils.decodeStorageFromJson(ModelUtils.encodeStorageToJson(persistent)), is(persistent));
}
use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder in project strimzi 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));
}
use of io.strimzi.api.kafka.model.storage.EphemeralStorageBuilder in project strimzi 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}"));
}
Aggregations