use of io.strimzi.api.kafka.model.storage.Storage in project strimzi-kafka-operator by strimzi.
the class KafkaAssemblyOperatorMockTest method data.
public static Iterable<KafkaAssemblyOperatorMockTest.Params> data() {
int[] replicas = { 1, 3 };
int[] storageOptions = { 0, 1, 2 };
Storage[] kafkaStorageConfigs = { new EphemeralStorage(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(true).build(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(false).build() };
SingleVolumeStorage[] zkStorageConfigs = { new EphemeralStorage(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(true).build(), new PersistentClaimStorageBuilder().withSize("123").withStorageClass("foo").withDeleteClaim(false).build() };
ResourceRequirements[] resources = { new ResourceRequirementsBuilder().addToLimits("cpu", new Quantity("5000m")).addToLimits("memory", new Quantity("5000m")).addToRequests("cpu", new Quantity("5000")).addToRequests("memory", new Quantity("5000m")).build() };
List<KafkaAssemblyOperatorMockTest.Params> result = new ArrayList();
for (int replicaCount : replicas) {
for (int storage : storageOptions) {
for (ResourceRequirements resource : resources) {
result.add(new KafkaAssemblyOperatorMockTest.Params(replicaCount, zkStorageConfigs[storage], replicaCount, kafkaStorageConfigs[storage], resource));
}
}
}
return result;
}
use of io.strimzi.api.kafka.model.storage.Storage in project strimzi-kafka-operator by strimzi.
the class KafkaAssemblyOperatorMockTest method testReconcileUpdatesKafkaPersistentVolumes.
@ParameterizedTest
@MethodSource("data")
public void testReconcileUpdatesKafkaPersistentVolumes(Params params, VertxTestContext context) {
init(params);
assumeTrue(kafkaStorage instanceof PersistentClaimStorage, "Parameterized Test only runs for Params with Kafka Persistent storage");
String originalStorageClass = Storage.storageClass(kafkaStorage);
Checkpoint async = context.checkpoint();
initialReconcile(context).onComplete(context.succeeding(v -> context.verify(() -> {
assertStorageClass(context, KafkaCluster.kafkaClusterName(CLUSTER_NAME), originalStorageClass);
// Try to update the storage class
String changedClass = originalStorageClass + "2";
Kafka patchedPersistenceKafka = new KafkaBuilder(cluster).editSpec().editKafka().withNewPersistentClaimStorage().withStorageClass(changedClass).withSize("123").endPersistentClaimStorage().endKafka().endSpec().build();
kafkaAssembly(NAMESPACE, CLUSTER_NAME).patch(patchedPersistenceKafka);
LOGGER.info("Updating with changed storage class");
}))).compose(v -> operator.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME))).onComplete(context.succeeding(v -> context.verify(() -> {
// Check the storage class was not changed
assertStorageClass(context, KafkaCluster.kafkaClusterName(CLUSTER_NAME), originalStorageClass);
async.flag();
})));
}
use of io.strimzi.api.kafka.model.storage.Storage in project strimzi-kafka-operator 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}"));
}
use of io.strimzi.api.kafka.model.storage.Storage in project strimzi-kafka-operator 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.Storage in project strimzi-kafka-operator by strimzi.
the class ZookeeperClusterTest method testStorageValidationAfterInitialDeployment.
@ParallelTest
public void testStorageValidationAfterInitialDeployment() {
assertThrows(InvalidResourceException.class, () -> {
Storage oldStorage = new PersistentClaimStorageBuilder().withSize("100Gi").build();
Kafka kafkaAssembly = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout, jmxMetricsConfig, configurationJson, zooConfigurationJson)).editSpec().editZookeeper().withStorage(new PersistentClaimStorageBuilder().build()).endZookeeper().endSpec().build();
ZookeeperCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, kafkaAssembly, VERSIONS, oldStorage, replicas);
});
}
Aggregations