Search in sources :

Example 1 with ParallelNamespaceTest

use of io.strimzi.systemtest.annotations.ParallelNamespaceTest in project strimzi by strimzi.

the class KafkaST method testAppDomainLabels.

@ParallelNamespaceTest
@Tag(INTERNAL_CLIENTS_USED)
void testAppDomainLabels(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final String topicName = mapWithTestTopics.get(extensionContext.getDisplayName());
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3, 1).build());
    resourceManager.createResource(extensionContext, KafkaTopicTemplates.topic(clusterName, topicName).build());
    resourceManager.createResource(extensionContext, KafkaClientsTemplates.kafkaClients(false, clusterName + "-" + Constants.KAFKA_CLIENTS).build());
    final String kafkaClientsPodName = kubeClient(namespaceName).listPodsByPrefixInName(namespaceName, clusterName + "-" + Constants.KAFKA_CLIENTS).get(0).getMetadata().getName();
    InternalKafkaClient internalKafkaClient = new InternalKafkaClient.Builder().withUsingPodName(kafkaClientsPodName).withTopicName(topicName).withNamespaceName(namespaceName).withClusterName(clusterName).withMessageCount(MESSAGE_COUNT).withListenerName(Constants.PLAIN_LISTENER_DEFAULT_NAME).build();
    Map<String, String> labels;
    LOGGER.info("---> PODS <---");
    List<Pod> pods = kubeClient(namespaceName).listPods(namespaceName, clusterName).stream().filter(pod -> pod.getMetadata().getName().startsWith(clusterName)).filter(pod -> !pod.getMetadata().getName().startsWith(clusterName + "-" + Constants.KAFKA_CLIENTS)).collect(Collectors.toList());
    for (Pod pod : pods) {
        LOGGER.info("Getting labels from {} pod", pod.getMetadata().getName());
        verifyAppLabels(pod.getMetadata().getLabels());
    }
    LOGGER.info("---> STATEFUL SETS <---");
    Map<String, String> kafkaLabels = StUtils.getLabelsOfStatefulSetOrStrimziPodSet(namespaceName, KafkaResources.kafkaStatefulSetName(clusterName));
    LOGGER.info("Getting labels from stateful set of kafka resource");
    verifyAppLabels(kafkaLabels);
    Map<String, String> zooLabels = StUtils.getLabelsOfStatefulSetOrStrimziPodSet(namespaceName, KafkaResources.zookeeperStatefulSetName(clusterName));
    LOGGER.info("Getting labels from stateful set of zookeeper resource");
    verifyAppLabels(zooLabels);
    LOGGER.info("---> SERVICES <---");
    List<Service> services = kubeClient(namespaceName).listServices(namespaceName).stream().filter(service -> service.getMetadata().getName().startsWith(clusterName)).collect(Collectors.toList());
    for (Service service : services) {
        LOGGER.info("Getting labels from {} service", service.getMetadata().getName());
        verifyAppLabels(service.getMetadata().getLabels());
    }
    LOGGER.info("---> SECRETS <---");
    List<Secret> secrets = kubeClient(namespaceName).listSecrets(namespaceName).stream().filter(secret -> secret.getMetadata().getName().startsWith(clusterName) && secret.getType().equals("Opaque")).collect(Collectors.toList());
    for (Secret secret : secrets) {
        LOGGER.info("Getting labels from {} secret", secret.getMetadata().getName());
        verifyAppLabelsForSecretsAndConfigMaps(secret.getMetadata().getLabels());
    }
    LOGGER.info("---> CONFIG MAPS <---");
    List<ConfigMap> configMaps = kubeClient(namespaceName).listConfigMapsInSpecificNamespace(namespaceName, clusterName);
    for (ConfigMap configMap : configMaps) {
        LOGGER.info("Getting labels from {} config map", configMap.getMetadata().getName());
        verifyAppLabelsForSecretsAndConfigMaps(configMap.getMetadata().getLabels());
    }
    internalKafkaClient.checkProducedAndConsumedMessages(internalKafkaClient.sendMessagesPlain(), internalKafkaClient.receiveMessagesPlain());
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) CoreMatchers(org.hamcrest.CoreMatchers) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Matchers.not(org.hamcrest.Matchers.not) ExecResult(io.strimzi.test.executor.ExecResult) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) SecurityContextBuilder(io.fabric8.kubernetes.api.model.SecurityContextBuilder) KafkaResources.kafkaStatefulSetName(io.strimzi.api.kafka.model.KafkaResources.kafkaStatefulSetName) Matchers.hasItems(org.hamcrest.Matchers.hasItems) PersistentVolumeClaimUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PersistentVolumeClaimUtils) EntityTopicOperatorSpec(io.strimzi.api.kafka.model.EntityTopicOperatorSpec) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Arrays.asList(java.util.Arrays.asList) SystemProperty(io.strimzi.api.kafka.model.SystemProperty) Duration(java.time.Duration) Map(java.util.Map) ConfigMapUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.ConfigMapUtils) Tag(org.junit.jupiter.api.Tag) ServiceUtils(io.strimzi.systemtest.utils.kubeUtils.objects.ServiceUtils) StUtils(io.strimzi.systemtest.utils.StUtils) RollingUpdateUtils(io.strimzi.systemtest.utils.RollingUpdateUtils) JbodStorageBuilder(io.strimzi.api.kafka.model.storage.JbodStorageBuilder) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) StUtils.configMap2Properties(io.strimzi.systemtest.utils.StUtils.configMap2Properties) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Instant(java.time.Instant) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) Secret(io.fabric8.kubernetes.api.model.Secret) Optional(java.util.Optional) KafkaTopicResource(io.strimzi.systemtest.resources.crd.KafkaTopicResource) Matchers.anyOf(org.hamcrest.Matchers.anyOf) CRUISE_CONTROL(io.strimzi.systemtest.Constants.CRUISE_CONTROL) Matchers.containsString(org.hamcrest.Matchers.containsString) AbstractST(io.strimzi.systemtest.AbstractST) ZookeeperClusterSpec(io.strimzi.api.kafka.model.ZookeeperClusterSpec) GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) LOADBALANCER_SUPPORTED(io.strimzi.systemtest.Constants.LOADBALANCER_SUPPORTED) ParallelSuite(io.strimzi.systemtest.annotations.ParallelSuite) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) KafkaResources.zookeeperStatefulSetName(io.strimzi.api.kafka.model.KafkaResources.zookeeperStatefulSetName) HashMap(java.util.HashMap) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) StUtils.stringToProperties(io.strimzi.systemtest.utils.StUtils.stringToProperties) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) KafkaTopicList(io.strimzi.api.kafka.KafkaTopicList) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils(io.strimzi.test.TestUtils) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) Service(io.fabric8.kubernetes.api.model.Service) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) EntityOperatorSpec(io.strimzi.api.kafka.model.EntityOperatorSpec) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage) KafkaUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils) Properties(java.util.Properties) InternalKafkaClient(io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient) Constants(io.strimzi.systemtest.Constants) Pod(io.fabric8.kubernetes.api.model.Pod) EntityUserOperatorSpec(io.strimzi.api.kafka.model.EntityUserOperatorSpec) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) KafkaCmdClient(io.strimzi.systemtest.cli.KafkaCmdClient) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) Matchers.hasItem(org.hamcrest.Matchers.hasItem) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) SystemPropertyBuilder(io.strimzi.api.kafka.model.SystemPropertyBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) Pod(io.fabric8.kubernetes.api.model.Pod) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Service(io.fabric8.kubernetes.api.model.Service) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) Secret(io.fabric8.kubernetes.api.model.Secret) InternalKafkaClient(io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) Tag(org.junit.jupiter.api.Tag)

