Search in sources :

Example 6 with CONNECT

use of io.strimzi.systemtest.Constants.CONNECT in project strimzi by strimzi.

the class MetricsIsolatedST method testKafkaConnectIoNetwork.

@ParallelTest
@Tag(CONNECT)
@Tag(CONNECT_COMPONENTS)
void testKafkaConnectIoNetwork() {
    kafkaConnectMetricsData = collector.toBuilder().withComponentType(ComponentType.KafkaConnect).build().collectMetricsFromPods();
    Pattern connectIoNetwork = Pattern.compile("kafka_connect_network_io_total\\{clientid=\".*\",} ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(connectIoNetwork, kafkaConnectMetricsData);
    assertThat("KafkaConnect IO network count doesn't match expected value", values.stream().mapToDouble(i -> i).sum() > 0);
}
Also used : ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) CoreMatchers(org.hamcrest.CoreMatchers) Arrays(java.util.Arrays) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) KafkaExporterResources(io.strimzi.api.kafka.model.KafkaExporterResources) SANITY(io.strimzi.systemtest.Constants.SANITY) CruiseControlUtils(io.strimzi.systemtest.utils.specific.CruiseControlUtils) Matchers.emptyString(org.hamcrest.Matchers.emptyString) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) GLOBAL_TIMEOUT(io.strimzi.systemtest.Constants.GLOBAL_TIMEOUT) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Matchers.not(org.hamcrest.Matchers.not) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) JsonReadFeature(com.fasterxml.jackson.core.json.JsonReadFeature) Matcher(java.util.regex.Matcher) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) ConfigMapKeySelector(io.fabric8.kubernetes.api.model.ConfigMapKeySelector) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Tag(org.junit.jupiter.api.Tag) StUtils(io.strimzi.systemtest.utils.StUtils) ScraperTemplates(io.strimzi.systemtest.templates.specific.ScraperTemplates) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) ACCEPTANCE(io.strimzi.systemtest.Constants.ACCEPTANCE) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) KafkaRebalance(io.strimzi.api.kafka.model.KafkaRebalance) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) KafkaMirrorMaker2Templates(io.strimzi.systemtest.templates.crd.KafkaMirrorMaker2Templates) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) KafkaMirrorMaker(io.strimzi.api.kafka.model.KafkaMirrorMaker) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) List(java.util.List) Exec(io.strimzi.test.executor.Exec) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) KafkaTopicResource(io.strimzi.systemtest.resources.crd.KafkaTopicResource) Pattern(java.util.regex.Pattern) CRUISE_CONTROL(io.strimzi.systemtest.Constants.CRUISE_CONTROL) AbstractST(io.strimzi.systemtest.AbstractST) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) NetworkPolicyResource(io.strimzi.systemtest.resources.kubernetes.NetworkPolicyResource) CONNECT(io.strimzi.systemtest.Constants.CONNECT) OptionalDouble(java.util.OptionalDouble) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ArrayList(java.util.ArrayList) JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) JmxPrometheusExporterMetricsBuilder(io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder) KRaftNotSupported(io.strimzi.systemtest.annotations.KRaftNotSupported) TestUtils(io.strimzi.test.TestUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MIRROR_MAKER2(io.strimzi.systemtest.Constants.MIRROR_MAKER2) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) ComponentType(io.strimzi.systemtest.resources.ComponentType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) IOException(java.io.IOException) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) IsolatedTest(io.strimzi.systemtest.annotations.IsolatedTest) ExecutionException(java.util.concurrent.ExecutionException) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) KafkaUserUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUserUtils) METRICS(io.strimzi.systemtest.Constants.METRICS) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) ConfigMapKeySelectorBuilder(io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 7 with CONNECT

use of io.strimzi.systemtest.Constants.CONNECT in project strimzi by strimzi.

the class ConnectBuilderIsolatedST method testUpdateConnectWithAnotherPlugin.

@ParallelTest
void testUpdateConnectWithAnotherPlugin(ExtensionContext extensionContext) {
    TestStorage storage = new TestStorage(extensionContext, clusterOperator.getDeploymentNamespace());
    String echoConnector = "echo-sink-connector";
    String camelConnector = "camel-http-connector";
    final String imageName = getImageNameForTestCase();
    Plugin secondPlugin = new PluginBuilder().withName("camel-connector").withArtifacts(new TgzArtifactBuilder().withUrl(CAMEL_CONNECTOR_TGZ_URL).withSha512sum(CAMEL_CONNECTOR_TGZ_CHECKSUM).build()).build();
    String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(storage.getNamespaceName(), topicName).build());
    KafkaConnect connect = KafkaConnectTemplates.kafkaConnect(storage.getClusterName(), storage.getNamespaceName(), storage.getNamespaceName(), 1).editMetadata().addToAnnotations(Annotations.STRIMZI_IO_USE_CONNECTOR_RESOURCES, "true").endMetadata().editOrNewSpec().addToConfig("key.converter.schemas.enable", false).addToConfig("value.converter.schemas.enable", false).addToConfig("key.converter", "org.apache.kafka.connect.storage.StringConverter").addToConfig("value.converter", "org.apache.kafka.connect.storage.StringConverter").withNewBuild().withPlugins(PLUGIN_WITH_TAR_AND_JAR).withNewDockerOutput().withImage(imageName).endDockerOutput().endBuild().withNewInlineLogging().addToLoggers("connect.root.logger.level", "INFO").endInlineLogging().endSpec().build();
    resourceManager.createResource(extensionContext, connect, ScraperTemplates.scraperPod(storage.getNamespaceName(), storage.getScraperName()).build());
    LOGGER.info("Deploy NetworkPolicies for KafkaConnect");
    NetworkPolicyResource.deployNetworkPolicyForResource(extensionContext, connect, KafkaConnectResources.deploymentName(storage.getClusterName()));
    Map<String, Object> echoSinkConfig = new HashMap<>();
    echoSinkConfig.put("topics", topicName);
    echoSinkConfig.put("level", "INFO");
    LOGGER.info("Creating EchoSink connector");
    resourceManager.createResource(extensionContext, KafkaConnectorTemplates.kafkaConnector(echoConnector, storage.getClusterName()).editOrNewSpec().withClassName(ECHO_SINK_CLASS_NAME).withConfig(echoSinkConfig).endSpec().build());
    String deploymentName = KafkaConnectResources.deploymentName(storage.getClusterName());
    Map<String, String> connectSnapshot = DeploymentUtils.depSnapshot(deploymentName);
    String scraperPodName = kubeClient(storage.getNamespaceName()).listPodsByPrefixInName(storage.getScraperName()).get(0).getMetadata().getName();
    LOGGER.info("Checking that KafkaConnect API contains EchoSink connector and not Camel-Telegram Connector class name");
    String plugins = cmdKubeClient().execInPod(scraperPodName, "curl", "-X", "GET", "http://" + KafkaConnectResources.serviceName(storage.getClusterName()) + ":8083/connector-plugins").out();
    assertFalse(plugins.contains(CAMEL_CONNECTOR_HTTP_SINK_CLASS_NAME));
    assertTrue(plugins.contains(ECHO_SINK_CLASS_NAME));
    LOGGER.info("Adding one more connector to the KafkaConnect");
    KafkaConnectResource.replaceKafkaConnectResource(storage.getClusterName(), kafkaConnect -> {
        kafkaConnect.getSpec().getBuild().getPlugins().add(secondPlugin);
    });
    DeploymentUtils.waitTillDepHasRolled(deploymentName, 1, connectSnapshot);
    Map<String, Object> camelHttpConfig = new HashMap<>();
    camelHttpConfig.put("camel.sink.path.httpUri", "http://" + KafkaConnectResources.serviceName(storage.getClusterName()) + ":8083");
    camelHttpConfig.put("topics", topicName);
    LOGGER.info("Creating Camel-HTTP-Sink connector");
    resourceManager.createResource(extensionContext, KafkaConnectorTemplates.kafkaConnector(camelConnector, storage.getClusterName()).editOrNewSpec().withClassName(CAMEL_CONNECTOR_HTTP_SINK_CLASS_NAME).withConfig(camelHttpConfig).endSpec().build());
    KafkaConnect kafkaConnect = KafkaConnectResource.kafkaConnectClient().inNamespace(storage.getNamespaceName()).withName(storage.getClusterName()).get();
    LOGGER.info("Checking if both Connectors were created and Connect contains both plugins");
    assertThat(kafkaConnect.getSpec().getBuild().getPlugins().size(), is(2));
    assertTrue(kafkaConnect.getStatus().getConnectorPlugins().stream().anyMatch(connectorPlugin -> connectorPlugin.getConnectorClass().contains(ECHO_SINK_CLASS_NAME)));
    assertTrue(kafkaConnect.getStatus().getConnectorPlugins().stream().anyMatch(connectorPlugin -> connectorPlugin.getConnectorClass().contains(CAMEL_CONNECTOR_HTTP_SINK_CLASS_NAME)));
}
Also used : ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) SANITY(io.strimzi.systemtest.Constants.SANITY) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Annotations(io.strimzi.operator.common.Annotations) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) KafkaConnectResource(io.strimzi.systemtest.resources.crd.KafkaConnectResource) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) OtherArtifactBuilder(io.strimzi.api.kafka.model.connect.build.OtherArtifactBuilder) KafkaConnectUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectUtils) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) ScraperTemplates(io.strimzi.systemtest.templates.specific.ScraperTemplates) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) ACCEPTANCE(io.strimzi.systemtest.Constants.ACCEPTANCE) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) Plugin(io.strimzi.api.kafka.model.connect.build.Plugin) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaConnectorTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectorTemplates) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) Condition(io.strimzi.api.kafka.model.status.Condition) AbstractST(io.strimzi.systemtest.AbstractST) Environment(io.strimzi.systemtest.Environment) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) NetworkPolicyResource(io.strimzi.systemtest.resources.kubernetes.NetworkPolicyResource) CONNECT(io.strimzi.systemtest.Constants.CONNECT) OpenShiftOnly(io.strimzi.systemtest.annotations.OpenShiftOnly) HashMap(java.util.HashMap) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ZipArtifactBuilder(io.strimzi.api.kafka.model.connect.build.ZipArtifactBuilder) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaConnectorResource(io.strimzi.systemtest.resources.crd.KafkaConnectorResource) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) NotReady(io.strimzi.systemtest.enums.CustomResourceStatus.NotReady) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) ImageStream(io.fabric8.openshift.api.model.ImageStream) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) Util(io.strimzi.operator.common.Util) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) MavenArtifactBuilder(io.strimzi.api.kafka.model.connect.build.MavenArtifactBuilder) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) HashMap(java.util.HashMap) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) Plugin(io.strimzi.api.kafka.model.connect.build.Plugin) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 8 with CONNECT

