Search in sources :

Example 66 with Kafka

use of io.strimzi.api.kafka.model.Kafka in project debezium by debezium.

the class OcpKafkaDeployer method deploy.

/**
 * Deploys Kafka Cluster
 * @return {@link OcpKafkaController} instance for deployed cluster
 * @throws InterruptedException
 */
@Override
public OcpKafkaController deploy() throws InterruptedException {
    LOGGER.info("Deploying Kafka Cluster");
    Kafka kafka = kafkaOperation().createOrReplace(strimziBuilder.build());
    OcpKafkaController controller = new OcpKafkaController(kafka, operatorController, ocp);
    controller.waitForCluster();
    return controller;
}
Also used : Kafka(io.strimzi.api.kafka.model.Kafka)

Example 67 with Kafka

use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.

the class FeatureGatesIsolatedST method testSwitchingStrimziPodSetFeatureGateOnAndOff.

@IsolatedTest
void testSwitchingStrimziPodSetFeatureGateOnAndOff(ExtensionContext extensionContext) {
    assumeFalse(Environment.isOlmInstall() || Environment.isHelmInstall());
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final String producerName = "producer-test-" + new Random().nextInt(Integer.MAX_VALUE);
    final String consumerName = "consumer-test-" + new Random().nextInt(Integer.MAX_VALUE);
    final String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
    int zkReplicas = 1;
    int kafkaReplicas = 3;
    final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    int messageCount = 500;
    List<EnvVar> coEnvVars = new ArrayList<>();
    coEnvVars.add(new EnvVar(Environment.STRIMZI_FEATURE_GATES_ENV, "-UseStrimziPodSets", null));
    LOGGER.info("Deploying CO with STS - SPS is disabled");
    clusterOperator.unInstall();
    clusterOperator = new SetupClusterOperator.SetupClusterOperatorBuilder().withExtensionContext(BeforeAllOnce.getSharedExtensionContext()).withNamespace(INFRA_NAMESPACE).withWatchingNamespaces(Constants.WATCH_ALL_NAMESPACES).withExtraEnvVars(coEnvVars).createInstallation().runInstallation();
    LOGGER.info("Deploying Kafka");
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaPersistent(clusterName, kafkaReplicas, zkReplicas).build());
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(clusterName, topicName).build());
    Map<String, String> kafkaPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), kafkaSelector);
    Map<String, String> zkPods = PodUtils.podSnapshot(clusterOperator.getDeploymentNamespace(), zkSelector);
    Map<String, String> coPod = DeploymentUtils.depSnapshot(ResourceManager.getCoDeploymentName());
    KafkaClients clients = new KafkaClientsBuilder().withProducerName(producerName).withConsumerName(consumerName).withBootstrapAddress(KafkaResources.plainBootstrapAddress(clusterName)).withTopicName(topicName).withMessageCount(messageCount).withDelayMs(1000).withNamespaceName(clusterOperator.getDeploymentNamespace()).build();
    resourceManager.createResource(extensionContext, clients.producerStrimzi(), clients.consumerStrimzi());
    LOGGER.info("Changing FG env variable to enable SPS");
    coEnvVars = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME).getSpec().getTemplate().getSpec().getContainers().get(0).getEnv();
    coEnvVars.stream().filter(env -> env.getName().equals(Environment.STRIMZI_FEATURE_GATES_ENV)).findFirst().get().setValue("+UseStrimziPodSets");
    Deployment coDep = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME);
    coDep.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(coEnvVars);
    kubeClient().getClient().apps().deployments().inNamespace(clusterOperator.getDeploymentNamespace()).withName(Constants.STRIMZI_DEPLOYMENT_NAME).replace(coDep);
    coPod = DeploymentUtils.waitTillDepHasRolled(Constants.STRIMZI_DEPLOYMENT_NAME, 1, coPod);
    zkPods = RollingUpdateUtils.waitTillComponentHasRolled(zkSelector, zkReplicas, zkPods);
    kafkaPods = RollingUpdateUtils.waitTillComponentHasRolled(kafkaSelector, kafkaReplicas, kafkaPods);
    KafkaUtils.waitForKafkaReady(clusterName);
    LOGGER.info("Changing FG env variable to disable again SPS");
    coEnvVars.stream().filter(env -> env.getName().equals(Environment.STRIMZI_FEATURE_GATES_ENV)).findFirst().get().setValue("");
    coDep = kubeClient().getDeployment(Constants.STRIMZI_DEPLOYMENT_NAME);
    coDep.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(coEnvVars);
    kubeClient().getClient().apps().deployments().inNamespace(clusterOperator.getDeploymentNamespace()).withName(Constants.STRIMZI_DEPLOYMENT_NAME).replace(coDep);
    DeploymentUtils.waitTillDepHasRolled(Constants.STRIMZI_DEPLOYMENT_NAME, 1, coPod);
    RollingUpdateUtils.waitTillComponentHasRolled(zkSelector, zkReplicas, zkPods);
    RollingUpdateUtils.waitTillComponentHasRolled(kafkaSelector, kafkaReplicas, kafkaPods);
    ClientUtils.waitForClientsSuccess(producerName, consumerName, clusterOperator.getDeploymentNamespace(), messageCount);
}
Also used : KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) AbstractST(io.strimzi.systemtest.AbstractST) Environment(io.strimzi.systemtest.Environment) CoreMatchers.is(org.hamcrest.CoreMatchers.is) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) Annotations(io.strimzi.operator.common.Annotations) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) INFRA_NAMESPACE(io.strimzi.systemtest.Constants.INFRA_NAMESPACE) ArrayList(java.util.ArrayList) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) PodBuilder(io.fabric8.kubernetes.api.model.PodBuilder) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) IsolatedTest(io.strimzi.test.annotations.IsolatedTest) Assumptions.assumeFalse(org.junit.jupiter.api.Assumptions.assumeFalse) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) BeforeAllOnce(io.strimzi.systemtest.BeforeAllOnce) RollingUpdateUtils(io.strimzi.systemtest.utils.RollingUpdateUtils) KafkaUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) JobUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.JobUtils) Constants(io.strimzi.systemtest.Constants) Pod(io.fabric8.kubernetes.api.model.Pod) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) List(java.util.List) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) Logger(org.apache.logging.log4j.Logger) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Kafka(io.strimzi.api.kafka.model.Kafka) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) LogManager(org.apache.logging.log4j.LogManager) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) ArrayList(java.util.ArrayList) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) Random(java.util.Random) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) IsolatedTest(io.strimzi.test.annotations.IsolatedTest)

