Search in sources :

Example 66 with ManagedKafka

use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaClusterTest method pausedUnknownStatus.

@Test
void pausedUnknownStatus() throws InterruptedException {
    ManagedKafka mk = ManagedKafka.getDummyInstance(1);
    InformerManager informer = Mockito.mock(InformerManager.class);
    Kafka kafka = new KafkaBuilder(this.kafkaCluster.kafkaFrom(mk, null)).editMetadata().withAnnotations(Map.of(StrimziManager.STRIMZI_PAUSE_REASON_ANNOTATION, "custom")).endMetadata().withNewStatus().withConditions(new ConditionBuilder().withType("ReconciliationPaused").withStatus("True").build()).endStatus().build();
    Mockito.when(informer.getLocalKafka(Mockito.anyString(), Mockito.anyString())).thenReturn(kafka);
    QuarkusMock.installMockForType(informer, InformerManager.class);
    OperandReadiness readiness = this.kafkaCluster.getReadiness(mk);
    assertEquals(Status.Unknown, readiness.getStatus());
    assertEquals(Reason.Paused, readiness.getReason());
    assertEquals("Kafka mk-1 is paused for an unknown reason", readiness.getMessage());
}
Also used : ConditionBuilder(io.strimzi.api.kafka.model.status.ConditionBuilder) ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) InformerManager(org.bf2.operator.managers.InformerManager) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 67 with ManagedKafka

use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaClusterTest method testScalingAndReplicationFactor.

@Test
void testScalingAndReplicationFactor() throws IOException {
    KafkaInstanceConfiguration config = kafkaCluster.getKafkaConfiguration();
    try {
        KafkaInstanceConfiguration clone = Serialization.clone(config);
        clone.getKafka().setScalingAndReplicationFactor(1);
        kafkaCluster.setKafkaConfiguration(clone);
        ManagedKafka mk = exampleManagedKafka("60Gi");
        Kafka kafka = kafkaCluster.kafkaFrom(mk, null);
        diffToExpected(kafka.getSpec().getKafka().getConfig(), "/expected/scaling-one.yml");
    } finally {
        kafkaCluster.setKafkaConfiguration(config);
    }
}
Also used : ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 68 with ManagedKafka

use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaClusterTest method testManagedKafkaToKafkaWithCustomConfiguration.

@Test
void testManagedKafkaToKafkaWithCustomConfiguration() throws IOException {
    KafkaInstanceConfiguration config = kafkaCluster.getKafkaConfiguration();
    try {
        KafkaInstanceConfiguration clone = Serialization.clone(config);
        clone.getKafka().setConnectionAttemptsPerSec(300);
        clone.getKafka().setContainerMemory("2Gi");
        clone.getKafka().setJvmXx("foo bar, foo2 bar2");
        clone.getZookeeper().setReplicas(5);
        clone.getZookeeper().setContainerMemory("11Gi");
        clone.getZookeeper().setJvmXx("zkfoo zkbar, zkfoo2 zkbar2");
        clone.getKafka().setOneInstancePerNode(false);
        clone.getKafka().setColocateWithZookeeper(false);
        clone.getExporter().setColocateWithZookeeper(false);
        kafkaCluster.setKafkaConfiguration(clone);
        ManagedKafka mk = exampleManagedKafka("60Gi");
        mk.getSpec().getCapacity().setMaxPartitions(2 * clone.getKafka().getPartitionCapacity());
        Kafka kafka = kafkaCluster.kafkaFrom(mk, null);
        diffToExpected(kafka, "/expected/custom-config-strimzi.yml");
    } finally {
        kafkaCluster.setKafkaConfiguration(config);
    }
}
Also used : ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 69 with ManagedKafka

use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaClusterTest method testDrainCleanerWebhookFound.

@Test
void testDrainCleanerWebhookFound() throws IOException {
    DrainCleanerManager mock = Mockito.mock(DrainCleanerManager.class);
    Mockito.when(mock.isDrainCleanerWebhookFound()).thenReturn(true);
    QuarkusMock.installMockForType(mock, DrainCleanerManager.class);
    ManagedKafka mk = exampleManagedKafka("40Gi");
    Kafka kafka = kafkaCluster.kafkaFrom(mk, null);
    assertEquals(0, kafka.getSpec().getKafka().getTemplate().getPodDisruptionBudget().getMaxUnavailable());
    assertEquals(0, kafka.getSpec().getZookeeper().getTemplate().getPodDisruptionBudget().getMaxUnavailable());
}
Also used : ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) DrainCleanerManager(org.bf2.operator.managers.DrainCleanerManager) ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 70 with ManagedKafka

use of org.bf2.operator.resources.v1alpha1.ManagedKafka in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaClusterTest method testManagedKafkaToKafka.

@Test
void testManagedKafkaToKafka() throws IOException {
    KafkaInstanceConfiguration config = kafkaCluster.getKafkaConfiguration();
    try {
        ObjectMapper objectMapper = new ObjectMapper();
        KafkaInstanceConfiguration clone = objectMapper.readValue(objectMapper.writeValueAsString(config), KafkaInstanceConfiguration.class);
        clone.getKafka().setOneInstancePerNode(false);
        clone.getKafka().setColocateWithZookeeper(false);
        clone.getExporter().setColocateWithZookeeper(false);
        kafkaCluster.setKafkaConfiguration(clone);
        ManagedKafka mk = exampleManagedKafka("60Gi");
        Kafka kafka = kafkaCluster.kafkaFrom(mk, null);
        diffToExpected(kafka, "/expected/strimzi.yml");
    } finally {
        kafkaCluster.setKafkaConfiguration(config);
    }
}
Also used : ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaUtils.exampleManagedKafka(org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka) Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ManagedKafka (org.bf2.operator.resources.v1alpha1.ManagedKafka)67 Kafka (io.strimzi.api.kafka.model.Kafka)30 Test (org.junit.jupiter.api.Test)24 QuarkusTest (io.quarkus.test.junit.QuarkusTest)23 List (java.util.List)16 Map (java.util.Map)15 Inject (javax.inject.Inject)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Objects (java.util.Objects)14 Quantity (io.fabric8.kubernetes.api.model.Quantity)11 Optional (java.util.Optional)11 Collectors (java.util.stream.Collectors)10 ApplicationScoped (javax.enterprise.context.ApplicationScoped)9 StrimziManager (org.bf2.operator.managers.StrimziManager)9 Logger (org.jboss.logging.Logger)9 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)8 ArrayList (java.util.ArrayList)8 Reason (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Reason)8 Status (org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status)8 ManagedKafkaUtils.exampleManagedKafka (org.bf2.operator.utils.ManagedKafkaUtils.exampleManagedKafka)8