use of io.strimzi.systemtest.Constants.CONNECT in project strimzi by strimzi.

the class ConnectBuilderIsolatedST method testBuildFailsWithWrongChecksumOfArtifact.

@ParallelTest
void testBuildFailsWithWrongChecksumOfArtifact(ExtensionContext extensionContext) {
    TestStorage storage = new TestStorage(extensionContext, clusterOperator.getDeploymentNamespace());
    final String imageName = getImageNameForTestCase();
    Plugin pluginWithWrongChecksum = new PluginBuilder().withName("connector-with-wrong-checksum").withArtifacts(new JarArtifactBuilder().withUrl(ECHO_SINK_JAR_URL).withSha512sum(ECHO_SINK_JAR_WRONG_CHECKSUM).build()).build();
    resourceManager.createResource(extensionContext, ScraperTemplates.scraperPod(storage.getNamespaceName(), storage.getScraperName()).build());
    resourceManager.createResource(extensionContext, false, KafkaConnectTemplates.kafkaConnect(storage.getClusterName(), storage.getNamespaceName(), storage.getNamespaceName(), 1).editMetadata().addToAnnotations(Annotations.STRIMZI_IO_USE_CONNECTOR_RESOURCES, "true").endMetadata().editOrNewSpec().withNewBuild().withPlugins(pluginWithWrongChecksum).withNewDockerOutput().withImage(imageName).endDockerOutput().endBuild().endSpec().build());
    KafkaConnectUtils.waitForConnectNotReady(storage.getClusterName());
    KafkaConnectUtils.waitUntilKafkaConnectStatusConditionContainsMessage(storage.getClusterName(), storage.getNamespaceName(), "The Kafka Connect build failed(.*)?");
    LOGGER.info("Checking if KafkaConnect status condition contains message about build failure");
    KafkaConnect kafkaConnect = KafkaConnectResource.kafkaConnectClient().inNamespace(storage.getNamespaceName()).withName(storage.getClusterName()).get();
    LOGGER.info("Deploying network policies for KafkaConnect");
    NetworkPolicyResource.deployNetworkPolicyForResource(extensionContext, kafkaConnect, KafkaConnectResources.deploymentName(storage.getClusterName()));
    Condition connectCondition = kafkaConnect.getStatus().getConditions().stream().findFirst().orElseThrow();
    assertTrue(connectCondition.getMessage().matches("The Kafka Connect build failed(.*)?"));
    assertThat(connectCondition.getType(), is(NotReady.toString()));
    LOGGER.info("Replacing plugin's checksum with right one");
    KafkaConnectResource.replaceKafkaConnectResource(storage.getClusterName(), kC -> {
        Plugin pluginWithRightChecksum = new PluginBuilder().withName("connector-with-right-checksum").withArtifacts(new JarArtifactBuilder().withUrl(ECHO_SINK_JAR_URL).withSha512sum(ECHO_SINK_JAR_CHECKSUM).build()).build();
        kC.getSpec().getBuild().getPlugins().remove(0);
        kC.getSpec().getBuild().getPlugins().add(pluginWithRightChecksum);
    });
    KafkaConnectUtils.waitForConnectReady(storage.getClusterName());
    String scraperPodName = kubeClient(storage.getNamespaceName()).listPodsByPrefixInName(storage.getScraperName()).get(0).getMetadata().getName();
    LOGGER.info("Checking if KafkaConnect API contains EchoSink connector");
    String plugins = cmdKubeClient().execInPod(scraperPodName, "curl", "-X", "GET", "http://" + KafkaConnectResources.serviceName(storage.getClusterName()) + ":8083/connector-plugins").out();
    assertTrue(plugins.contains(ECHO_SINK_CLASS_NAME));
    LOGGER.info("Checking if KafkaConnect resource contains EchoSink connector in status");
    kafkaConnect = KafkaConnectResource.kafkaConnectClient().inNamespace(storage.getNamespaceName()).withName(storage.getClusterName()).get();
    assertTrue(kafkaConnect.getStatus().getConnectorPlugins().stream().anyMatch(connectorPlugin -> connectorPlugin.getConnectorClass().contains(ECHO_SINK_CLASS_NAME)));
}
Also used : Condition(io.strimzi.api.kafka.model.status.Condition) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) SANITY(io.strimzi.systemtest.Constants.SANITY) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Annotations(io.strimzi.operator.common.Annotations) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) KafkaConnectResource(io.strimzi.systemtest.resources.crd.KafkaConnectResource) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) OtherArtifactBuilder(io.strimzi.api.kafka.model.connect.build.OtherArtifactBuilder) KafkaConnectUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectUtils) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) ScraperTemplates(io.strimzi.systemtest.templates.specific.ScraperTemplates) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) ACCEPTANCE(io.strimzi.systemtest.Constants.ACCEPTANCE) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) Plugin(io.strimzi.api.kafka.model.connect.build.Plugin) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaConnectorTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectorTemplates) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) Condition(io.strimzi.api.kafka.model.status.Condition) AbstractST(io.strimzi.systemtest.AbstractST) Environment(io.strimzi.systemtest.Environment) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) NetworkPolicyResource(io.strimzi.systemtest.resources.kubernetes.NetworkPolicyResource) CONNECT(io.strimzi.systemtest.Constants.CONNECT) OpenShiftOnly(io.strimzi.systemtest.annotations.OpenShiftOnly) HashMap(java.util.HashMap) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ZipArtifactBuilder(io.strimzi.api.kafka.model.connect.build.ZipArtifactBuilder) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaConnectorResource(io.strimzi.systemtest.resources.crd.KafkaConnectorResource) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) NotReady(io.strimzi.systemtest.enums.CustomResourceStatus.NotReady) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) ImageStream(io.fabric8.openshift.api.model.ImageStream) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) Util(io.strimzi.operator.common.Util) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) MavenArtifactBuilder(io.strimzi.api.kafka.model.connect.build.MavenArtifactBuilder) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) Plugin(io.strimzi.api.kafka.model.connect.build.Plugin) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Example 9 with CONNECT

