Search in sources :

Example 86 with MockCertManager

use of io.strimzi.operator.common.operator.MockCertManager in project strimzi-kafka-operator by strimzi.

the class PartialRollingUpdateTest method startKube.

private void startKube() {
    CustomResourceDefinition kafkaAssemblyCrd = Crds.kafka();
    this.mockClient = new MockKube().withCustomResourceDefinition(kafkaAssemblyCrd, Kafka.class, KafkaList.class).withInitialInstances(Collections.singleton(cluster)).end().withCustomResourceDefinition(Crds.strimziPodSet(), StrimziPodSet.class, StrimziPodSetList.class).end().withInitialStatefulSets(set(zkSts, kafkaSts)).withInitialPods(set(zkPod0, zkPod1, zkPod2, kafkaPod0, kafkaPod1, kafkaPod2, kafkaPod3, kafkaPod4)).withInitialSecrets(set(clusterCaCert, clusterCaKey, clientsCaCert, clientsCaKey)).build();
    ResourceOperatorSupplier supplier = supplier(mockClient);
    this.kco = new KafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(true, KubernetesVersion.V1_16), new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
    LOGGER.info("Started test KafkaAssemblyOperator");
}
Also used : ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) MockKube(io.strimzi.test.mockkube.MockKube) MockCertManager(io.strimzi.operator.common.operator.MockCertManager) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) PasswordGenerator(io.strimzi.operator.common.PasswordGenerator) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaList(io.strimzi.api.kafka.KafkaList)

Example 87 with MockCertManager

use of io.strimzi.operator.common.operator.MockCertManager in project strimzi by strimzi.

the class PartialRollingUpdateTest method beforeEach.

@BeforeEach
public void beforeEach(VertxTestContext context) throws InterruptedException, ExecutionException, TimeoutException {
    this.cluster = new KafkaBuilder().withMetadata(new ObjectMetaBuilder().withName(CLUSTER_NAME).withNamespace(NAMESPACE).build()).withNewSpec().withNewKafka().withReplicas(5).withListeners(new GenericKafkaListenerBuilder().withName("plain").withPort(9092).withType(KafkaListenerType.INTERNAL).withTls(false).build(), new GenericKafkaListenerBuilder().withName("tls").withPort(9093).withType(KafkaListenerType.INTERNAL).withTls(true).build()).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endKafka().withNewZookeeper().withReplicas(3).withNewPersistentClaimStorage().withSize("123").withStorageClass("foo").withDeleteClaim(true).endPersistentClaimStorage().endZookeeper().endSpec().build();
    CustomResourceDefinition kafkaAssemblyCrd = Crds.kafka();
    KubernetesClient bootstrapClient = new MockKube().withCustomResourceDefinition(kafkaAssemblyCrd, Kafka.class, KafkaList.class).withInitialInstances(Collections.singleton(cluster)).end().withCustomResourceDefinition(Crds.strimziPodSet(), StrimziPodSet.class, StrimziPodSetList.class).end().build();
    ResourceOperatorSupplier supplier = supplier(bootstrapClient);
    KafkaAssemblyOperator kco = new KafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(true, KubernetesVersion.V1_16), new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
    LOGGER.info("bootstrap reconciliation");
    CountDownLatch createAsync = new CountDownLatch(1);
    kco.reconcile(new Reconciliation("test-trigger", Kafka.RESOURCE_KIND, NAMESPACE, CLUSTER_NAME)).onComplete(ar -> {
        context.verify(() -> assertThat(ar.succeeded(), is(true)));
        createAsync.countDown();
    });
    if (!createAsync.await(60, TimeUnit.SECONDS)) {
        context.failNow(new Throwable("Test timeout"));
    }
    context.completeNow();
    LOGGER.info("bootstrap reconciliation complete");
    this.kafkaSts = bootstrapClient.apps().statefulSets().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaClusterName(CLUSTER_NAME)).get();
    this.zkSts = bootstrapClient.apps().statefulSets().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperClusterName(CLUSTER_NAME)).get();
    this.zkPod0 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperPodName(CLUSTER_NAME, 0)).get();
    this.zkPod1 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperPodName(CLUSTER_NAME, 1)).get();
    this.zkPod2 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(ZookeeperCluster.zookeeperPodName(CLUSTER_NAME, 2)).get();
    this.kafkaPod0 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaPodName(CLUSTER_NAME, 0)).get();
    this.kafkaPod1 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaPodName(CLUSTER_NAME, 1)).get();
    this.kafkaPod2 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaPodName(CLUSTER_NAME, 2)).get();
    this.kafkaPod3 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaPodName(CLUSTER_NAME, 3)).get();
    this.kafkaPod4 = bootstrapClient.pods().inNamespace(NAMESPACE).withName(KafkaCluster.kafkaPodName(CLUSTER_NAME, 4)).get();
    this.clusterCaCert = bootstrapClient.secrets().inNamespace(NAMESPACE).withName(KafkaResources.clusterCaCertificateSecretName(CLUSTER_NAME)).get();
    this.clusterCaKey = bootstrapClient.secrets().inNamespace(NAMESPACE).withName(KafkaResources.clusterCaKeySecretName(CLUSTER_NAME)).get();
    this.clientsCaCert = bootstrapClient.secrets().inNamespace(NAMESPACE).withName(KafkaResources.clientsCaCertificateSecretName(CLUSTER_NAME)).get();
    this.clientsCaKey = bootstrapClient.secrets().inNamespace(NAMESPACE).withName(KafkaResources.clientsCaKeySecretName(CLUSTER_NAME)).get();
    context.completeNow();
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) ObjectMetaBuilder(io.fabric8.kubernetes.api.model.ObjectMetaBuilder) CountDownLatch(java.util.concurrent.CountDownLatch) KafkaList(io.strimzi.api.kafka.KafkaList) ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) MockKube(io.strimzi.test.mockkube.MockKube) MockCertManager(io.strimzi.operator.common.operator.MockCertManager) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) PasswordGenerator(io.strimzi.operator.common.PasswordGenerator) Reconciliation(io.strimzi.operator.common.Reconciliation) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 88 with MockCertManager