Example 2 with ParallelNamespaceTest

use of io.strimzi.systemtest.annotations.ParallelNamespaceTest in project strimzi by strimzi.

the class KafkaST method testEntityOperatorWithoutTopicOperator.

@ParallelNamespaceTest
void testEntityOperatorWithoutTopicOperator(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    LOGGER.info("Deploying Kafka cluster without TO in EO");
    Instant startTime = Instant.now();
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3).editSpec().withNewEntityOperator().withNewUserOperator().endUserOperator().endEntityOperator().endSpec().build());
    Instant endTime = Instant.now();
    long duration = Duration.between(startTime, endTime).toSeconds();
    assertNoCoErrorsLogged(duration);
    // Checking that TO was not deployed
    kubeClient(namespaceName).listPodsByPrefixInName(namespaceName, KafkaResources.entityOperatorDeploymentName(clusterName)).forEach(pod -> {
        pod.getSpec().getContainers().forEach(container -> {
            assertThat(container.getName(), not(containsString("topic-operator")));
        });
    });
}
Also used : Instant(java.time.Instant) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Example 3 with ParallelNamespaceTest

use of io.strimzi.systemtest.annotations.ParallelNamespaceTest in project strimzi by strimzi.

the class KafkaST method testEntityOperatorWithoutUserOperator.

