Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ST: Fix test which checks labels for cluster CMs #3524

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ void testAppDomainLabels() {

LOGGER.info("---> CONFIG MAPS <---");

List<ConfigMap> configMaps = kubeClient().listConfigMaps();
List<ConfigMap> configMaps = kubeClient().listConfigMaps(CLUSTER_NAME);

for (ConfigMap configMap : configMaps) {
LOGGER.info("Getting labels from {} config map", configMap.getMetadata().getName());
Expand Down Expand Up @@ -1953,15 +1953,15 @@ void verifyNullLabels(String[] labelKeys, HasMetadata resources) {

void verifyAppLabels(Map<String, String> 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<String, String> 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
Expand Down
6 changes: 6 additions & 0 deletions test/src/main/java/io/strimzi/test/k8s/KubeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ public List<ConfigMap> listConfigMaps() {
return client.configMaps().inNamespace(getNamespace()).list().getItems();
}

public List<ConfigMap> 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);
Expand Down