Search in sources :

Example 36 with CONFIG

use of org.bf2.admin.kafka.systemtest.Environment.CONFIG 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 37 with CONFIG

use of org.bf2.admin.kafka.systemtest.Environment.CONFIG 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 38 with CONFIG

use of org.bf2.admin.kafka.systemtest.Environment.CONFIG 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)

Example 39 with CONFIG

use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaClusterTest method testManagedKafkaToKafkaBrokerPerNode.

@Test
void testManagedKafkaToKafkaBrokerPerNode() throws IOException {
    KafkaInstanceConfiguration config = kafkaCluster.getKafkaConfiguration();
    config.getKafka().setOneInstancePerNode(true);
    config.getKafka().setColocateWithZookeeper(true);
    config.getExporter().setColocateWithZookeeper(true);
    try {
        ManagedKafka mk = exampleManagedKafka("60Gi");
        Kafka kafka = kafkaCluster.kafkaFrom(mk, null);
        diffToExpected(kafka.getSpec().getKafka().getTemplate(), "/expected/broker-per-node-kafka.yml");
        diffToExpected(kafka.getSpec().getKafkaExporter().getTemplate(), "/expected/broker-per-node-exporter.yml");
        diffToExpected(kafka.getSpec().getZookeeper().getTemplate(), "/expected/broker-per-node-zookeeper.yml");
    } finally {
        config.getKafka().setOneInstancePerNode(false);
        config.getKafka().setColocateWithZookeeper(false);
        config.getExporter().setColocateWithZookeeper(false);
    }
}
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 40 with CONFIG

use of org.bf2.admin.kafka.systemtest.Environment.CONFIG in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class ObservabilityManagerTest method testObservabilitySecret.

@Test
public void testObservabilitySecret() {
    client.getConfiguration().setNamespace("test");
    ObservabilityConfiguration config = new ObservabilityConfigurationBuilder().withAccessToken("test-token").withChannel("test").withRepository("test-repo").withTag("tag").build();
    String ownerName = "SampleOwner";
    Secret owner = client.secrets().inNamespace(client.getNamespace()).withName(ownerName).create(new SecretBuilder().withNewMetadata().withNamespace(client.getNamespace()).withName(ownerName).endMetadata().addToData("key", "value").build());
    this.observabilityManager.createOrUpdateObservabilitySecret(config, owner);
    // lets call event handler
    Secret secret = observabilityManager.observabilitySecretResource().get();
    assertNotNull(secret);
    // the mock informermanager should be immediately updated, but it should
    // not be seen as running
    assertNotNull(observabilityManager.cachedObservabilitySecret());
    assertFalse(observabilityManager.isObservabilityRunning());
    assertFalse(secret.getMetadata().getOwnerReferences().isEmpty());
    ObservabilityConfiguration secretConfig = new ObservabilityConfigurationBuilder().withAccessToken(new String(decoder.decode(secret.getData().get(ObservabilityManager.OBSERVABILITY_ACCESS_TOKEN)))).withChannel(new String(decoder.decode(secret.getData().get(ObservabilityManager.OBSERVABILITY_CHANNEL)))).withTag(new String(decoder.decode(secret.getData().get(ObservabilityManager.OBSERVABILITY_TAG)))).withRepository(new String(decoder.decode(secret.getData().get(ObservabilityManager.OBSERVABILITY_REPOSITORY)))).build();
    // secret verification
    assertEquals(secretConfig, config);
    assertEquals("observability-operator", secret.getMetadata().getLabels().get("configures"));
    // status verification, the Informers do not work in test framework thus direct verification
    secret = ObservabilityManager.createObservabilitySecretBuilder(client.getNamespace(), config).editMetadata().addToAnnotations(ObservabilityManager.OBSERVABILITY_OPERATOR_STATUS, ObservabilityManager.ACCEPTED).endMetadata().build();
    observabilityManager.observabilitySecretResource().createOrReplace(secret);
    secret = observabilityManager.observabilitySecretResource().get();
    assertTrue(ObservabilityManager.isObservabilityStatusAccepted(secret));
    this.observabilityManager.createOrUpdateObservabilitySecret(config, owner);
    // no-op update and make sure the flag is not flipped
    secret = observabilityManager.observabilitySecretResource().get();
    assertTrue(ObservabilityManager.isObservabilityStatusAccepted(secret));
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) SecretBuilder(io.fabric8.kubernetes.api.model.SecretBuilder) ObservabilityConfiguration(org.bf2.operator.resources.v1alpha1.ObservabilityConfiguration) ObservabilityConfigurationBuilder(org.bf2.operator.resources.v1alpha1.ObservabilityConfigurationBuilder) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)15 Map (java.util.Map)12 Inject (javax.inject.Inject)12 QuarkusTest (io.quarkus.test.junit.QuarkusTest)9 List (java.util.List)9 Collectors (java.util.stream.Collectors)8 FleetShardClient (org.bf2.cos.fleetshard.sync.client.FleetShardClient)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 Secret (io.fabric8.kubernetes.api.model.Secret)7 HashMap (java.util.HashMap)7 Objects (java.util.Objects)6 ApplicationScoped (javax.enterprise.context.ApplicationScoped)6 ManagedConnector (org.bf2.cos.fleetshard.api.ManagedConnector)6 FleetShardSyncConfig (org.bf2.cos.fleetshard.sync.FleetShardSyncConfig)6 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)5 ArrayList (java.util.ArrayList)5 Optional (java.util.Optional)5 Set (java.util.Set)5 TopicUtils (org.bf2.admin.kafka.systemtest.utils.TopicUtils)5 Namespace (io.fabric8.kubernetes.api.model.Namespace)4