@ParallelNamespaceTest
void testEntityOperatorWithoutUserOperator(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    LOGGER.info("Deploying Kafka cluster without UO in EO");
    Instant startTime = Instant.now();
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3).editSpec().withNewEntityOperator().withNewTopicOperator().endTopicOperator().endEntityOperator().endSpec().build());
    Instant endTime = Instant.now();
    long duration = Duration.between(startTime, endTime).toSeconds();
    assertNoCoErrorsLogged(duration);
    // Checking that UO was not deployed
    kubeClient(namespaceName).listPodsByPrefixInName(namespaceName, KafkaResources.entityOperatorDeploymentName(clusterName)).forEach(pod -> {
        pod.getSpec().getContainers().forEach(container -> {
            assertThat(container.getName(), not(containsString("user-operator")));
        });
    });
}
Also used : Instant(java.time.Instant) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Example 4 with ParallelNamespaceTest

use of io.strimzi.systemtest.annotations.ParallelNamespaceTest in project strimzi by strimzi.

the class KafkaST method testJvmAndResources.

@ParallelNamespaceTest
void testJvmAndResources(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
    final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
    ArrayList<SystemProperty> javaSystemProps = new ArrayList<>();
    javaSystemProps.add(new SystemPropertyBuilder().withName("javax.net.debug").withValue("verbose").build());
    Map<String, String> jvmOptionsXX = new HashMap<>();
    jvmOptionsXX.put("UseG1GC", "true");
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 1, 1).editSpec().editKafka().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("1.5Gi")).addToLimits("cpu", new Quantity("1")).addToRequests("memory", new Quantity("1Gi")).addToRequests("cpu", new Quantity("50m")).build()).withNewJvmOptions().withXmx("1g").withXms("512m").withXx(jvmOptionsXX).endJvmOptions().endKafka().editZookeeper().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("1G")).addToLimits("cpu", new Quantity("0.5")).addToRequests("memory", new Quantity("0.5G")).addToRequests("cpu", new Quantity("25m")).build()).withNewJvmOptions().withXmx("1G").withXms("512M").withXx(jvmOptionsXX).endJvmOptions().endZookeeper().withNewEntityOperator().withNewTopicOperator().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("1024Mi")).addToLimits("cpu", new Quantity("500m")).addToRequests("memory", new Quantity("384Mi")).addToRequests("cpu", new Quantity("0.025")).build()).withNewJvmOptions().withXmx("2G").withXms("1024M").withJavaSystemProperties(javaSystemProps).endJvmOptions().endTopicOperator().withNewUserOperator().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("512M")).addToLimits("cpu", new Quantity("300m")).addToRequests("memory", new Quantity("256M")).addToRequests("cpu", new Quantity("30m")).build()).withNewJvmOptions().withXmx("1G").withXms("512M").withJavaSystemProperties(javaSystemProps).endJvmOptions().endUserOperator().endEntityOperator().endSpec().build());
    // Make snapshots for Kafka cluster to meke sure that there is no rolling update after CO reconciliation
    final String zkStsName = KafkaResources.zookeeperStatefulSetName(clusterName);
    final String kafkaStsName = kafkaStatefulSetName(clusterName);
    final String eoDepName = KafkaResources.entityOperatorDeploymentName(clusterName);
    final Map<String, String> zkPods = PodUtils.podSnapshot(namespaceName, zkSelector);
    final Map<String, String> kafkaPods = PodUtils.podSnapshot(namespaceName, kafkaSelector);
    final Map<String, String> eoPods = DeploymentUtils.depSnapshot(namespaceName, eoDepName);
    assertResources(namespaceName, KafkaResources.kafkaPodName(clusterName, 0), "kafka", "1536Mi", "1", "1Gi", "50m");
    assertExpectedJavaOpts(namespaceName, KafkaResources.kafkaPodName(clusterName, 0), "kafka", "-Xmx1g", "-Xms512m", "-XX:+UseG1GC");
    assertResources(namespaceName, KafkaResources.zookeeperPodName(clusterName, 0), "zookeeper", "1G", "500m", "500M", "25m");
    assertExpectedJavaOpts(namespaceName, KafkaResources.zookeeperPodName(clusterName, 0), "zookeeper", "-Xmx1G", "-Xms512M", "-XX:+UseG1GC");
    Optional<Pod> pod = kubeClient(namespaceName).listPods(namespaceName).stream().filter(p -> p.getMetadata().getName().startsWith(KafkaResources.entityOperatorDeploymentName(clusterName))).findFirst();
    assertThat("EO pod does not exist", pod.isPresent(), is(true));
    assertResources(namespaceName, pod.get().getMetadata().getName(), "topic-operator", "1Gi", "500m", "384Mi", "25m");
    assertResources(namespaceName, pod.get().getMetadata().getName(), "user-operator", "512M", "300m", "256M", "30m");
    assertExpectedJavaOpts(namespaceName, pod.get().getMetadata().getName(), "topic-operator", "-Xmx2G", "-Xms1024M", null);
    assertExpectedJavaOpts(namespaceName, pod.get().getMetadata().getName(), "user-operator", "-Xmx1G", "-Xms512M", null);
    String eoPod = eoPods.keySet().toArray()[0].toString();
    kubeClient(namespaceName).getPod(namespaceName, eoPod).getSpec().getContainers().forEach(container -> {
        if (!container.getName().equals("tls-sidecar")) {
            LOGGER.info("Check if -D java options are present in {}", container.getName());
            String javaSystemProp = container.getEnv().stream().filter(envVar -> envVar.getName().equals("STRIMZI_JAVA_SYSTEM_PROPERTIES")).findFirst().orElseThrow().getValue();
            String javaOpts = container.getEnv().stream().filter(envVar -> envVar.getName().equals("STRIMZI_JAVA_OPTS")).findFirst().orElseThrow().getValue();
            assertThat(javaSystemProp, is("-Djavax.net.debug=verbose"));
            if (container.getName().equals("topic-operator")) {
                assertThat(javaOpts, is("-Xms1024M -Xmx2G"));
            }
            if (container.getName().equals("user-operator")) {
                assertThat(javaOpts, is("-Xms512M -Xmx1G"));
            }
        }
    });
    LOGGER.info("Checking no rolling update for Kafka cluster");
    RollingUpdateUtils.waitForNoRollingUpdate(namespaceName, zkSelector, zkPods);
    RollingUpdateUtils.waitForNoRollingUpdate(namespaceName, kafkaSelector, kafkaPods);
    DeploymentUtils.waitForNoRollingUpdate(namespaceName, eoDepName, eoPods);
}
Also used : Quantity(io.fabric8.kubernetes.api.model.Quantity) CoreMatchers.is(org.hamcrest.CoreMatchers.is) KafkaClusterSpec(io.strimzi.api.kafka.model.KafkaClusterSpec) CoreMatchers(org.hamcrest.CoreMatchers) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) KafkaResource(io.strimzi.systemtest.resources.crd.KafkaResource) KubeClusterResource.cmdKubeClient(io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient) Matchers.not(org.hamcrest.Matchers.not) ExecResult(io.strimzi.test.executor.ExecResult) KafkaTopicUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaTopicUtils) SecurityContextBuilder(io.fabric8.kubernetes.api.model.SecurityContextBuilder) KafkaResources.kafkaStatefulSetName(io.strimzi.api.kafka.model.KafkaResources.kafkaStatefulSetName) Matchers.hasItems(org.hamcrest.Matchers.hasItems) PersistentVolumeClaimUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PersistentVolumeClaimUtils) EntityTopicOperatorSpec(io.strimzi.api.kafka.model.EntityTopicOperatorSpec) KafkaResources(io.strimzi.api.kafka.model.KafkaResources) Arrays.asList(java.util.Arrays.asList) SystemProperty(io.strimzi.api.kafka.model.SystemProperty) Duration(java.time.Duration) Map(java.util.Map) ConfigMapUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.ConfigMapUtils) Tag(org.junit.jupiter.api.Tag) ServiceUtils(io.strimzi.systemtest.utils.kubeUtils.objects.ServiceUtils) StUtils(io.strimzi.systemtest.utils.StUtils) RollingUpdateUtils(io.strimzi.systemtest.utils.RollingUpdateUtils) JbodStorageBuilder(io.strimzi.api.kafka.model.storage.JbodStorageBuilder) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) StUtils.configMap2Properties(io.strimzi.systemtest.utils.StUtils.configMap2Properties) INTERNAL_CLIENTS_USED(io.strimzi.systemtest.Constants.INTERNAL_CLIENTS_USED) GenericKafkaListenerBuilder(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder) Instant(java.time.Instant) HasMetadata(io.fabric8.kubernetes.api.model.HasMetadata) Collectors(java.util.stream.Collectors) List(java.util.List) Labels(io.strimzi.operator.common.model.Labels) Logger(org.apache.logging.log4j.Logger) KafkaTopicTemplates(io.strimzi.systemtest.templates.crd.KafkaTopicTemplates) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) Secret(io.fabric8.kubernetes.api.model.Secret) Optional(java.util.Optional) KafkaTopicResource(io.strimzi.systemtest.resources.crd.KafkaTopicResource) Matchers.anyOf(org.hamcrest.Matchers.anyOf) CRUISE_CONTROL(io.strimzi.systemtest.Constants.CRUISE_CONTROL) Matchers.containsString(org.hamcrest.Matchers.containsString) AbstractST(io.strimzi.systemtest.AbstractST) ZookeeperClusterSpec(io.strimzi.api.kafka.model.ZookeeperClusterSpec) GenericKafkaListener(io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListener) KafkaClientsTemplates(io.strimzi.systemtest.templates.crd.KafkaClientsTemplates) LOADBALANCER_SUPPORTED(io.strimzi.systemtest.Constants.LOADBALANCER_SUPPORTED) ParallelSuite(io.strimzi.systemtest.annotations.ParallelSuite) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) KafkaResources.zookeeperStatefulSetName(io.strimzi.api.kafka.model.KafkaResources.zookeeperStatefulSetName) HashMap(java.util.HashMap) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) StUtils.stringToProperties(io.strimzi.systemtest.utils.StUtils.stringToProperties) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) PersistentClaimStorageBuilder(io.strimzi.api.kafka.model.storage.PersistentClaimStorageBuilder) PodUtils(io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils) KafkaTopicList(io.strimzi.api.kafka.KafkaTopicList) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils(io.strimzi.test.TestUtils) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) Service(io.fabric8.kubernetes.api.model.Service) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) EntityOperatorSpec(io.strimzi.api.kafka.model.EntityOperatorSpec) KafkaTemplates(io.strimzi.systemtest.templates.crd.KafkaTemplates) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage) KafkaUtils(io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils) Properties(java.util.Properties) InternalKafkaClient(io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient) Constants(io.strimzi.systemtest.Constants) Pod(io.fabric8.kubernetes.api.model.Pod) EntityUserOperatorSpec(io.strimzi.api.kafka.model.EntityUserOperatorSpec) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest) KafkaCmdClient(io.strimzi.systemtest.cli.KafkaCmdClient) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) KubeClusterResource.kubeClient(io.strimzi.test.k8s.KubeClusterResource.kubeClient) KafkaTopic(io.strimzi.api.kafka.model.KafkaTopic) DeploymentUtils(io.strimzi.systemtest.utils.kubeUtils.controllers.DeploymentUtils) Matchers.hasItem(org.hamcrest.Matchers.hasItem) KafkaListenerType(io.strimzi.api.kafka.model.listener.arraylistener.KafkaListenerType) KafkaUserTemplates(io.strimzi.systemtest.templates.crd.KafkaUserTemplates) SystemPropertyBuilder(io.strimzi.api.kafka.model.SystemPropertyBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) LogManager(org.apache.logging.log4j.LogManager) REGRESSION(io.strimzi.systemtest.Constants.REGRESSION) SystemPropertyBuilder(io.strimzi.api.kafka.model.SystemPropertyBuilder) Pod(io.fabric8.kubernetes.api.model.Pod) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ResourceRequirementsBuilder(io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder) ArrayList(java.util.ArrayList) LabelSelector(io.fabric8.kubernetes.api.model.LabelSelector) Quantity(io.fabric8.kubernetes.api.model.Quantity) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) SystemProperty(io.strimzi.api.kafka.model.SystemProperty) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Example 5 with ParallelNamespaceTest