Example 68 with Kafka

use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.

the class AbstractST method verifyLabelsForService.

protected void verifyLabelsForService(String namespaceName, String clusterName, String serviceToTest, String kind) {
    LOGGER.info("Verifying labels for Kafka Connect Services");
    String serviceName = clusterName.concat("-").concat(serviceToTest);
    kubeClient(namespaceName).listServices().stream().filter(service -> service.getMetadata().getName().equals(serviceName)).forEach(service -> {
        LOGGER.info("Verifying labels for service {}", service.getMetadata().getName());
        assertThat(service.getMetadata().getLabels().get(Labels.STRIMZI_CLUSTER_LABEL), is(clusterName));
        assertThat(service.getMetadata().getLabels().get(Labels.STRIMZI_KIND_LABEL), is(kind));
        assertThat(service.getMetadata().getLabels().get(Labels.STRIMZI_NAME_LABEL), is(serviceName));
    });
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) CoreMatchers.is(org.hamcrest.CoreMatchers.is) BeforeEach(org.junit.jupiter.api.BeforeEach) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) AfterAll(org.junit.jupiter.api.AfterAll) TestInstance(org.junit.jupiter.api.TestInstance) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) IsNull.nullValue(org.hamcrest.core.IsNull.nullValue) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IndicativeSentences(io.strimzi.systemtest.interfaces.IndicativeSentences) Arrays.asList(java.util.Arrays.asList) ExecutionListener(io.strimzi.systemtest.listeners.ExecutionListener) Map(java.util.Map) StUtils(io.strimzi.systemtest.utils.StUtils) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Util.hashStub(io.strimzi.operator.common.Util.hashStub) TestExecutionWatcher(io.strimzi.systemtest.logs.TestExecutionWatcher) Collectors(java.util.stream.Collectors) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) SuiteThreadController(io.strimzi.systemtest.parallel.SuiteThreadController) Optional(java.util.Optional) Condition(io.strimzi.api.kafka.model.status.Condition) TestSuiteNamespaceManager(io.strimzi.systemtest.parallel.TestSuiteNamespaceManager) TestSeparator(io.strimzi.test.interfaces.TestSeparator) Assertions.fail(org.junit.jupiter.api.Assertions.fail) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) Container(io.fabric8.kubernetes.api.model.Container) OlmResource(io.strimzi.systemtest.resources.operator.specific.OlmResource) Matchers.logHasNoUnexpectedErrors(io.strimzi.systemtest.matchers.Matchers.logHasNoUnexpectedErrors) HashMap(java.util.HashMap) Crds(io.strimzi.api.kafka.Crds) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) TestStorage(io.strimzi.systemtest.storage.TestStorage) ArrayList(java.util.ArrayList) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) KubeClusterResource(io.strimzi.test.k8s.KubeClusterResource) TestUtils(io.strimzi.test.TestUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DisplayNameGeneration(org.junit.jupiter.api.DisplayNameGeneration) Pod(io.fabric8.kubernetes.api.model.Pod) SetupClusterOperator(io.strimzi.systemtest.resources.operator.SetupClusterOperator) KubernetesClusterUnstableException(io.strimzi.systemtest.exceptions.KubernetesClusterUnstableException) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) AfterEach(org.junit.jupiter.api.AfterEach) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaUserUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUserUtils) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 69 with Kafka