use of io.strimzi.systemtest.Constants.CONNECT in project strimzi-kafka-operator by strimzi.

the class MetricsIsolatedST method testKafkaConnectRequests.

@ParallelTest
@Tag(CONNECT)
@Tag(CONNECT_COMPONENTS)
void testKafkaConnectRequests() {
    kafkaConnectMetricsData = collector.toBuilder().withComponentType(ComponentType.KafkaConnect).build().collectMetricsFromPods();
    Pattern connectRequests = Pattern.compile("kafka_connect_node_request_total\\{clientid=\".*\",} ([\\d.][^\\n]+)", Pattern.CASE_INSENSITIVE);
    ArrayList<Double> values = MetricsCollector.collectSpecificMetric(connectRequests, kafkaConnectMetricsData);
    assertThat("KafkaConnect requests count doesn't match expected value", values.stream().mapToDouble(i -> i).sum() > 0);
}
Also used : ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) CoreMatchers(org.hamcrest.CoreMatchers) Arrays(java.util.Arrays) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) KafkaExporterResources(io.strimzi.api.kafka.model.KafkaExporterResources) SANITY(io.strimzi.systemtest.Constants.SANITY) CruiseControlUtils(io.strimzi.systemtest.utils.specific.CruiseControlUtils) Matchers.emptyString(org.hamcrest.Matchers.emptyString) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) GLOBAL_TIMEOUT(io.strimzi.systemtest.Constants.GLOBAL_TIMEOUT) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Matchers.not(org.hamcrest.Matchers.not) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) JsonReadFeature(com.fasterxml.jackson.core.json.JsonReadFeature) Matcher(java.util.regex.Matcher) KafkaBridge(io.strimzi.api.kafka.model.KafkaBridge) ConfigMapKeySelector(io.fabric8.kubernetes.api.model.ConfigMapKeySelector) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Matchers.nullValue(org.hamcrest.Matchers.nullValue) Tag(org.junit.jupiter.api.Tag) StUtils(io.strimzi.systemtest.utils.StUtils) ScraperTemplates(io.strimzi.systemtest.templates.specific.ScraperTemplates) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) ACCEPTANCE(io.strimzi.systemtest.Constants.ACCEPTANCE) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) KafkaRebalance(io.strimzi.api.kafka.model.KafkaRebalance) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) KafkaMirrorMaker2Templates(io.strimzi.systemtest.templates.crd.KafkaMirrorMaker2Templates) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) KafkaMirrorMaker(io.strimzi.api.kafka.model.KafkaMirrorMaker) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) KafkaMirrorMaker2(io.strimzi.api.kafka.model.KafkaMirrorMaker2) List(java.util.List) Exec(io.strimzi.test.executor.Exec) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) BRIDGE(io.strimzi.systemtest.Constants.BRIDGE) BridgeClients(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients) BridgeClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) KafkaTopicResource(io.strimzi.systemtest.resources.crd.KafkaTopicResource) Pattern(java.util.regex.Pattern) CRUISE_CONTROL(io.strimzi.systemtest.Constants.CRUISE_CONTROL) AbstractST(io.strimzi.systemtest.AbstractST) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) NetworkPolicyResource(io.strimzi.systemtest.resources.kubernetes.NetworkPolicyResource) CONNECT(io.strimzi.systemtest.Constants.CONNECT) OptionalDouble(java.util.OptionalDouble) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ArrayList(java.util.ArrayList) JmxPrometheusExporterMetrics(io.strimzi.api.kafka.model.JmxPrometheusExporterMetrics) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) JmxPrometheusExporterMetricsBuilder(io.strimzi.api.kafka.model.JmxPrometheusExporterMetricsBuilder) KRaftNotSupported(io.strimzi.systemtest.annotations.KRaftNotSupported) TestUtils(io.strimzi.test.TestUtils) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) MIRROR_MAKER2(io.strimzi.systemtest.Constants.MIRROR_MAKER2) KafkaBridgeResources(io.strimzi.api.kafka.model.KafkaBridgeResources) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) ComponentType(io.strimzi.systemtest.resources.ComponentType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) IOException(java.io.IOException) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) IsolatedTest(io.strimzi.systemtest.annotations.IsolatedTest) ExecutionException(java.util.concurrent.ExecutionException) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) ResourceManager(io.strimzi.systemtest.resources.ResourceManager) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) KafkaUserUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUserUtils) METRICS(io.strimzi.systemtest.Constants.METRICS) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) ConfigMapKeySelectorBuilder(io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) KafkaBridgeTemplates(io.strimzi.systemtest.templates.crd.KafkaBridgeTemplates) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) Pattern(java.util.regex.Pattern) OptionalDouble(java.util.OptionalDouble) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) Tag(org.junit.jupiter.api.Tag)