use of io.strimzi.systemtest.annotations.ParallelNamespaceTest in project strimzi by strimzi.

the class KafkaST method testTopicWithoutLabels.

@ParallelNamespaceTest
void testTopicWithoutLabels(ExtensionContext extensionContext) {
    final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
    final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
    // Negative scenario: creating topic without any labels and make sure that TO can't handle this topic
    resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 3).build());
    // Creating topic without any label
    resourceManager.createResource(extensionContext, false, KafkaTopicTemplates.topic(clusterName, "topic-without-labels", 1, 1, 1).editMetadata().withLabels(null).endMetadata().build());
    // Checking that resource was created
    assertThat(cmdKubeClient(namespaceName).list("kafkatopic"), hasItems("topic-without-labels"));
    // Checking that TO didn't handle new topic and zk pods don't contain new topic
    assertThat(KafkaCmdClient.listTopicsUsingPodCli(namespaceName, clusterName, 0), not(hasItems("topic-without-labels")));
    // Checking TO logs
    String tOPodName = cmdKubeClient(namespaceName).listResourcesByLabel("pod", Labels.STRIMZI_NAME_LABEL + "=" + clusterName + "-entity-operator").get(0);
    String tOlogs = kubeClient(namespaceName).logsInSpecificNamespace(namespaceName, tOPodName, "topic-operator");
    assertThat(tOlogs, not(containsString("Created topic 'topic-without-labels'")));
    // Deleting topic
    cmdKubeClient(namespaceName).deleteByName("kafkatopic", "topic-without-labels");
    KafkaTopicUtils.waitForKafkaTopicDeletion(namespaceName, "topic-without-labels");
    // Checking all topics were deleted
    List<String> topics = KafkaCmdClient.listTopicsUsingPodCli(namespaceName, clusterName, 0);
    assertThat(topics, not(hasItems("topic-without-labels")));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.emptyOrNullString(org.hamcrest.Matchers.emptyOrNullString) TestUtils.fromYamlString(io.strimzi.test.TestUtils.fromYamlString) ParallelNamespaceTest(io.strimzi.systemtest.annotations.ParallelNamespaceTest)

