From 7df0dbb562bcc32afee7eb4c864be50def601f4c Mon Sep 17 00:00:00 2001 From: Jakub Stejskal Date: Tue, 18 Aug 2020 14:33:12 +0200 Subject: [PATCH] Fix test which checks labels for cluster CMs Signed-off-by: Jakub Stejskal --- .../java/io/strimzi/systemtest/kafka/KafkaST.java | 12 ++++++------ .../main/java/io/strimzi/test/k8s/KubeClient.java | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/systemtest/src/test/java/io/strimzi/systemtest/kafka/KafkaST.java b/systemtest/src/test/java/io/strimzi/systemtest/kafka/KafkaST.java index 1a69536fa7c..f439111ca4a 100644 --- a/systemtest/src/test/java/io/strimzi/systemtest/kafka/KafkaST.java +++ b/systemtest/src/test/java/io/strimzi/systemtest/kafka/KafkaST.java @@ -1230,7 +1230,7 @@ void testAppDomainLabels() { LOGGER.info("---> CONFIG MAPS <---"); - List configMaps = kubeClient().listConfigMaps(); + List configMaps = kubeClient().listConfigMaps(CLUSTER_NAME); for (ConfigMap configMap : configMaps) { LOGGER.info("Getting labels from {} config map", configMap.getMetadata().getName()); @@ -1953,15 +1953,15 @@ void verifyNullLabels(String[] labelKeys, HasMetadata resources) { void verifyAppLabels(Map labels) { LOGGER.info("Verifying labels {}", labels); - assertThat("Label " + Labels.STRIMZI_CLUSTER_LABEL + " is present", labels.containsKey(Labels.STRIMZI_CLUSTER_LABEL)); - assertThat("Label " + Labels.STRIMZI_KIND_LABEL + " is present", labels.containsKey(Labels.STRIMZI_KIND_LABEL)); - assertThat("Label " + Labels.STRIMZI_NAME_LABEL + " is present", labels.containsKey(Labels.STRIMZI_NAME_LABEL)); + assertThat("Label " + Labels.STRIMZI_CLUSTER_LABEL + " is not present", labels.containsKey(Labels.STRIMZI_CLUSTER_LABEL)); + assertThat("Label " + Labels.STRIMZI_KIND_LABEL + " is not present", labels.containsKey(Labels.STRIMZI_KIND_LABEL)); + assertThat("Label " + Labels.STRIMZI_NAME_LABEL + " is not present", labels.containsKey(Labels.STRIMZI_NAME_LABEL)); } void verifyAppLabelsForSecretsAndConfigMaps(Map labels) { LOGGER.info("Verifying labels {}", labels); - assertThat("Label " + Labels.STRIMZI_CLUSTER_LABEL + " is present", labels.containsKey(Labels.STRIMZI_CLUSTER_LABEL)); - assertThat("Label " + Labels.STRIMZI_KIND_LABEL + " is present", labels.containsKey(Labels.STRIMZI_KIND_LABEL)); + assertThat("Label " + Labels.STRIMZI_CLUSTER_LABEL + " is not present", labels.containsKey(Labels.STRIMZI_CLUSTER_LABEL)); + assertThat("Label " + Labels.STRIMZI_KIND_LABEL + " is not present", labels.containsKey(Labels.STRIMZI_KIND_LABEL)); } @BeforeAll diff --git a/test/src/main/java/io/strimzi/test/k8s/KubeClient.java b/test/src/main/java/io/strimzi/test/k8s/KubeClient.java index b95e351312c..15b5cf9e581 100644 --- a/test/src/main/java/io/strimzi/test/k8s/KubeClient.java +++ b/test/src/main/java/io/strimzi/test/k8s/KubeClient.java @@ -124,6 +124,12 @@ public List listConfigMaps() { return client.configMaps().inNamespace(getNamespace()).list().getItems(); } + public List listConfigMaps(String namePrefix) { + return listConfigMaps().stream() + .filter(cm -> cm.getMetadata().getName().startsWith(namePrefix)) + .collect(Collectors.toList()); + } + public String execInPod(String podName, String container, String... command) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); LOGGER.info("Running command on pod {}: {}", podName, command);