Example 10 with CONNECT

use of io.strimzi.systemtest.Constants.CONNECT in project strimzi-kafka-operator by strimzi.

the class ConnectBuilderIsolatedST method testUpdateConnectWithAnotherPlugin.

@ParallelTest
void testUpdateConnectWithAnotherPlugin(ExtensionContext extensionContext) {
    TestStorage storage = new TestStorage(extensionContext, clusterOperator.getDeploymentNamespace());
    String echoConnector = "echo-sink-connector";
    String camelConnector = "camel-http-connector";
    final String imageName = getImageNameForTestCase();
    Plugin secondPlugin = new PluginBuilder().withName("camel-connector").withArtifacts(new TgzArtifactBuilder().withUrl(CAMEL_CONNECTOR_TGZ_URL).withSha512sum(CAMEL_CONNECTOR_TGZ_CHECKSUM).build()).build();
    String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(storage.getNamespaceName(), topicName).build());
    KafkaConnect connect = KafkaConnectTemplates.kafkaConnect(storage.getClusterName(), storage.getNamespaceName(), storage.getNamespaceName(), 1).editMetadata().addToAnnotations(Annotations.STRIMZI_IO_USE_CONNECTOR_RESOURCES, "true").endMetadata().editOrNewSpec().addToConfig("key.converter.schemas.enable", false).addToConfig("value.converter.schemas.enable", false).addToConfig("key.converter", "org.apache.kafka.connect.storage.StringConverter").addToConfig("value.converter", "org.apache.kafka.connect.storage.StringConverter").withNewBuild().withPlugins(PLUGIN_WITH_TAR_AND_JAR).withNewDockerOutput().withImage(imageName).endDockerOutput().endBuild().withNewInlineLogging().addToLoggers("connect.root.logger.level", "INFO").endInlineLogging().endSpec().build();
    resourceManager.createResource(extensionContext, connect, ScraperTemplates.scraperPod(storage.getNamespaceName(), storage.getScraperName()).build());
    LOGGER.info("Deploy NetworkPolicies for KafkaConnect");
    NetworkPolicyResource.deployNetworkPolicyForResource(extensionContext, connect, KafkaConnectResources.deploymentName(storage.getClusterName()));
    Map<String, Object> echoSinkConfig = new HashMap<>();
    echoSinkConfig.put("topics", topicName);
    echoSinkConfig.put("level", "INFO");
    LOGGER.info("Creating EchoSink connector");
    resourceManager.createResource(extensionContext, KafkaConnectorTemplates.kafkaConnector(echoConnector, storage.getClusterName()).editOrNewSpec().withClassName(ECHO_SINK_CLASS_NAME).withConfig(echoSinkConfig).endSpec().build());
    String deploymentName = KafkaConnectResources.deploymentName(storage.getClusterName());
    Map<String, String> connectSnapshot = DeploymentUtils.depSnapshot(deploymentName);
    String scraperPodName = kubeClient(storage.getNamespaceName()).listPodsByPrefixInName(storage.getScraperName()).get(0).getMetadata().getName();
    LOGGER.info("Checking that KafkaConnect API contains EchoSink connector and not Camel-Telegram Connector class name");
    String plugins = cmdKubeClient().execInPod(scraperPodName, "curl", "-X", "GET", "http://" + KafkaConnectResources.serviceName(storage.getClusterName()) + ":8083/connector-plugins").out();
    assertFalse(plugins.contains(CAMEL_CONNECTOR_HTTP_SINK_CLASS_NAME));
    assertTrue(plugins.contains(ECHO_SINK_CLASS_NAME));
    LOGGER.info("Adding one more connector to the KafkaConnect");
    KafkaConnectResource.replaceKafkaConnectResource(storage.getClusterName(), kafkaConnect -> {
        kafkaConnect.getSpec().getBuild().getPlugins().add(secondPlugin);
    });
    DeploymentUtils.waitTillDepHasRolled(deploymentName, 1, connectSnapshot);
    Map<String, Object> camelHttpConfig = new HashMap<>();
    camelHttpConfig.put("camel.sink.path.httpUri", "http://" + KafkaConnectResources.serviceName(storage.getClusterName()) + ":8083");
    camelHttpConfig.put("topics", topicName);
    LOGGER.info("Creating Camel-HTTP-Sink connector");
    resourceManager.createResource(extensionContext, KafkaConnectorTemplates.kafkaConnector(camelConnector, storage.getClusterName()).editOrNewSpec().withClassName(CAMEL_CONNECTOR_HTTP_SINK_CLASS_NAME).withConfig(camelHttpConfig).endSpec().build());
    KafkaConnect kafkaConnect = KafkaConnectResource.kafkaConnectClient().inNamespace(storage.getNamespaceName()).withName(storage.getClusterName()).get();
    LOGGER.info("Checking if both Connectors were created and Connect contains both plugins");
    assertThat(kafkaConnect.getSpec().getBuild().getPlugins().size(), is(2));
    assertTrue(kafkaConnect.getStatus().getConnectorPlugins().stream().anyMatch(connectorPlugin -> connectorPlugin.getConnectorClass().contains(ECHO_SINK_CLASS_NAME)));
    assertTrue(kafkaConnect.getStatus().getConnectorPlugins().stream().anyMatch(connectorPlugin -> connectorPlugin.getConnectorClass().contains(CAMEL_CONNECTOR_HTTP_SINK_CLASS_NAME)));
}
Also used : ParallelTest(io.strimzi.systemtest.annotations.ParallelTest) SANITY(io.strimzi.systemtest.Constants.SANITY) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) Annotations(io.strimzi.operator.common.Annotations) Random(java.util.Random) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) KafkaConnectResource(io.strimzi.systemtest.resources.crd.KafkaConnectResource) KafkaConnector(io.strimzi.api.kafka.model.KafkaConnector) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) OtherArtifactBuilder(io.strimzi.api.kafka.model.connect.build.OtherArtifactBuilder) KafkaConnectUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaConnectUtils) BeforeAll(org.junit.jupiter.api.BeforeAll) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) ScraperTemplates(io.strimzi.systemtest.templates.specific.ScraperTemplates) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) ACCEPTANCE(io.strimzi.systemtest.Constants.ACCEPTANCE) IsolatedSuite(io.strimzi.systemtest.annotations.IsolatedSuite) KafkaClients(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients) Collectors(java.util.stream.Collectors) ClientUtils(io.strimzi.systemtest.utils.ClientUtils) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) Plugin(io.strimzi.api.kafka.model.connect.build.Plugin) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) KafkaConnectorTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectorTemplates) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Matchers.is(org.hamcrest.Matchers.is) Condition(io.strimzi.api.kafka.model.status.Condition) AbstractST(io.strimzi.systemtest.AbstractST) Environment(io.strimzi.systemtest.Environment) KafkaConnectTemplates(io.strimzi.systemtest.templates.crd.KafkaConnectTemplates) NetworkPolicyResource(io.strimzi.systemtest.resources.kubernetes.NetworkPolicyResource) CONNECT(io.strimzi.systemtest.Constants.CONNECT) OpenShiftOnly(io.strimzi.systemtest.annotations.OpenShiftOnly) HashMap(java.util.HashMap) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) ZipArtifactBuilder(io.strimzi.api.kafka.model.connect.build.ZipArtifactBuilder) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaConnectorResource(io.strimzi.systemtest.resources.crd.KafkaConnectorResource) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) NotReady(io.strimzi.systemtest.enums.CustomResourceStatus.NotReady) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) ImageStream(io.fabric8.openshift.api.model.ImageStream) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) Ready(io.strimzi.systemtest.enums.CustomResourceStatus.Ready) Constants(io.strimzi.systemtest.Constants) KafkaClientsBuilder(io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) JarArtifactBuilder(io.strimzi.api.kafka.model.connect.build.JarArtifactBuilder) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) Util(io.strimzi.operator.common.Util) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) CONNECT_COMPONENTS(io.strimzi.systemtest.Constants.CONNECT_COMPONENTS) ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) MavenArtifactBuilder(io.strimzi.api.kafka.model.connect.build.MavenArtifactBuilder) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) KafkaConnectResources(io.strimzi.api.kafka.model.KafkaConnectResources) HashMap(java.util.HashMap) TestStorage(io.strimzi.systemtest.storage.TestStorage) KafkaConnect(io.strimzi.api.kafka.model.KafkaConnect) TgzArtifactBuilder(io.strimzi.api.kafka.model.connect.build.TgzArtifactBuilder) PluginBuilder(io.strimzi.api.kafka.model.connect.build.PluginBuilder) Plugin(io.strimzi.api.kafka.model.connect.build.Plugin) ParallelTest(io.strimzi.systemtest.annotations.ParallelTest)