Aggregations

ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)302 Tag (org.junit.jupiter.api.Tag)166 Matchers.containsString (org.hamcrest.Matchers.containsString)148 GenericKafkaListenerBuilder (io.strimzi.api.kafka.model.listener.arraylistener.GenericKafkaListenerBuilder)114 InternalKafkaClient (io.strimzi.systemtest.kafkaclients.clients.InternalKafkaClient)112 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)94 KafkaUser (io.strimzi.api.kafka.model.KafkaUser)86 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)76 SecretBuilder (io.fabric8.kubernetes.api.model.SecretBuilder)66 HashMap (java.util.HashMap)52 ResourceRequirementsBuilder (io.fabric8.kubernetes.api.model.ResourceRequirementsBuilder)50 TestUtils.fromYamlString (io.strimzi.test.TestUtils.fromYamlString)48 Matchers.emptyOrNullString (org.hamcrest.Matchers.emptyOrNullString)48 ExternalKafkaClient (io.strimzi.systemtest.kafkaclients.externalClients.ExternalKafkaClient)42 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)40 ConfigMapBuilder (io.fabric8.kubernetes.api.model.ConfigMapBuilder)40 Secret (io.fabric8.kubernetes.api.model.Secret)40 ConfigMapKeySelectorBuilder (io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder)38 KafkaListenerAuthenticationTls (io.strimzi.api.kafka.model.listener.KafkaListenerAuthenticationTls)36 Pod (io.fabric8.kubernetes.api.model.Pod)32