use of io.strimzi.operator.common.operator.MockCertManager in project strimzi by strimzi.

the class PartialRollingUpdateTest method startKube.

private void startKube() {
    CustomResourceDefinition kafkaAssemblyCrd = Crds.kafka();
    this.mockClient = new MockKube().withCustomResourceDefinition(kafkaAssemblyCrd, Kafka.class, KafkaList.class).withInitialInstances(Collections.singleton(cluster)).end().withCustomResourceDefinition(Crds.strimziPodSet(), StrimziPodSet.class, StrimziPodSetList.class).end().withInitialStatefulSets(set(zkSts, kafkaSts)).withInitialPods(set(zkPod0, zkPod1, zkPod2, kafkaPod0, kafkaPod1, kafkaPod2, kafkaPod3, kafkaPod4)).withInitialSecrets(set(clusterCaCert, clusterCaKey, clientsCaCert, clientsCaKey)).build();
    ResourceOperatorSupplier supplier = supplier(mockClient);
    this.kco = new KafkaAssemblyOperator(vertx, new PlatformFeaturesAvailability(true, KubernetesVersion.V1_16), new MockCertManager(), new PasswordGenerator(10, "a", "a"), supplier, ResourceUtils.dummyClusterOperatorConfig(VERSIONS, 2_000));
    LOGGER.info("Started test KafkaAssemblyOperator");
}
Also used : ResourceOperatorSupplier(io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier) MockKube(io.strimzi.test.mockkube.MockKube) MockCertManager(io.strimzi.operator.common.operator.MockCertManager) PlatformFeaturesAvailability(io.strimzi.operator.PlatformFeaturesAvailability) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition) PasswordGenerator(io.strimzi.operator.common.PasswordGenerator) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaList(io.strimzi.api.kafka.KafkaList)

Aggregations

MockCertManager (io.strimzi.operator.common.operator.MockCertManager)88 Reconciliation (io.strimzi.operator.common.Reconciliation)78 Labels (io.strimzi.operator.common.model.Labels)72 SecretOperator (io.strimzi.operator.common.operator.resource.SecretOperator)72 Future (io.vertx.core.Future)72 Vertx (io.vertx.core.Vertx)72 Checkpoint (io.vertx.junit5.Checkpoint)72 VertxExtension (io.vertx.junit5.VertxExtension)72 VertxTestContext (io.vertx.junit5.VertxTestContext)72 Arrays.asList (java.util.Arrays.asList)72 List (java.util.List)72 Map (java.util.Map)72 Optional (java.util.Optional)72 Set (java.util.Set)72 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)72 CoreMatchers.is (org.hamcrest.CoreMatchers.is)72 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)72 Matchers.hasSize (org.hamcrest.Matchers.hasSize)72 AfterAll (org.junit.jupiter.api.AfterAll)72 BeforeAll (org.junit.jupiter.api.BeforeAll)72