use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.

the class KafkaTemplates method kafkaWithMetrics.

public static KafkaBuilder kafkaWithMetrics(String name, String namespace, int kafkaReplicas, int zookeeperReplicas) {
    Kafka kafka = getKafkaFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG);
    ConfigMap metricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
    KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(namespace).createOrReplace(metricsCm);
    return defaultKafka(kafka, name, kafkaReplicas, zookeeperReplicas).editOrNewMetadata().withNamespace(namespace).endMetadata().editSpec().withNewKafkaExporter().endKafkaExporter().endSpec();
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Kafka(io.strimzi.api.kafka.model.Kafka)

Example 70 with Kafka

use of io.strimzi.api.kafka.model.Kafka in project strimzi by strimzi.

the class KafkaTemplates method kafkaAndCruiseControlWithMetrics.

public static KafkaBuilder kafkaAndCruiseControlWithMetrics(String name, int kafkaReplicas, int zookeeperReplicas) {
    Kafka kafka = getKafkaFromYaml(Constants.PATH_TO_KAFKA_CRUISE_CONTROL_METRICS_CONFIG);
    ConfigMap kafkaMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
    KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(kafkaMetricsCm);
    ConfigMap zkMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_METRICS_CONFIG, "kafka-metrics");
    KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(zkMetricsCm);
    ConfigMap ccMetricsCm = TestUtils.configMapFromYaml(Constants.PATH_TO_KAFKA_CRUISE_CONTROL_CONFIG, "cruise-control-metrics");
    KubeClusterResource.kubeClient().getClient().configMaps().inNamespace(kubeClient().getNamespace()).createOrReplace(ccMetricsCm);
    return defaultKafka(kafka, name, kafkaReplicas, zookeeperReplicas);
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Kafka(io.strimzi.api.kafka.model.Kafka)

Aggregations

Kafka (io.strimzi.api.kafka.model.Kafka)913 KafkaBuilder (io.strimzi.api.kafka.model.KafkaBuilder)703 ParallelTest (io.strimzi.test.annotations.ParallelTest)452 Reconciliation (io.strimzi.operator.common.Reconciliation)448 Test (org.junit.jupiter.api.Test)347 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)332 ResourceUtils (io.strimzi.operator.cluster.ResourceUtils)304 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)295 KafkaVersionTestUtils (io.strimzi.operator.cluster.KafkaVersionTestUtils)294 ResourceOperatorSupplier (io.strimzi.operator.cluster.operator.resource.ResourceOperatorSupplier)292 Map (java.util.Map)278 Checkpoint (io.vertx.junit5.Checkpoint)264 CoreMatchers.is (org.hamcrest.CoreMatchers.is)262 Labels (io.strimzi.operator.common.model.Labels)252 Future (io.vertx.core.Future)234 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)230 VertxTestContext (io.vertx.junit5.VertxTestContext)228 List (java.util.List)228 VertxExtension (io.vertx.junit5.VertxExtension)226 AfterAll (org.junit.jupiter.api.AfterAll)220