Aggregations

KafkaConnect (io.strimzi.api.kafka.model.KafkaConnect)10 KafkaConnector (io.strimzi.api.kafka.model.KafkaConnector)10 KafkaResources (io.strimzi.api.kafka.model.KafkaResources)10 AbstractST (io.strimzi.systemtest.AbstractST)10 Constants (io.strimzi.systemtest.Constants)10 ACCEPTANCE (io.strimzi.systemtest.Constants.ACCEPTANCE)10 CONNECT (io.strimzi.systemtest.Constants.CONNECT)10 CONNECT_COMPONENTS (io.strimzi.systemtest.Constants.CONNECT_COMPONENTS)10 REGRESSION (io.strimzi.systemtest.Constants.REGRESSION)10 SANITY (io.strimzi.systemtest.Constants.SANITY)10 IsolatedSuite (io.strimzi.systemtest.annotations.IsolatedSuite)10 ParallelTest (io.strimzi.systemtest.annotations.ParallelTest)10 KafkaClients (io.strimzi.systemtest.kafkaclients.internalClients.KafkaClients)10 KafkaClientsBuilder (io.strimzi.systemtest.kafkaclients.internalClients.KafkaClientsBuilder)10 NetworkPolicyResource (io.strimzi.systemtest.resources.kubernetes.NetworkPolicyResource)10 KafkaConnectTemplates (io.strimzi.systemtest.templates.crd.KafkaConnectTemplates)10 KafkaTemplates (io.strimzi.systemtest.templates.crd.KafkaTemplates)10 KafkaTopicTemplates (io.strimzi.systemtest.templates.crd.KafkaTopicTemplates)10 ScraperTemplates (io.strimzi.systemtest.templates.specific.ScraperTemplates)10 ClientUtils (io.strimzi.systemtest.utils.ClientUtils)10