Skip to content

Commit 999f1bd

Browse files
committed
merge
Signed-off-by: wind57 <[email protected]>
2 parents 2c4e4d5 + 379846c commit 999f1bd

File tree

2 files changed

+9
-124
lines changed

2 files changed

+9
-124
lines changed

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledConfigMapContextToSourceDataProviderNamespacedBatchReadTests.java

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -377,49 +377,6 @@ void searchWithLabelsOneConfigMapFound() {
377377

378378
}
379379

380-
/**
381-
* two configmaps are deployed: "color-configmap" with label: "{color:blue}" and
382-
* "color-configmap-k8s" with label: "{color:red}". We search by "{color:blue}" and
383-
* find one configmap. Since profiles are enabled, we will also be reading
384-
* "color-configmap-k8s", even if its labels do not match provided ones.
385-
*/
386-
@Test
387-
void searchWithLabelsOneConfigMapFoundAndOneFromProfileFound() {
388-
ConfigMap colorConfigmap = new ConfigMapBuilder().withNewMetadata()
389-
.withName("color-configmap")
390-
.withLabels(Collections.singletonMap("color", "blue"))
391-
.endMetadata()
392-
.addToData("one", "1")
393-
.build();
394-
395-
ConfigMap colorConfigmapK8s = new ConfigMapBuilder().withNewMetadata()
396-
.withName("color-configmap-k8s")
397-
.withLabels(Collections.singletonMap("color", "red"))
398-
.endMetadata()
399-
.addToData("two", "2")
400-
.build();
401-
402-
mockClient.configMaps().inNamespace(NAMESPACE).resource(colorConfigmap).create();
403-
mockClient.configMaps().inNamespace(NAMESPACE).resource(colorConfigmapK8s).create();
404-
MockEnvironment environment = new MockEnvironment();
405-
environment.setActiveProfiles("k8s");
406-
407-
NormalizedSource normalizedSource = new LabeledConfigMapNormalizedSource(NAMESPACE,
408-
Collections.singletonMap("color", "blue"), true, ConfigUtils.Prefix.DELAYED, true);
409-
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, normalizedSource, NAMESPACE, environment,
410-
true);
411-
412-
Fabric8ContextToSourceData data = new LabeledConfigMapContextToSourceDataProvider().get();
413-
SourceData sourceData = data.apply(context);
414-
415-
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(2);
416-
Assertions.assertThat(sourceData.sourceData().get("color-configmap.color-configmap-k8s.one")).isEqualTo("1");
417-
Assertions.assertThat(sourceData.sourceData().get("color-configmap.color-configmap-k8s.two")).isEqualTo("2");
418-
Assertions.assertThat(sourceData.sourceName())
419-
.isEqualTo("configmap.color-configmap.color-configmap-k8s.default");
420-
421-
}
422-
423380
/**
424381
* <pre>
425382
* - configmap "color-configmap" with label "{color:blue}"
@@ -482,26 +439,10 @@ void searchWithLabelsTwoConfigMapsFound() {
482439
Fabric8ContextToSourceData data = new LabeledConfigMapContextToSourceDataProvider().get();
483440
SourceData sourceData = data.apply(context);
484441

485-
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(4);
486-
Assertions
487-
.assertThat(sourceData.sourceData()
488-
.get("color-configmap.color-configmap-k8s.shape-configmap.shape-configmap-k8s.one"))
489-
.isEqualTo("1");
490-
Assertions
491-
.assertThat(sourceData.sourceData()
492-
.get("color-configmap.color-configmap-k8s.shape-configmap.shape-configmap-k8s.two"))
493-
.isEqualTo("2");
494-
Assertions
495-
.assertThat(sourceData.sourceData()
496-
.get("color-configmap.color-configmap-k8s.shape-configmap.shape-configmap-k8s.four"))
497-
.isEqualTo("4");
498-
Assertions
499-
.assertThat(sourceData.sourceData()
500-
.get("color-configmap.color-configmap-k8s.shape-configmap.shape-configmap-k8s.five"))
501-
.isEqualTo("5");
502-
503-
Assertions.assertThat(sourceData.sourceName())
504-
.isEqualTo("configmap.color-configmap.color-configmap-k8s.shape-configmap.shape-configmap-k8s.default");
442+
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(2);
443+
Assertions.assertThat(sourceData.sourceData().get("color-configmap.shape-configmap.one")).isEqualTo("1");
444+
Assertions.assertThat(sourceData.sourceData().get("color-configmap.shape-configmap.two")).isEqualTo("2");
445+
Assertions.assertThat(sourceData.sourceName()).isEqualTo("configmap.color-configmap.shape-configmap.default");
505446

506447
}
507448

@@ -544,7 +485,6 @@ void cache(CapturedOutput output) {
544485
Assertions.assertThat(redSourceData.sourceData().size()).isEqualTo(1);
545486
Assertions.assertThat(redSourceData.sourceData().get("red-configmap.one")).isEqualTo("1");
546487
Assertions.assertThat(output.getAll()).contains("Loaded all config maps in namespace '" + NAMESPACE + "'");
547-
Assertions.assertThat(output.getAll()).contains("Will read individual configmaps in namespace");
548488

549489
NormalizedSource greenNormalizedSource = new LabeledConfigMapNormalizedSource(NAMESPACE,
550490
Collections.singletonMap("color", "green"), true, ConfigUtils.Prefix.DELAYED, true);

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledSecretContextToSourceDataProviderNamespacedBatchReadTests.java

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -378,49 +378,7 @@ void searchWithLabelsOneSecretFound() {
378378
}
379379

380380
/**
381-
* two secrets are deployed: secret "color-secret" with label: "{color:blue}" and
382-
* "color-secret-k8s" with label: "{color:red}". We search by "{color:blue}" and find
383-
* one secret. Since profiles are enabled, we will also be reading "color-secret-k8s",
384-
* even if its labels do not match provided ones.
385-
*/
386-
@Test
387-
void searchWithLabelsOneSecretFoundAndOneFromProfileFound() {
388-
Secret colorSecret = new SecretBuilder().withNewMetadata()
389-
.withName("color-secret")
390-
.withLabels(Collections.singletonMap("color", "blue"))
391-
.endMetadata()
392-
.addToData("one", Base64.getEncoder().encodeToString("1".getBytes()))
393-
.build();
394-
395-
Secret colorSecretK8s = new SecretBuilder().withNewMetadata()
396-
.withName("color-secret-k8s")
397-
.withLabels(Collections.singletonMap("color", "red"))
398-
.endMetadata()
399-
.addToData("two", Base64.getEncoder().encodeToString("2".getBytes()))
400-
.build();
401-
402-
mockClient.secrets().inNamespace(NAMESPACE).resource(colorSecret).create();
403-
mockClient.secrets().inNamespace(NAMESPACE).resource(colorSecretK8s).create();
404-
MockEnvironment environment = new MockEnvironment();
405-
environment.setActiveProfiles("k8s");
406-
407-
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE,
408-
Collections.singletonMap("color", "blue"), true, ConfigUtils.Prefix.DELAYED);
409-
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, normalizedSource, NAMESPACE, environment,
410-
true);
411-
412-
Fabric8ContextToSourceData data = new LabeledSecretContextToSourceDataProvider().get();
413-
SourceData sourceData = data.apply(context);
414-
415-
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(2);
416-
Assertions.assertThat(sourceData.sourceData().get("color-secret.color-secret-k8s.one")).isEqualTo("1");
417-
Assertions.assertThat(sourceData.sourceData().get("color-secret.color-secret-k8s.two")).isEqualTo("2");
418-
Assertions.assertThat(sourceData.sourceName()).isEqualTo("secret.color-secret.color-secret-k8s.default");
419-
420-
}
421-
422-
/**
423-
* >>>>>>> main <pre>
381+
* <pre>
424382
* - secret "color-secret" with label "{color:blue}"
425383
* - secret "shape-secret" with labels "{color:blue, shape:round}"
426384
* - secret "no-fit" with labels "{tag:no-fit}"
@@ -481,22 +439,10 @@ void searchWithLabelsTwoSecretsFound() {
481439
Fabric8ContextToSourceData data = new LabeledSecretContextToSourceDataProvider().get();
482440
SourceData sourceData = data.apply(context);
483441

484-
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(4);
485-
Assertions
486-
.assertThat(sourceData.sourceData().get("color-secret.color-secret-k8s.shape-secret.shape-secret-k8s.one"))
487-
.isEqualTo("1");
488-
Assertions
489-
.assertThat(sourceData.sourceData().get("color-secret.color-secret-k8s.shape-secret.shape-secret-k8s.two"))
490-
.isEqualTo("2");
491-
Assertions
492-
.assertThat(sourceData.sourceData().get("color-secret.color-secret-k8s.shape-secret.shape-secret-k8s.four"))
493-
.isEqualTo("4");
494-
Assertions
495-
.assertThat(sourceData.sourceData().get("color-secret.color-secret-k8s.shape-secret.shape-secret-k8s.five"))
496-
.isEqualTo("5");
497-
498-
Assertions.assertThat(sourceData.sourceName())
499-
.isEqualTo("secret.color-secret.color-secret-k8s.shape-secret.shape-secret-k8s.default");
442+
Assertions.assertThat(sourceData.sourceData().size()).isEqualTo(2);
443+
Assertions.assertThat(sourceData.sourceData().get("color-secret.shape-secret.one")).isEqualTo("1");
444+
Assertions.assertThat(sourceData.sourceData().get("color-secret.shape-secret.two")).isEqualTo("2");
445+
Assertions.assertThat(sourceData.sourceName()).isEqualTo("secret.color-secret.shape-secret.default");
500446

501447
}
502448

@@ -566,7 +512,6 @@ void cache(CapturedOutput output) {
566512
Assertions.assertThat(redSourceData.sourceData().size()).isEqualTo(1);
567513
Assertions.assertThat(redSourceData.sourceData().get("red.one")).isEqualTo("1");
568514
Assertions.assertThat(output.getAll()).contains("Loaded all secrets in namespace '" + NAMESPACE + "'");
569-
Assertions.assertThat(output.getAll()).contains("Will read individual secrets in namespace");
570515

571516
NormalizedSource greenNormalizedSource = new LabeledSecretNormalizedSource(NAMESPACE,
572517
Collections.singletonMap("color", "green"), true, ConfigUtils.Prefix.DELAYED);

0 commit comments

Comments
 (0)