Search in sources :

Example 16 with ManagedKafka

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

the class IngressControllerManagerTest method testReplicaReduction.

@Test
public void testReplicaReduction() {
    openShiftClient.resourceList((List) buildNodes(12)).createOrReplace();
    IntStream.range(0, 6).forEach(i -> {
        ManagedKafka mk = ManagedKafka.getDummyInstance(1);
        mk.getMetadata().setName("ingressTest" + i);
        mk.getMetadata().setNamespace("ingressTest");
        mk.getSpec().getCapacity().setIngressPerSec(Quantity.parse("125Mi"));
        Kafka kafka = this.kafkaCluster.kafkaFrom(mk, null);
        openShiftClient.resource(kafka).createOrReplace();
    });
    informerManager.createKafkaInformer();
    ingressControllerManager.reconcileIngressControllers();
    checkAzReplicaCount(4);
    // remove two kafkas - we should keep the same number of replicas
    var kafkas = openShiftClient.resources(Kafka.class).inNamespace("ingressTest");
    assertTrue(kafkas.withName("ingressTest0").delete());
    assertTrue(kafkas.withName("ingressTest1").delete());
    ingressControllerManager.reconcileIngressControllers();
    checkAzReplicaCount(4);
    // remove two more kafkas - and we should reduce
    assertTrue(kafkas.withName("ingressTest2").delete());
    assertTrue(kafkas.withName("ingressTest3").delete());
    ingressControllerManager.reconcileIngressControllers();
    checkAzReplicaCount(2);
}
Also used : ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) List(java.util.List) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 17 with ManagedKafka

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

the class StrimziManager method currentStrimziVersion.

/**
 * Returns the current Strimzi version for the Kafka instance
 * It comes directly from the Kafka custom resource label or from the ManagedKafka in case of creation
 *
 * @param managedKafka ManagedKafka instance
 * @return current Strimzi version for the Kafka instance
 */
public String currentStrimziVersion(ManagedKafka managedKafka) {
    Kafka kafka = cachedKafka(managedKafka);
    // on first time Kafka resource creation, we take the Strimzi version from the ManagedKafka resource spec
    String kafkaStrimziVersion = kafka != null && kafka.getMetadata().getLabels() != null && kafka.getMetadata().getLabels().containsKey(this.versionLabel) ? kafka.getMetadata().getLabels().get(this.versionLabel) : managedKafka.getSpec().getVersions().getStrimzi();
    log.debugf("currentStrimziVersion = %s", kafkaStrimziVersion);
    return kafkaStrimziVersion;
}
Also used : Kafka(io.strimzi.api.kafka.model.Kafka) ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka)

Example 18 with ManagedKafka

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

the class MockManagedKafkaFactory method markForDeletion.

private void markForDeletion(String id) {
    ManagedKafka mk = this.kafkas.get(id);
    if (mk != null && !mk.isMarkedForDeletion()) {
        log.infof("Mock ManagedKafka Factory:: marking cluster %s for deletion", mk.getId());
        mk.getSpec().setDeleted(true);
        mkClient.patch(mk);
    } else {
        log.infof("Mock ManagedKafka Factory:: Is cluster %s already deleted?", id);
    }
}
Also used : ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka)

Example 19 with ManagedKafka

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

the class CanaryTest method createCanaryService.

@Test
void createCanaryService() throws Exception {
    ManagedKafka mk = new ManagedKafkaBuilder().withNewMetadata().withNamespace("test").withName("test-mk").endMetadata().withSpec(new ManagedKafkaSpecBuilder().withNewVersions().withKafka("2.6.0").endVersions().withNewEndpoint().withBootstrapServerHost("test-mk-kafka-bootstrap").endEndpoint().build()).build();
    Service canaryService = canary.serviceFrom(mk, null);
    server.getClient().services().create(canaryService);
    assertNotNull(server.getClient().services().inNamespace(canaryService.getMetadata().getNamespace()).withName(canaryService.getMetadata().getName()).get());
    KafkaClusterTest.diffToExpected(canaryService, "/expected/canary-service.yml");
}
Also used : ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaSpecBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaSpecBuilder) Service(io.fabric8.kubernetes.api.model.Service) ManagedKafkaBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaBuilder) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with ManagedKafka

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

the class CanaryTest method createCanaryDeployment.

@ParameterizedTest(name = "createCanaryDeployment: {0}")
@CsvSource({ "shouldHaveNoDiffByDefault, test-mk-kafka-bootstrap, '[]'", "shouldNotHaveInitContainersIfDevCluster, bootstrap.kas.testing.domain.tld, '[{\"op\":\"remove\",\"path\":\"/spec/template/spec/initContainers\"},{\"op\":\"replace\",\"path\":\"/spec/template/spec/containers/0/env/0/value\",\"value\":\"bootstrap.kas.testing.domain.tld:443\"}]'" })
void createCanaryDeployment(String name, String bootstrapServerHost, String expectedDiff) throws Exception {
    ManagedKafka mk = new ManagedKafkaBuilder().withNewMetadata().withNamespace("test").withName("test-mk").endMetadata().withSpec(new ManagedKafkaSpecBuilder().withNewVersions().withKafka("2.6.0").endVersions().withNewEndpoint().withBootstrapServerHost(bootstrapServerHost).endEndpoint().build()).build();
    Deployment canaryDeployment = canary.deploymentFrom(mk, null);
    KafkaClusterTest.diffToExpected(canaryDeployment, "/expected/canary.yml", expectedDiff);
}
Also used : ManagedKafka(org.bf2.operator.resources.v1alpha1.ManagedKafka) ManagedKafkaSpecBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ManagedKafkaBuilder(org.bf2.operator.resources.v1alpha1.ManagedKafkaBuilder) CsvSource(org.junit.jupiter.params.provider.CsvSource) 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