From 032014e7b841bb3346f2a9a097fe9bd5983a30e9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sat, 4 Dec 2021 07:59:07 -0800 Subject: [PATCH 001/100] test --- delme.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 delme.sh diff --git a/delme.sh b/delme.sh new file mode 100644 index 0000000000..707d90cb73 --- /dev/null +++ b/delme.sh @@ -0,0 +1 @@ +dadsa \ No newline at end of file From 10889fd1fc9c5ec3a32699d70d4a0e914aae7577 Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 16 Dec 2021 04:15:40 -0800 Subject: [PATCH 002/100] fix @Nested tests not running --- .circleci/config.yml | 2 +- pom.xml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f197c14d8..7eed9f3449 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -44,7 +44,7 @@ jobs: echo $CLASSNAMES TEST_ARG=$(echo $CLASSNAMES | sed 's/ /,/g') echo $TEST_ARG - ./mvnw -s .settings.xml -DfailIfNoTests=false -Dtest=$TEST_ARG -e clean org.jacoco:jacoco-maven-plugin:prepare-agent test -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + ./mvnw -s .settings.xml -DfailIfNoTests=false -DtestsToRun=$TEST_ARG -e clean org.jacoco:jacoco-maven-plugin:prepare-agent test -U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn mkdir -p $HOME/artifacts/junit/ find . -type f -regex ".*/spring-cloud-*.*/target/*.*" -exec cp {} $HOME/artifacts/ \; find . -type f -regex ".*/target/.*-reports/.*" -exec cp {} $HOME/artifacts/junit/ \; diff --git a/pom.xml b/pom.xml index 191dae7c2d..e25caca33c 100644 --- a/pom.xml +++ b/pom.xml @@ -204,6 +204,11 @@ all false + + + + ${testsToRun} + @@ -356,6 +361,11 @@ all false + + + + ${testsToRun} + ${surefireArgLine} From b041c00ea5cac0bb3e7bd43bc75ee470920cc3fe Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 13 Jan 2022 15:33:08 +0200 Subject: [PATCH 003/100] trigger again From a34ac473971fca316b05a0b886de000f05220b1e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 08:43:39 +0000 Subject: [PATCH 004/100] Add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000000..7bd954555f --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} From 618f25aeccb763010ba7777653994148514c8d99 Mon Sep 17 00:00:00 2001 From: erabii Date: Tue, 14 Mar 2023 10:39:50 +0200 Subject: [PATCH 005/100] Delete renovate.json --- renovate.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 renovate.json diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 7bd954555f..0000000000 --- a/renovate.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base" - ] -} From 100a9cd110d5c5e614573d8c3726b21788c1b550 Mon Sep 17 00:00:00 2001 From: erabii Date: Tue, 14 Mar 2023 10:40:02 +0200 Subject: [PATCH 006/100] Delete delme.sh --- delme.sh | 1 - 1 file changed, 1 deletion(-) delete mode 100644 delme.sh diff --git a/delme.sh b/delme.sh deleted file mode 100644 index 707d90cb73..0000000000 --- a/delme.sh +++ /dev/null @@ -1 +0,0 @@ -dadsa \ No newline at end of file From 67629e6f6ad4907c87e8ced1bd2be59dd11098c4 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 2 May 2023 20:49:06 +0300 Subject: [PATCH 007/100] fix --- docs/src/main/asciidoc/property-source-config.adoc | 2 +- .../commons/config/ConfigMapPropertySourceLocator.java | 1 + .../kubernetes/commons/config/SecretsPropertySourceLocator.java | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/src/main/asciidoc/property-source-config.adoc b/docs/src/main/asciidoc/property-source-config.adoc index 31daabbe1a..5c5d459079 100644 --- a/docs/src/main/asciidoc/property-source-config.adoc +++ b/docs/src/main/asciidoc/property-source-config.adoc @@ -580,7 +580,7 @@ NOTE: You should check the security configuration section. To access config maps Kubernetes service accounts, roles and role bindings. Another option for using `ConfigMap` instances is to mount them into the Pod by running the Spring Cloud Kubernetes application -and having Spring Cloud Kubernetes read them from the file system. +and having Spring Cloud Kubernetes read them from the file system. Please note that this feature is deprecated and will be removed in a future release (Use `spring.config.import` instead). This behavior is controlled by the `spring.cloud.kubernetes.config.paths` property. You can use it in addition to or instead of the mechanism described earlier. `spring.cloud.kubernetes.config.paths` expects a List of full paths to each property file, because directories are not being recursively parsed. For example: diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java index 1bfcf39e06..3c23784fb0 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java @@ -99,6 +99,7 @@ public Collection> locateCollection(Environment environment) { private void addPropertySourcesFromPaths(Environment environment, CompositePropertySource composite) { Set uniquePaths = new LinkedHashSet<>(properties.paths()); + LOG.warn("path support is deprecated and will be removed in a future release. Please use spring.config.import"); LOG.debug("paths property sources : " + uniquePaths); uniquePaths.stream().map(Paths::get).filter(p -> { boolean exists = Files.exists(p); diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java index 4f2664c668..235cacb957 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java @@ -112,6 +112,8 @@ protected abstract SecretsPropertySource getPropertySource(ConfigurableEnvironme protected void putPathConfig(CompositePropertySource composite) { + LOG.warn("path support is deprecated and will be removed in a future release. Please use spring.config.import"); + this.properties.paths().stream().map(Paths::get).filter(Files::exists).flatMap(x -> { try { return Files.walk(x); From 42ba919521317f591814257dbce22bba2c2ae9fd Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 2 May 2023 22:00:25 +0300 Subject: [PATCH 008/100] starte --- ...ntConfigMapPropertySourceLocatorTests.java | 24 ++-- ...ientSecretsPropertySourceLocatorTests.java | 18 +-- .../config/ConfigMapConfigProperties.java | 7 +- .../ConfigMapPropertySourceLocator.java | 63 +-------- .../config/MountConfigMapPropertySource.java | 32 ----- .../config/SecretsConfigProperties.java | 5 +- .../config/SecretsPropertySourceLocator.java | 90 +------------ .../config/reload/ConfigReloadUtil.java | 11 +- ...ConfigMapConfigPropertiesBindingTests.java | 43 +++--- .../ConfigMapConfigPropertiesTests.java | 30 ++--- ...rnetesConfigDataLocationResolverTests.java | 13 +- .../SecretsConfigPropertiesBindingTests.java | 6 - .../config/SecretsConfigPropertiesTests.java | 26 ++-- .../config/reload/ConfigReloadUtilTests.java | 11 +- ...BootstrapConfigMapsFromFilePathsTests.java | 47 ------- .../config/BootstrapConfigMapsMixedTests.java | 5 +- ...onfigDataConfigMapsFromFilePathsTests.java | 47 ------- .../ConfigDataConfigMapsMixedTests.java | 5 +- .../fabric8/config/ConfigMapTestUtil.java | 7 - .../config/ConfigMapsFromFilePathsTests.java | 122 ------------------ .../fabric8/config/ConfigMapsMixedTests.java | 38 ------ ...nfigMapPropertySourceLocatorMockTests.java | 4 +- ...c8ConfigMapPropertySourceLocatorTests.java | 8 +- ...ric8SecretsPropertySourceLocatorTests.java | 8 +- ...ConfigFailFastEnabledButRetryDisabled.java | 2 +- 25 files changed, 99 insertions(+), 573 deletions(-) delete mode 100644 spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MountConfigMapPropertySource.java delete mode 100644 spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsFromFilePathsTests.java delete mode 100644 spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsFromFilePathsTests.java delete mode 100644 spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsFromFilePathsTests.java diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java index 0ec6e336a3..76fae181cf 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java @@ -97,8 +97,8 @@ void locateWithoutSources() { CoreV1Api api = new CoreV1Api(); stubFor(get("/api/v1/namespaces/default/configmaps") .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); MockEnvironment mockEnvironment = new MockEnvironment(); mockEnvironment.setProperty("spring.cloud.kubernetes.client.namespace", "default"); PropertySource propertySource = new KubernetesClientConfigMapPropertySourceLocator(api, @@ -115,8 +115,8 @@ void locateWithSources() { ConfigMapConfigProperties.Source source = new ConfigMapConfigProperties.Source("bootstrap-640", "default", Collections.emptyMap(), null, null, null); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), - List.of(source), Map.of(), true, "fake-name", null, false, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(source), + Map.of(), true, "fake-name", null, false, false, false, RetryProperties.DEFAULT); PropertySource propertySource = new KubernetesClientConfigMapPropertySourceLocator(api, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())).locate(ENV); @@ -137,8 +137,8 @@ void testLocateWithoutNamespaceConstructor() { stubFor(get("/api/v1/namespaces/default/configmaps") .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); assertThatThrownBy(() -> new KubernetesClientConfigMapPropertySourceLocator(api, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())).locate(ENV)) @@ -157,8 +157,8 @@ void testLocateWithoutNamespace() { CoreV1Api api = new CoreV1Api(); stubFor(get("/api/v1/namespaces/default/configmaps") .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); assertThatThrownBy(() -> new KubernetesClientConfigMapPropertySourceLocator(api, configMapConfigProperties, new KubernetesNamespaceProvider(ENV)).locate(ENV)) .isInstanceOf(NamespaceResolutionFailedException.class); @@ -170,8 +170,8 @@ public void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() { stubFor(get("/api/v1/namespaces/default/configmaps") .willReturn(aResponse().withStatus(500).withBody("Internal Server Error"))); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, "bootstrap-640", "default", false, false, true, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, "bootstrap-640", "default", false, false, true, RetryProperties.DEFAULT); KubernetesClientConfigMapPropertySourceLocator locator = new KubernetesClientConfigMapPropertySourceLocator(api, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())); @@ -186,8 +186,8 @@ public void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() { stubFor(get("/api/v1/namespaces/default/configmaps") .willReturn(aResponse().withStatus(500).withBody("Internal Server Error"))); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, "bootstrap-640", "default", false, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, "bootstrap-640", "default", false, false, false, RetryProperties.DEFAULT); KubernetesClientConfigMapPropertySourceLocator locator = new KubernetesClientConfigMapPropertySourceLocator(api, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())); diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientSecretsPropertySourceLocatorTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientSecretsPropertySourceLocatorTests.java index 841dfa79f1..c9e1fd66a0 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientSecretsPropertySourceLocatorTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientSecretsPropertySourceLocatorTests.java @@ -114,7 +114,7 @@ void getLocateWithSources() { SecretsConfigProperties.Source source2 = new SecretsConfigProperties.Source("rabbit-password", "", Collections.emptyMap(), null, null, null); - SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), + SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(source1, source2), true, "app", "default", false, true, false, RetryProperties.DEFAULT); PropertySource propertySource = new KubernetesClientSecretsPropertySourceLocator(api, @@ -127,8 +127,8 @@ void getLocateWithSources() { void getLocateWithOutSources() { CoreV1Api api = new CoreV1Api(); stubFor(get(LIST_API).willReturn(aResponse().withStatus(200).withBody(LIST_BODY))); - SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), - List.of(), true, "db-secret", "default", false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), true, + "db-secret", "default", false, true, false, RetryProperties.DEFAULT); PropertySource propertySource = new KubernetesClientSecretsPropertySourceLocator(api, new KubernetesNamespaceProvider(new MockEnvironment()), secretsConfigProperties).locate(ENV); @@ -148,8 +148,8 @@ void testLocateWithoutNamespaceConstructor() { CoreV1Api api = new CoreV1Api(); stubFor(get(LIST_API).willReturn(aResponse().withStatus(200).withBody(LIST_BODY))); - SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), - List.of(), true, "db-secret", "", false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), true, + "db-secret", "", false, true, false, RetryProperties.DEFAULT); assertThatThrownBy(() -> new KubernetesClientSecretsPropertySourceLocator(api, new KubernetesNamespaceProvider(new MockEnvironment()), secretsConfigProperties).locate(ENV)) @@ -161,8 +161,8 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() { CoreV1Api api = new CoreV1Api(); stubFor(get(LIST_API).willReturn(aResponse().withStatus(500).withBody("Internal Server Error"))); - SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), - List.of(), true, "db-secret", "default", false, true, true, RetryProperties.DEFAULT); + SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), true, + "db-secret", "default", false, true, true, RetryProperties.DEFAULT); KubernetesClientSecretsPropertySourceLocator locator = new KubernetesClientSecretsPropertySourceLocator(api, new KubernetesNamespaceProvider(new MockEnvironment()), secretsConfigProperties); @@ -176,8 +176,8 @@ void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() { CoreV1Api api = new CoreV1Api(); stubFor(get(LIST_API).willReturn(aResponse().withStatus(500).withBody("Internal Server Error"))); - SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), - List.of(), true, "db-secret", "default", false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties secretsConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), true, + "db-secret", "default", false, true, false, RetryProperties.DEFAULT); KubernetesClientSecretsPropertySourceLocator locator = new KubernetesClientSecretsPropertySourceLocator(api, new KubernetesNamespaceProvider(new MockEnvironment()), secretsConfigProperties); diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java index 2b3fc5ba16..42947b0dec 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java @@ -36,10 +36,9 @@ * @author Isik Erhan */ @ConfigurationProperties(ConfigMapConfigProperties.PREFIX) -public record ConfigMapConfigProperties(@DefaultValue("true") boolean enableApi, @DefaultValue List paths, - @DefaultValue List sources, @DefaultValue Map labels, - @DefaultValue("true") boolean enabled, String name, String namespace, boolean useNameAsPrefix, - @DefaultValue("true") boolean includeProfileSpecificSources, boolean failFast, +public record ConfigMapConfigProperties(@DefaultValue("true") boolean enableApi, @DefaultValue List sources, + @DefaultValue Map labels, @DefaultValue("true") boolean enabled, String name, String namespace, + boolean useNameAsPrefix, @DefaultValue("true") boolean includeProfileSpecificSources, boolean failFast, @DefaultValue RetryProperties retry) { /** diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java index 3c23784fb0..08d03dcfd7 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapPropertySourceLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,9 @@ package org.springframework.cloud.kubernetes.commons.config; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.Collection; -import java.util.HashMap; import java.util.LinkedHashSet; -import java.util.Map; import java.util.Set; -import java.util.function.Function; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -36,10 +30,6 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.PropertySource; -import static org.springframework.cloud.kubernetes.commons.config.PropertySourceUtils.KEY_VALUE_TO_PROPERTIES; -import static org.springframework.cloud.kubernetes.commons.config.PropertySourceUtils.PROPERTIES_TO_MAP; -import static org.springframework.cloud.kubernetes.commons.config.PropertySourceUtils.yamlParserGenerator; - /** * A {@link PropertySourceLocator} that uses config maps. * @@ -84,8 +74,6 @@ public PropertySource locate(Environment environment) { sources.forEach(s -> composite.addFirstPropertySource(getMapPropertySource(s, env))); } - addPropertySourcesFromPaths(environment, composite); - cache.discardAll(); return composite; } @@ -97,53 +85,4 @@ public Collection> locateCollection(Environment environment) { return PropertySourceLocator.super.locateCollection(environment); } - private void addPropertySourcesFromPaths(Environment environment, CompositePropertySource composite) { - Set uniquePaths = new LinkedHashSet<>(properties.paths()); - LOG.warn("path support is deprecated and will be removed in a future release. Please use spring.config.import"); - LOG.debug("paths property sources : " + uniquePaths); - uniquePaths.stream().map(Paths::get).filter(p -> { - boolean exists = Files.exists(p); - if (!exists) { - LOG.warn("Configured input path: " + p - + " will be ignored because it does not exist on the file system"); - } - return exists; - }).filter(p -> { - boolean regular = Files.isRegularFile(p); - if (!regular) { - LOG.warn("Configured input path: " + p + " will be ignored because it is not a regular file"); - } - return regular; - }).toList().forEach(p -> { - try { - String content = new String(Files.readAllBytes(p)).trim(); - String filename = p.toAbsolutePath().toString().toLowerCase(); - if (filename.endsWith(".properties")) { - addPropertySourceIfNeeded(c -> PROPERTIES_TO_MAP.apply(KEY_VALUE_TO_PROPERTIES.apply(c)), content, - filename, composite); - } - else if (filename.endsWith(".yml") || filename.endsWith(".yaml")) { - addPropertySourceIfNeeded(c -> PROPERTIES_TO_MAP.apply(yamlParserGenerator(environment).apply(c)), - content, filename, composite); - } - } - catch (IOException e) { - LOG.warn("Error reading input file", e); - } - }); - } - - private void addPropertySourceIfNeeded(Function> contentToMapFunction, String content, - String name, CompositePropertySource composite) { - - Map map = new HashMap<>(contentToMapFunction.apply(content)); - if (map.isEmpty()) { - LOG.warn("Property source: " + name + "will be ignored because no properties could be found"); - } - else { - LOG.debug("will add file-based property source : " + name); - composite.addFirstPropertySource(new MountConfigMapPropertySource(name, map)); - } - } - } diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MountConfigMapPropertySource.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MountConfigMapPropertySource.java deleted file mode 100644 index 7cbffac4c0..0000000000 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/MountConfigMapPropertySource.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2013-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.commons.config; - -import java.util.Map; - -import org.springframework.core.env.MapPropertySource; - -/** - * @author wind57 - */ -public final class MountConfigMapPropertySource extends MapPropertySource { - - public MountConfigMapPropertySource(String name, Map source) { - super(name, source); - } - -} diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigProperties.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigProperties.java index ea48184828..614d525637 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigProperties.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigProperties.java @@ -38,9 +38,8 @@ */ @ConfigurationProperties(SecretsConfigProperties.PREFIX) public record SecretsConfigProperties(boolean enableApi, @DefaultValue Map labels, - @DefaultValue List paths, @DefaultValue List sources, @DefaultValue("true") boolean enabled, - String name, String namespace, boolean useNameAsPrefix, - @DefaultValue("true") boolean includeProfileSpecificSources, boolean failFast, + @DefaultValue List sources, @DefaultValue("true") boolean enabled, String name, String namespace, + boolean useNameAsPrefix, @DefaultValue("true") boolean includeProfileSpecificSources, boolean failFast, @DefaultValue RetryProperties retry) { /** diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java index 235cacb957..4fefbe307e 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2021 the original author or authors. + * Copyright 2013-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,23 +16,10 @@ package org.springframework.cloud.kubernetes.commons.config; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.Set; -import java.util.function.BiConsumer; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.function.Supplier; -import java.util.stream.Collector; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -82,8 +69,6 @@ public PropertySource locate(Environment environment) { Set uniqueSources = new HashSet<>(sources); LOG.debug("Secrets normalized sources : " + sources); CompositePropertySource composite = new CompositePropertySource("composite-secrets"); - // read for secrets mount - putPathConfig(composite); if (this.properties.enableApi()) { uniqueSources @@ -110,77 +95,4 @@ private SecretsPropertySource getSecretsPropertySourceForSingleSecret(Configurab protected abstract SecretsPropertySource getPropertySource(ConfigurableEnvironment environment, NormalizedSource normalizedSource); - protected void putPathConfig(CompositePropertySource composite) { - - LOG.warn("path support is deprecated and will be removed in a future release. Please use spring.config.import"); - - this.properties.paths().stream().map(Paths::get).filter(Files::exists).flatMap(x -> { - try { - return Files.walk(x); - } - catch (IOException e) { - LOG.warn("Error walking properties files", e); - return null; - } - }).filter(Objects::nonNull).filter(Files::isRegularFile).collect(new SecretsPropertySourceCollector()) - .forEach(composite::addPropertySource); - } - - /** - * @author wind57 - */ - private static class SecretsPropertySourceCollector - implements Collector, List> { - - @Override - public Supplier> supplier() { - return ArrayList::new; - } - - @Override - public BiConsumer, Path> accumulator() { - return (list, filePath) -> { - SecretsPropertySource source = property(filePath); - if (source != null) { - list.add(source); - } - }; - } - - @Override - public BinaryOperator> combiner() { - return (left, right) -> { - left.addAll(right); - return left; - }; - } - - @Override - public Function, List> finisher() { - return Function.identity(); - } - - @Override - public Set characteristics() { - return EnumSet.of(Characteristics.UNORDERED, Characteristics.IDENTITY_FINISH); - } - - private SecretsPropertySource property(Path filePath) { - - String fileName = filePath.getFileName().toString(); - - try { - String content = new String(Files.readAllBytes(filePath)).trim(); - String sourceName = fileName.toLowerCase(); - SourceData sourceData = new SourceData(sourceName, Collections.singletonMap(fileName, content)); - return new SecretsPropertySource(sourceData); - } - catch (IOException e) { - LOG.warn("Error reading properties file", e); - return null; - } - } - - } - } diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java index d9b0f933fa..02f1c60d83 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2022 the original author or authors. + * Copyright 2013-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import org.springframework.cloud.bootstrap.config.BootstrapPropertySource; import org.springframework.cloud.bootstrap.config.PropertySourceLocator; -import org.springframework.cloud.kubernetes.commons.config.MountConfigMapPropertySource; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; @@ -85,20 +84,12 @@ public static > List findPropertySources(Class else if (sourceClass.isInstance(source)) { managedSources.add(sourceClass.cast(source)); } - else if (source instanceof MountConfigMapPropertySource mountConfigMapPropertySource) { - // we know that the type is correct here - managedSources.add((S) mountConfigMapPropertySource); - } else if (source instanceof BootstrapPropertySource bootstrapPropertySource) { PropertySource propertySource = bootstrapPropertySource.getDelegate(); LOG.debug(() -> "bootstrap delegate class : " + propertySource.getClass()); if (sourceClass.isInstance(propertySource)) { sources.add(propertySource); } - else if (propertySource instanceof MountConfigMapPropertySource mountConfigMapPropertySource) { - // we know that the type is correct here - managedSources.add((S) mountConfigMapPropertySource); - } } } diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java index 526b70a98a..d0a42bc2c5 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java @@ -37,7 +37,6 @@ void testWithDefaults() { ConfigMapConfigProperties props = context.getBean(ConfigMapConfigProperties.class); Assertions.assertNotNull(props); Assertions.assertTrue(props.enableApi()); - Assertions.assertTrue(props.paths().isEmpty()); Assertions.assertTrue(props.sources().isEmpty()); Assertions.assertTrue(props.labels().isEmpty()); Assertions.assertTrue(props.enabled()); @@ -58,32 +57,30 @@ void testWithDefaults() { @Test void testWithNonDefaults() { - new ApplicationContextRunner().withUserConfiguration(Config.class).withPropertyValues( - "spring.cloud.kubernetes.config.enableApi=false", "spring.cloud.kubernetes.config.paths[0]=a", - "spring.cloud.kubernetes.config.paths[1]=b", "spring.cloud.kubernetes.config.sources[0].name=source-a", - "spring.cloud.kubernetes.config.sources[0].namespace=source-namespace-a", - "spring.cloud.kubernetes.config.sources[0].labels.key=source-value", - "spring.cloud.kubernetes.config.sources[0].explicit-prefix=source-prefix", - "spring.cloud.kubernetes.config.sources[0].use-name-as-prefix=true", - "spring.cloud.kubernetes.config.sources[0].include-profile-specific-sources=true", - "spring.cloud.kubernetes.config.labels.label-a=label-a", "spring.cloud.kubernetes.config.enabled=false", - "spring.cloud.kubernetes.config.name=name", "spring.cloud.kubernetes.config.namespace=namespace", - "spring.cloud.kubernetes.config.use-name-as-prefix=true", - "spring.cloud.kubernetes.config.include-profile-specific-sources=true", - "spring.cloud.kubernetes.config.fail-fast=true", - "spring.cloud.kubernetes.config.retry.initial-interval=1", - "spring.cloud.kubernetes.config.retry.multiplier=1.2", - "spring.cloud.kubernetes.config.retry.max-interval=3", - "spring.cloud.kubernetes.config.retry.max-attempts=4", - "spring.cloud.kubernetes.config.retry.enabled=false").run(context -> { + new ApplicationContextRunner().withUserConfiguration(Config.class) + .withPropertyValues("spring.cloud.kubernetes.config.enableApi=false", + "spring.cloud.kubernetes.config.sources[0].name=source-a", + "spring.cloud.kubernetes.config.sources[0].namespace=source-namespace-a", + "spring.cloud.kubernetes.config.sources[0].labels.key=source-value", + "spring.cloud.kubernetes.config.sources[0].explicit-prefix=source-prefix", + "spring.cloud.kubernetes.config.sources[0].use-name-as-prefix=true", + "spring.cloud.kubernetes.config.sources[0].include-profile-specific-sources=true", + "spring.cloud.kubernetes.config.labels.label-a=label-a", + "spring.cloud.kubernetes.config.enabled=false", "spring.cloud.kubernetes.config.name=name", + "spring.cloud.kubernetes.config.namespace=namespace", + "spring.cloud.kubernetes.config.use-name-as-prefix=true", + "spring.cloud.kubernetes.config.include-profile-specific-sources=true", + "spring.cloud.kubernetes.config.fail-fast=true", + "spring.cloud.kubernetes.config.retry.initial-interval=1", + "spring.cloud.kubernetes.config.retry.multiplier=1.2", + "spring.cloud.kubernetes.config.retry.max-interval=3", + "spring.cloud.kubernetes.config.retry.max-attempts=4", + "spring.cloud.kubernetes.config.retry.enabled=false") + .run(context -> { ConfigMapConfigProperties props = context.getBean(ConfigMapConfigProperties.class); Assertions.assertNotNull(props); Assertions.assertFalse(props.enableApi()); - Assertions.assertEquals(props.paths().size(), 2); - Assertions.assertEquals(props.paths().get(0), "a"); - Assertions.assertEquals(props.paths().get(1), "b"); - Assertions.assertEquals(props.sources().size(), 1); ConfigMapConfigProperties.Source source = props.sources().get(0); Assertions.assertEquals(source.name(), "source-a"); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java index f4b0a98cc0..10364d19bc 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java @@ -46,7 +46,7 @@ class ConfigMapConfigPropertiesTests { */ @Test void testUseNameAsPrefixUnsetEmptySources() { - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(), Map.of(), true, + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), Map.of(), true, "config-map-a", "spring-k8s", false, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); @@ -72,7 +72,7 @@ void testUseNameAsPrefixUnsetEmptySources() { */ @Test void testUseNameAsPrefixSetEmptySources() { - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(), Map.of(), true, + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), Map.of(), true, "config-map-a", "spring-k8s", true, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); @@ -104,8 +104,8 @@ void testUseNameAsPrefixUnsetNonEmptySources() { ConfigMapConfigProperties.Source one = new ConfigMapConfigProperties.Source("config-map-one", null, Collections.emptyMap(), null, null, null); - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(one), Map.of(), - true, "config-map-a", "spring-k8s", true, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(one), Map.of(), true, + "config-map-a", "spring-k8s", true, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 1, "a single NormalizedSource is expected"); @@ -147,8 +147,8 @@ void testUseNameAsPrefixSetNonEmptySources() { ConfigMapConfigProperties.Source three = new ConfigMapConfigProperties.Source("config-map-three", null, Collections.emptyMap(), null, true, null); - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(one, two, three), - Map.of(), true, "config-map-a", "spring-k8s", true, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(one, two, three), Map.of(), + true, "config-map-a", "spring-k8s", true, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 3, "3 NormalizedSources are expected"); @@ -196,9 +196,8 @@ void testMultipleCases() { ConfigMapConfigProperties.Source four = new ConfigMapConfigProperties.Source(null, "config-map-four", Collections.emptyMap(), null, false, null); - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), - List.of(one, two, three, four), Map.of(), true, "config-map-a", "spring-k8s", true, false, false, - RetryProperties.DEFAULT); + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(one, two, three, four), + Map.of(), true, "config-map-a", "spring-k8s", true, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 4, "4 NormalizedSources are expected"); @@ -229,7 +228,7 @@ void testMultipleCases() { @Test void testUseIncludeProfileSpecificSourcesNoChanges() { - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(), Map.of(), true, + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), Map.of(), true, "config-map-a", "spring-k8s", false, true, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); @@ -258,7 +257,7 @@ void testUseIncludeProfileSpecificSourcesNoChanges() { @Test void testUseIncludeProfileSpecificSourcesDefaultChanged() { - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(), Map.of(), true, + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), Map.of(), true, "config-map-a", "spring-k8s", false, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); @@ -302,8 +301,8 @@ void testUseIncludeProfileSpecificSourcesDefaultChangedSourceOverride() { ConfigMapConfigProperties.Source three = new ConfigMapConfigProperties.Source("config-map-three", null, Collections.emptyMap(), null, null, false); - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), List.of(one, two, three), - Map.of(), true, "config-map-a", "spring-k8s", false, false, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(one, two, three), Map.of(), + true, "config-map-a", "spring-k8s", false, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 3); @@ -359,9 +358,8 @@ void testLabelsMultipleCases() { ConfigMapConfigProperties.Source four = new ConfigMapConfigProperties.Source(null, null, Map.of("fourth-label", "configmap-four"), null, null, null); - ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(), - List.of(one, two, three, four), Map.of(), true, "config-map-a", "spring-k8s", false, false, false, - RetryProperties.DEFAULT); + ConfigMapConfigProperties properties = new ConfigMapConfigProperties(true, List.of(one, two, three, four), + Map.of(), true, "config-map-a", "spring-k8s", false, false, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); // we get 8 property sources, since "named" ones with "application" are diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/KubernetesConfigDataLocationResolverTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/KubernetesConfigDataLocationResolverTests.java index 3bad5ad2bf..7141a6a940 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/KubernetesConfigDataLocationResolverTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/KubernetesConfigDataLocationResolverTests.java @@ -224,11 +224,11 @@ void testResolveProfileSpecificFour() { // 'one' and 'two' prove that we have not registered ConfigMapConfigProperties and // SecretsConfigProperties in the bootstrap context - ConfigMapConfigProperties one = new ConfigMapConfigProperties(false, List.of(), List.of(), Map.of(), false, - null, null, false, false, false, null); + ConfigMapConfigProperties one = new ConfigMapConfigProperties(false, List.of(), Map.of(), false, null, null, + false, false, false, null); - SecretsConfigProperties two = new SecretsConfigProperties(false, Map.of(), List.of(), List.of(), false, null, - null, false, false, false, null); + SecretsConfigProperties two = new SecretsConfigProperties(false, Map.of(), List.of(), false, null, null, false, + false, false, null); KubernetesClientProperties kubernetesClientProperties = RESOLVER_CONTEXT.getBootstrapContext() .get(KubernetesClientProperties.class); @@ -293,11 +293,6 @@ void testResolveProfileSpecificSix() { Assertions.assertFalse(result.get(0).getConfigMapProperties().enableApi()); // on the other hand, @Default will be picked here Assertions.assertTrue(result.get(0).getConfigMapProperties().enabled()); - - // we have @DefaultValue enabled on paths, but it is not going to be picked up - // because of the explicit property we set in environment - Assertions.assertEquals("a", result.get(0).getSecretsConfigProperties().paths().get(0)); - // on the other hand, @Default will be picked here Assertions.assertTrue(result.get(0).getSecretsConfigProperties().includeProfileSpecificSources()); } diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java index 45918b702d..2e7394eb02 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java @@ -37,7 +37,6 @@ void testWithDefaults() { SecretsConfigProperties props = context.getBean(SecretsConfigProperties.class); Assertions.assertNotNull(props); Assertions.assertFalse(props.enableApi()); - Assertions.assertTrue(props.paths().isEmpty()); Assertions.assertTrue(props.sources().isEmpty()); Assertions.assertTrue(props.labels().isEmpty()); Assertions.assertTrue(props.enabled()); @@ -60,7 +59,6 @@ void testWithDefaults() { void testWithNonDefaults() { new ApplicationContextRunner().withUserConfiguration(Config.class) .withPropertyValues("spring.cloud.kubernetes.secrets.enableApi=false", - "spring.cloud.kubernetes.secrets.paths[0]=a", "spring.cloud.kubernetes.secrets.paths[1]=b", "spring.cloud.kubernetes.secrets.sources[0].name=source-a", "spring.cloud.kubernetes.secrets.sources[0].namespace=source-namespace-a", "spring.cloud.kubernetes.secrets.sources[0].labels.key=source-value", @@ -83,10 +81,6 @@ void testWithNonDefaults() { Assertions.assertNotNull(props); Assertions.assertFalse(props.enableApi()); - Assertions.assertEquals(props.paths().size(), 2); - Assertions.assertEquals(props.paths().get(0), "a"); - Assertions.assertEquals(props.paths().get(1), "b"); - Assertions.assertEquals(props.sources().size(), 1); SecretsConfigProperties.Source source = props.sources().get(0); Assertions.assertEquals(source.name(), "source-a"); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesTests.java index cb3cd6439f..6a424ab2c1 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesTests.java @@ -39,8 +39,8 @@ class SecretsConfigPropertiesTests { @Test void emptySourcesSecretName() { - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), List.of(), true, - null, "namespace", false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), true, null, + "namespace", false, true, false, RetryProperties.DEFAULT); List source = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(source.size(), 1); @@ -80,8 +80,8 @@ void multipleSources() { SecretsConfigProperties.Source three = new SecretsConfigProperties.Source(null, "spring-k8s", Map.of("three", "3"), null, false, false); - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), - List.of(one, two, three), true, null, "namespace", false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(one, two, three), + true, null, "namespace", false, true, false, RetryProperties.DEFAULT); List result = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(result.size(), 6); @@ -125,8 +125,8 @@ void multipleSources() { @Test void testUseNameAsPrefixUnsetEmptySources() { - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), List.of(), true, - "secret-a", "namespace", false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), true, "secret-a", + "namespace", false, true, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 1, "empty sources must generate a List with a single NormalizedSource"); @@ -151,8 +151,8 @@ void testUseNameAsPrefixUnsetEmptySources() { @Test void testUseNameAsPrefixSetEmptySources() { - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), List.of(), true, - "secret-a", "namespace", true, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), true, "secret-a", + "namespace", true, true, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 1, "empty sources must generate a List with a single NormalizedSource"); @@ -183,7 +183,7 @@ void testUseNameAsPrefixUnsetNonEmptySources() { SecretsConfigProperties.Source one = new SecretsConfigProperties.Source("secret-one", "spring-k8s", Map.of(), null, true, false); - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), List.of(one), true, + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(one), true, "secret-one", null, false, true, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); @@ -226,8 +226,8 @@ void testUseNameAsPrefixSetNonEmptySources() { SecretsConfigProperties.Source three = new SecretsConfigProperties.Source("secret-three", "spring-k8s", Map.of(), null, true, false); - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), - List.of(one, two, three), true, "secret-one", null, false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(one, two, three), + true, "secret-one", null, false, true, false, RetryProperties.DEFAULT); List sources = properties.determineSources(new MockEnvironment()); Assertions.assertEquals(sources.size(), 3, "3 NormalizedSources are expected"); @@ -275,7 +275,7 @@ void testMultipleCases() { SecretsConfigProperties.Source four = new SecretsConfigProperties.Source("secret-four", "spring-k8s", Map.of(), null, false, false); - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(one, two, three, four), true, "secret-one", "spring-k8s", false, false, false, RetryProperties.DEFAULT); @@ -335,7 +335,7 @@ void testLabelsMultipleCases() { SecretsConfigProperties.Source four = new SecretsConfigProperties.Source(null, "spring-k8s", Map.of("fourth-label", "secret-four"), null, false, false); - SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(), + SecretsConfigProperties properties = new SecretsConfigProperties(false, Map.of(), List.of(one, two, three, four), false, null, "spring-k8s", false, false, false, RetryProperties.DEFAULT); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtilTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtilTests.java index 280d95f9d5..02194ee127 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtilTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtilTests.java @@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test; import org.springframework.cloud.bootstrap.config.BootstrapPropertySource; -import org.springframework.cloud.kubernetes.commons.config.MountConfigMapPropertySource; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.EnumerablePropertySource; import org.springframework.core.env.MapPropertySource; @@ -139,15 +138,13 @@ public Object getProperty(String name) { return null; } })); - propertySources.addFirst(new MountConfigMapPropertySource("mounted", Map.of("a", "b"))); List result = ConfigReloadUtil.findPropertySources(PlainPropertySource.class, environment); - Assertions.assertEquals(4, result.size()); - Assertions.assertEquals("b", result.get(0).getProperty("a")); - Assertions.assertEquals("plain", result.get(1).getProperty("")); - Assertions.assertEquals("from-bootstrap", result.get(2).getProperty("")); - Assertions.assertEquals("from-inner-two-composite", result.get(3).getProperty("")); + Assertions.assertEquals(3, result.size()); + Assertions.assertEquals("plain", result.get(0).getProperty("")); + Assertions.assertEquals("from-bootstrap", result.get(1).getProperty("")); + Assertions.assertEquals("from-inner-two-composite", result.get(2).getProperty("")); } private static final class OneComposite extends CompositePropertySource { diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsFromFilePathsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsFromFilePathsTests.java deleted file mode 100644 index d21ecd5a67..0000000000 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsFromFilePathsTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.fabric8.config; - -import java.io.IOException; - -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.extension.ExtendWith; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.kubernetes.fabric8.config.example.App; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = App.class, properties = { - "spring.application.name=configmap-path-example", "spring.cloud.kubernetes.config.enableApi=false", - "spring.cloud.kubernetes.config.paths=" + BootstrapConfigMapsFromFilePathsTests.FIRST_FILE_NAME_FULL_PATH + "," - + BootstrapConfigMapsFromFilePathsTests.SECOND_FILE_NAME_FULL_PATH + "," - + BootstrapConfigMapsFromFilePathsTests.FIRST_FILE_NAME_DUPLICATED_FULL_PATH, - "spring.main.cloud-platform=KUBERNETES", "spring.cloud.bootstrap.enabled=true" }) -@EnableKubernetesMockClient(crud = true, https = false) -public class BootstrapConfigMapsFromFilePathsTests extends ConfigMapsFromFilePathsTests { - - private static KubernetesClient mockClient; - - @BeforeAll - public static void setUpBeforeClass() throws IOException { - setUpBeforeClass(mockClient); - } - -} diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsMixedTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsMixedTests.java index b550c93953..461959d246 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsMixedTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/BootstrapConfigMapsMixedTests.java @@ -30,9 +30,8 @@ @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = App.class, properties = { "spring.application.name=" + BootstrapConfigMapsMixedTests.APPLICATION_NAME, - "spring.cloud.kubernetes.config.enableApi=true", - "spring.cloud.kubernetes.config.paths=" + BootstrapConfigMapsMixedTests.FILE_NAME_FULL_PATH, - "spring.main.cloud-platform=KUBERNETES", "spring.cloud.bootstrap.enabled=true" }) + "spring.cloud.kubernetes.config.enableApi=true", "spring.main.cloud-platform=KUBERNETES", + "spring.cloud.bootstrap.enabled=true" }) @EnableKubernetesMockClient(crud = true, https = false) public class BootstrapConfigMapsMixedTests extends ConfigMapsMixedTests { diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsFromFilePathsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsFromFilePathsTests.java deleted file mode 100644 index 4f21d7b3d5..0000000000 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsFromFilePathsTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.fabric8.config; - -import java.io.IOException; - -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.extension.ExtendWith; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.kubernetes.fabric8.config.example.App; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = App.class, properties = { - "spring.application.name=configmap-path-example", "spring.cloud.kubernetes.config.enableApi=false", - "spring.cloud.kubernetes.config.paths=" + ConfigDataConfigMapsFromFilePathsTests.FIRST_FILE_NAME_FULL_PATH + "," - + ConfigDataConfigMapsFromFilePathsTests.SECOND_FILE_NAME_FULL_PATH + "," - + ConfigDataConfigMapsFromFilePathsTests.FIRST_FILE_NAME_DUPLICATED_FULL_PATH, - "spring.main.cloud-platform=KUBERNETES", "spring.config.import=kubernetes:" }) -@EnableKubernetesMockClient(crud = true, https = false) -public class ConfigDataConfigMapsFromFilePathsTests extends ConfigMapsFromFilePathsTests { - - private static KubernetesClient mockClient; - - @BeforeAll - public static void setUpBeforeClass() throws IOException { - setUpBeforeClass(mockClient); - } - -} diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsMixedTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsMixedTests.java index ccfe012396..22240ec0df 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsMixedTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigDataConfigMapsMixedTests.java @@ -30,9 +30,8 @@ @ExtendWith(SpringExtension.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = App.class, properties = { "spring.application.name=" + ConfigDataConfigMapsMixedTests.APPLICATION_NAME, - "spring.cloud.kubernetes.config.enableApi=true", - "spring.cloud.kubernetes.config.paths=" + ConfigDataConfigMapsMixedTests.FILE_NAME_FULL_PATH, - "spring.main.cloud-platform=KUBERNETES", "spring.config.import=kubernetes:" }) + "spring.cloud.kubernetes.config.enableApi=true", "spring.main.cloud-platform=KUBERNETES", + "spring.config.import=kubernetes:" }) @EnableKubernetesMockClient(crud = true, https = false) public class ConfigDataConfigMapsMixedTests extends ConfigMapsMixedTests { diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapTestUtil.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapTestUtil.java index 1955050d5d..c2fa8fe699 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapTestUtil.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapTestUtil.java @@ -17,9 +17,6 @@ package org.springframework.cloud.kubernetes.fabric8.config; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; import io.fabric8.kubernetes.client.utils.IOHelpers; @@ -39,8 +36,4 @@ static String readResourceFile(String file) { return resource; } - static void createFileWithContent(String file, String content) throws IOException { - Files.write(Paths.get(file), content.getBytes(), StandardOpenOption.CREATE); - } - } diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsFromFilePathsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsFromFilePathsTests.java deleted file mode 100644 index 0161a06d85..0000000000 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsFromFilePathsTests.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.fabric8.config; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import io.fabric8.kubernetes.client.Config; -import io.fabric8.kubernetes.client.KubernetesClient; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.cloud.kubernetes.fabric8.config.example.App; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.web.reactive.server.WebTestClient; - -import static org.assertj.core.util.Lists.newArrayList; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = App.class, - properties = { "spring.application.name=configmap-path-example", - "spring.cloud.kubernetes.config.enableApi=false", - "spring.cloud.kubernetes.config.paths=" + ConfigMapsFromFilePathsTests.FIRST_FILE_NAME_FULL_PATH + "," - + ConfigMapsFromFilePathsTests.SECOND_FILE_NAME_FULL_PATH + "," - + ConfigMapsFromFilePathsTests.FIRST_FILE_NAME_DUPLICATED_FULL_PATH, - "spring.main.cloud-platform=KUBERNETES" }) -abstract class ConfigMapsFromFilePathsTests { - - protected static final String FILES_ROOT_PATH = "/tmp/scktests"; - - protected static final String FILES_SUB_PATH = "another-directory"; - - protected static final String FIRST_FILE_NAME = "application.properties"; - - protected static final String SECOND_FILE_NAME = "extra.properties"; - - protected static final String UNUSED_FILE_NAME = "unused.properties"; - - protected static final String FIRST_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + FIRST_FILE_NAME; - - protected static final String SECOND_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + SECOND_FILE_NAME; - - protected static final String UNUSED_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + UNUSED_FILE_NAME; - - protected static final String FIRST_FILE_NAME_DUPLICATED_FULL_PATH = FILES_ROOT_PATH + "/" + FILES_SUB_PATH + "/" - + FIRST_FILE_NAME; - - @Autowired - private WebTestClient webClient; - - public static void setUpBeforeClass(KubernetesClient mockClient) throws IOException { - - // Configure the kubernetes master url to point to the mock server - System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl()); - System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true"); - System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false"); - System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false"); - System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); - System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); - Files.createDirectories(Paths.get(FILES_ROOT_PATH + "/" + FILES_SUB_PATH)); - ConfigMapTestUtil.createFileWithContent(FIRST_FILE_NAME_FULL_PATH, "bean.greeting=Hello from path!"); - ConfigMapTestUtil.createFileWithContent(SECOND_FILE_NAME_FULL_PATH, "bean.farewell=Bye from path!"); - ConfigMapTestUtil.createFileWithContent(UNUSED_FILE_NAME_FULL_PATH, "bean.morning=Morning from path!"); - ConfigMapTestUtil.createFileWithContent(FIRST_FILE_NAME_DUPLICATED_FULL_PATH, - "bean.bonjour=Bonjour from path!"); - } - - @AfterAll - public static void teardownAfterClass() { - newArrayList(FIRST_FILE_NAME_FULL_PATH, SECOND_FILE_NAME_FULL_PATH, SECOND_FILE_NAME_FULL_PATH, FILES_ROOT_PATH) - .forEach(fn -> { - try { - Files.delete(Paths.get(fn)); - } - catch (IOException ignored) { - } - }); - } - - @Test - public void greetingInputShouldReturnPropertyFromFirstFile() { - this.webClient.get().uri("/api/greeting").exchange().expectStatus().isOk().expectBody().jsonPath("content") - .isEqualTo("Hello from path!"); - } - - @Test - public void farewellInputShouldReturnPropertyFromSecondFile() { - this.webClient.get().uri("/api/farewell").exchange().expectStatus().isOk().expectBody().jsonPath("content") - .isEqualTo("Bye from path!"); - } - - @Test - public void morningInputShouldReturnDefaultValue() { - this.webClient.get().uri("/api/morning").exchange().expectStatus().isOk().expectBody().jsonPath("content") - .isEqualTo("Good morning, World!"); - } - - @Test - public void bonjourInputShouldReturnPropertyFromDuplicatedFile() { - this.webClient.get().uri("/api/bonjour").exchange().expectStatus().isOk().expectBody().jsonPath("content") - .isEqualTo("Bonjour from path!"); - } - -} diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsMixedTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsMixedTests.java index ffdad69b64..cc78124ae8 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsMixedTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapsMixedTests.java @@ -17,30 +17,19 @@ package org.springframework.cloud.kubernetes.fabric8.config; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.HashMap; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ConfigMapBuilder; import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.KubernetesClient; -import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.web.reactive.server.WebTestClient; -import static org.assertj.core.util.Lists.newArrayList; - abstract class ConfigMapsMixedTests { - protected static final String FILES_ROOT_PATH = "/tmp/scktests"; - - protected static final String FILE_NAME = "application-path.yaml"; - - protected static final String FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + FILE_NAME; - protected static final String APPLICATION_NAME = "configmap-mixed-example"; @Autowired @@ -56,10 +45,6 @@ public static void setUpBeforeClass(KubernetesClient mockClient) throws IOExcept System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test"); System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true"); - Files.createDirectories(Paths.get(FILES_ROOT_PATH)); - ConfigMapTestUtil.createFileWithContent(FILE_NAME_FULL_PATH, - ConfigMapTestUtil.readResourceFile("application-path.yaml")); - HashMap data = new HashMap<>(); data.put("bean.morning", "Buenos Dias ConfigMap, %s"); @@ -69,29 +54,6 @@ public static void setUpBeforeClass(KubernetesClient mockClient) throws IOExcept mockClient.configMaps().inNamespace("test").resource(configMap).create(); } - @AfterAll - public static void teardownAfterClass() { - newArrayList(FILE_NAME_FULL_PATH, FILES_ROOT_PATH).forEach(fn -> { - try { - Files.delete(Paths.get(fn)); - } - catch (IOException ignored) { - } - }); - } - - @Test - public void greetingInputShouldReturnPropertyFromFile() { - this.webClient.get().uri("/api/greeting").exchange().expectStatus().isOk().expectBody().jsonPath("content") - .isEqualTo("Hello ConfigMap, World from path"); - } - - @Test - public void farewellInputShouldReturnPropertyFromFile() { - this.webClient.get().uri("/api/farewell").exchange().expectStatus().isOk().expectBody().jsonPath("content") - .isEqualTo("Bye ConfigMap, World from path"); - } - @Test public void morningInputShouldReturnPropertyFromApi() { this.webClient.get().uri("/api/morning").exchange().expectStatus().isOk().expectBody().jsonPath("content") diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorMockTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorMockTests.java index 0ab018c479..bff9cd3fec 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorMockTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorMockTests.java @@ -46,8 +46,8 @@ class Fabric8ConfigMapPropertySourceLocatorMockTests { @Test void constructorWithoutClientNamespaceMustFail() { - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, "name", null, false, true, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, "name", null, false, true, false, RetryProperties.DEFAULT); Mockito.when(client.getNamespace()).thenReturn(null); Fabric8ConfigMapPropertySourceLocator source = new Fabric8ConfigMapPropertySourceLocator(client, diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorTests.java index 547b07c441..d3fd5fc8a2 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8ConfigMapPropertySourceLocatorTests.java @@ -50,8 +50,8 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() { mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once(); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, name, namespace, false, true, true, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, name, namespace, false, true, true, RetryProperties.DEFAULT); Fabric8ConfigMapPropertySourceLocator locator = new Fabric8ConfigMapPropertySourceLocator(mockClient, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())); @@ -68,8 +68,8 @@ void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() { mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once(); - ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), List.of(), - Map.of(), true, name, namespace, false, true, false, RetryProperties.DEFAULT); + ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), + true, name, namespace, false, true, false, RetryProperties.DEFAULT); Fabric8ConfigMapPropertySourceLocator locator = new Fabric8ConfigMapPropertySourceLocator(mockClient, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())); diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8SecretsPropertySourceLocatorTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8SecretsPropertySourceLocatorTests.java index 24c771e312..ee43f451f8 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8SecretsPropertySourceLocatorTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8SecretsPropertySourceLocatorTests.java @@ -50,8 +50,8 @@ void locateShouldThrowExceptionOnFailureWhenFailFastIsEnabled() { mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once(); - SecretsConfigProperties configMapConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), - List.of(), true, name, namespace, false, true, true, RetryProperties.DEFAULT); + SecretsConfigProperties configMapConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), true, + name, namespace, false, true, true, RetryProperties.DEFAULT); Fabric8SecretsPropertySourceLocator locator = new Fabric8SecretsPropertySourceLocator(mockClient, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())); @@ -68,8 +68,8 @@ void locateShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() { mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").once(); - SecretsConfigProperties configMapConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), - List.of(), true, name, namespace, false, true, false, RetryProperties.DEFAULT); + SecretsConfigProperties configMapConfigProperties = new SecretsConfigProperties(true, Map.of(), List.of(), true, + name, namespace, false, true, false, RetryProperties.DEFAULT); Fabric8SecretsPropertySourceLocator locator = new Fabric8SecretsPropertySourceLocator(mockClient, configMapConfigProperties, new KubernetesNamespaceProvider(new MockEnvironment())); diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/locator_retry/fail_fast_enabled_retry_disabled/ConfigDataConfigFailFastEnabledButRetryDisabled.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/locator_retry/fail_fast_enabled_retry_disabled/ConfigDataConfigFailFastEnabledButRetryDisabled.java index a3bc41c037..8f97e875e9 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/locator_retry/fail_fast_enabled_retry_disabled/ConfigDataConfigFailFastEnabledButRetryDisabled.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/locator_retry/fail_fast_enabled_retry_disabled/ConfigDataConfigFailFastEnabledButRetryDisabled.java @@ -76,7 +76,7 @@ static class LocalConfig { */ @Bean ConfigMapConfigProperties properties(Environment environment) { - return new ConfigMapConfigProperties(true, List.of(), List.of(), Map.of(), true, null, null, false, true, + return new ConfigMapConfigProperties(true, List.of(), Map.of(), true, null, null, false, true, Boolean.parseBoolean(environment.getProperty("spring.cloud.kubernetes.config.fail-fast")), RetryProperties.DEFAULT); } From ada6450557e0cd3f2cea8b39570b423f38eeb0fa Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 10 May 2023 16:44:14 +0300 Subject: [PATCH 009/100] continue with tests --- docs/src/main/asciidoc/_configprops.adoc | 8 +- .../main/asciidoc/property-source-config.adoc | 109 ++++++++++++------ .../config/reload/ConfigReloadUtil.java | 2 +- .../pom.xml | 2 +- .../polling/reload/ConfigMapApp.java | 2 +- .../polling/reload/ConfigMapController.java | 10 +- .../polling/reload/ConfigMapProperties.java | 6 +- .../reload/ConfigMapPropertiesNoMount.java | 37 ++++++ .../src/main/resources/application-mount.yaml | 24 ++++ .../main/resources/application-no-mount.yaml | 2 - .../resources/application-with-bootstrap.yaml | 14 ++- .../resources/bootstrap-with-bootstrap.yaml | 3 + ...pEnabledPollingReloadConfigMapMountIT.java | 78 ++++++------- .../reload/ConfigMapPollingReloadIT.java | 4 +- .../reload/ReloadConfigMapMountIT.java} | 77 +++++-------- .../src/test/resources/configmap.yaml | 0 .../src/test/resources/deployment.yaml | 10 +- .../src/test/resources/ingress.yaml | 4 +- .../src/test/resources/logback-test.xml | 0 .../test/resources/mount/configmap-mount.yaml | 7 ++ .../resources/mount/deployment-mount.yaml | 18 +-- .../src/test/resources/service.yaml | 14 +++ .../pom.xml | 2 +- .../src/main/resources/application-mount.yaml | 17 --- .../resources/bootstrap-with-bootstrap.yaml | 6 - .../test/resources/mount/configmap-mount.yaml | 8 -- .../src/test/resources/service.yaml | 14 --- .../tests/commons/fabric8_client/Util.java | 16 +++ .../resources/config-watcher/deployment.yaml | 37 ++++++ .../resources/config-watcher/service.yaml | 14 +++ 30 files changed, 340 insertions(+), 205 deletions(-) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/pom.xml (97%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java (91%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java (77%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java (90%) create mode 100644 spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPropertiesNoMount.java create mode 100644 spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/main/resources/application-no-mount.yaml (84%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/main/resources/application-with-bootstrap.yaml (55%) create mode 100644 spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java (70%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java (96%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/PollingReloadConfigMapMountIT.java => fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ReloadConfigMapMountIT.java} (70%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/resources/configmap.yaml (100%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/resources/deployment.yaml (56%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/resources/ingress.yaml (61%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/resources/logback-test.xml (100%) create mode 100644 spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/configmap-mount.yaml rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-fabric8-client-configmap-polling-reload => fabric8-client-configmap-polling-and-import-reload}/src/test/resources/mount/deployment-mount.yaml (52%) create mode 100644 spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/service.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-mount.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/configmap-mount.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/service.yaml create mode 100644 spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml create mode 100644 spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/service.yaml diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index d6e8d2d5fb..a6d1ece3d6 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -53,8 +53,7 @@ |spring.cloud.kubernetes.config.include-profile-specific-sources | `+++true+++` | |spring.cloud.kubernetes.config.labels | | |spring.cloud.kubernetes.config.name | | -|spring.cloud.kubernetes.config.namespace | | -|spring.cloud.kubernetes.config.paths | | +|spring.cloud.kubernetes.config.namespace | | |spring.cloud.kubernetes.config.retry | | |spring.cloud.kubernetes.config.sources | | |spring.cloud.kubernetes.config.use-name-as-prefix | `+++false+++` | @@ -107,10 +106,9 @@ |spring.cloud.kubernetes.secrets.include-profile-specific-sources | `+++true+++` | |spring.cloud.kubernetes.secrets.labels | | |spring.cloud.kubernetes.secrets.name | | -|spring.cloud.kubernetes.secrets.namespace | | -|spring.cloud.kubernetes.secrets.paths | | +|spring.cloud.kubernetes.secrets.namespace | | |spring.cloud.kubernetes.secrets.retry | | |spring.cloud.kubernetes.secrets.sources | | |spring.cloud.kubernetes.secrets.use-name-as-prefix | `+++false+++` | -|=== \ No newline at end of file +|=== diff --git a/docs/src/main/asciidoc/property-source-config.adoc b/docs/src/main/asciidoc/property-source-config.adoc index 5c5d459079..22253c03af 100644 --- a/docs/src/main/asciidoc/property-source-config.adoc +++ b/docs/src/main/asciidoc/property-source-config.adoc @@ -579,25 +579,82 @@ for individual ones; the latter having a higher priority. NOTE: You should check the security configuration section. To access config maps from inside a pod you need to have the correct Kubernetes service accounts, roles and role bindings. -Another option for using `ConfigMap` instances is to mount them into the Pod by running the Spring Cloud Kubernetes application -and having Spring Cloud Kubernetes read them from the file system. Please note that this feature is deprecated and will be removed in a future release (Use `spring.config.import` instead). -This behavior is controlled by the `spring.cloud.kubernetes.config.paths` property. You can use it in -addition to or instead of the mechanism described earlier. -`spring.cloud.kubernetes.config.paths` expects a List of full paths to each property file, because directories are not being recursively parsed. For example: +Another option for using `ConfigMap` (or `Secrets`) instances is to mount them into the Pod and use `spring.config.import` support. For example, suppose that you have such a ConfigMap deployed: ``` -spring: - cloud: - kubernetes: - config: - paths: - - /tmp/application.properties - - /var/application.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: my-configmap + namespace: default +data: + from.properties: 'as-mount-initial' +``` + +You can mount it in the pod (see https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#populate-a-volume-with-data-stored-in-a-configmap): + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-pod +spec: + selector: + matchLabels: + app: my-app + template: + metadata: + labels: + app: my-app + spec: + containers: + - name: .... + image: .... + volumeMounts: + - name: my-configmap + mountPath: /tmp/props + volumes: + - name: my-configmap + configMap: + name: my-configmap + items: + - key: 'from.properties' + path: key +``` + +And then in `application.properties` have a property: + +``` +spring.config.import: "configtree:/tmp/" +``` + +This will result in a Property Source being created that will hold: `props.key=as-mount-initial`. + +NOTE: Using `spring.config.import`, automatic reload +functionality will work only using configuration watcher image. Or you will need to make a `POST` request to the `/actuator/refresh` endpoint or +restart/redeploy the application manually. There is a small caveat here: kubernetes will update the value of the file once the ConfigMap changes, but that does not happen instantly. It might take up to two minutes before you see the changed values. + +To better understand the note above, consider the example: + +- there is a ConfigMap that stores `from.properties: 'as-mount-initial'` +- that config map is mounted into `/tmp` (just like the example above) +- you use `spring.config.import: configtree:/tmp` +- you have a `@ConfigurationProperty` class: + +``` +@ConfigurationProperties("props") +public class ConfigMapProperties { + // getters, setters + private String key; +} +``` + +Once you start the application, the value read by `ConfigMapProperties::getKey` will be `as-mount-initial`. Now consider the case that you change `from.properties: 'as-mount-changed'` inside the ConfigMap and trigger a restart (manually or automatic via configuration watcher). The value read by: `ConfigMapProperties::getkey` might _not_ be `as-mount-changed`. This is because it takes up to two minutes for kubernetes to update the value from the ConfigMap to the mounted volume. In the case when you are using configuration watcher, things will work as expected, because there we have: + +``` +spring.cloud.kubernetes.configuration.watcher.refreshDelay = Duration.ofMillis(120000); ``` -NOTE: If you use `spring.cloud.kubernetes.config.paths` or `spring.cloud.kubernetes.secrets.path` the automatic reload -functionality will not work. You will need to make a `POST` request to the `/actuator/refresh` endpoint or -restart/redeploy the application. [#config-map-fail-fast] In some cases, your application may be unable to load some of your `ConfigMaps` using the Kubernetes API. @@ -622,7 +679,6 @@ by setting `spring.cloud.kubernetes.config.retry.enabled=false`. | `spring.cloud.kubernetes.config.enabled` | `Boolean` | `true` | Enable ConfigMaps `PropertySource` | `spring.cloud.kubernetes.config.name` | `String` | `${spring.application.name}` | Sets the name of `ConfigMap` to look up | `spring.cloud.kubernetes.config.namespace` | `String` | Client namespace | Sets the Kubernetes namespace where to lookup -| `spring.cloud.kubernetes.config.paths` | `List` | `null` | Sets the paths where `ConfigMap` instances are mounted | `spring.cloud.kubernetes.config.enableApi` | `Boolean` | `true` | Enable or disable consuming `ConfigMap` instances through APIs | `spring.cloud.kubernetes.config.fail-fast` | `Boolean` | `false` | Enable or disable failing the application start-up when an error occurred while loading a `ConfigMap` | `spring.cloud.kubernetes.config.retry.enabled` | `Boolean` | `true` | Enable or disable config retry. @@ -716,24 +772,6 @@ spec: You can select the Secrets to consume in a number of ways: -. By listing the directories where secrets are mapped: -+ -==== -[source,bash] ----- --Dspring.cloud.kubernetes.secrets.paths=/etc/secrets/db-secret,etc/secrets/postgresql ----- -==== -+ -If you have all the secrets mapped to a common root, you can set them like: -+ -==== -[source,bash] ----- --Dspring.cloud.kubernetes.secrets.paths=/etc/secrets ----- -==== - . By setting a named secret: + ==== @@ -805,7 +843,6 @@ by setting `spring.cloud.kubernetes.secrets.retry.enabled=false`. | `spring.cloud.kubernetes.secrets.name` | `String` | `${spring.application.name}` | Sets the name of the secret to look up | `spring.cloud.kubernetes.secrets.namespace` | `String` | Client namespace | Sets the Kubernetes namespace where to look up | `spring.cloud.kubernetes.secrets.labels` | `Map` | `null` | Sets the labels used to lookup secrets -| `spring.cloud.kubernetes.secrets.paths` | `List` | `null` | Sets the paths where secrets are mounted (example 1) | `spring.cloud.kubernetes.secrets.enableApi` | `Boolean` | `false` | Enables or disables consuming secrets through APIs (examples 2 and 3) | `spring.cloud.kubernetes.secrets.fail-fast` | `Boolean` | `false` | Enable or disable failing the application start-up when an error occurred while loading a `Secret` | `spring.cloud.kubernetes.secrets.retry.enabled` | `Boolean` | `true` | Enable or disable secrets retry. @@ -819,8 +856,6 @@ Notes: * The `spring.cloud.kubernetes.secrets.labels` property behaves as defined by https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding#map-based-binding[Map-based binding]. -* The `spring.cloud.kubernetes.secrets.paths` property behaves as defined by -https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-Configuration-Binding#collection-based-binding[Collection-based binding]. * Access to secrets through the API may be restricted for security reasons. The preferred way is to mount secrets to the Pod. You can find an example of an application that uses secrets (though it has not been updated to use the new `spring-cloud-kubernetes` project) at diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java index 02f1c60d83..bd25b038a9 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadUtil.java @@ -93,7 +93,7 @@ else if (source instanceof BootstrapPropertySource bootstrapPropertySource) { } } - LOG.debug(() -> "findPropertySources : " + managedSources.stream().map(PropertySource::getName).toList()); + LOG.debug(() -> "sources from findPropertySources : " + managedSources); return managedSources; } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/pom.xml similarity index 97% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/pom.xml index adad09d71a..35f1d021aa 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/pom.xml @@ -9,7 +9,7 @@ 4.0.0 - spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + fabric8-client-configmap-polling-and-import-reload diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java similarity index 91% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java index 8594a99cc6..1b267f4a93 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java @@ -25,7 +25,7 @@ */ @SpringBootApplication -@EnableConfigurationProperties(ConfigMapProperties.class) +@EnableConfigurationProperties({ ConfigMapProperties.class, ConfigMapPropertiesNoMount.class }) public class ConfigMapApp { public static void main(String[] args) { diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java similarity index 77% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java index c59aa7fc93..b6206006a8 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java @@ -27,8 +27,11 @@ public class ConfigMapController { private final ConfigMapProperties properties; - public ConfigMapController(ConfigMapProperties properties) { + private final ConfigMapPropertiesNoMount propertiesNoMount; + + public ConfigMapController(ConfigMapProperties properties, ConfigMapPropertiesNoMount propertiesNoMount) { this.properties = properties; + this.propertiesNoMount = propertiesNoMount; } @GetMapping("/key") @@ -36,4 +39,9 @@ public String key() { return properties.getKey(); } + @GetMapping("/key-no-mount") + public String keyNoMount() { + return propertiesNoMount.getKey(); + } + } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java similarity index 90% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java index 0b6f7e61d7..437859d026 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapProperties.java @@ -21,7 +21,7 @@ /** * @author wind57 */ -@ConfigurationProperties("from.properties") +@ConfigurationProperties("props") public class ConfigMapProperties { private String key; @@ -30,8 +30,8 @@ public String getKey() { return key; } - public void setKey(String key1) { - this.key = key1; + public void setKey(String key) { + this.key = key; } } diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPropertiesNoMount.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPropertiesNoMount.java new file mode 100644 index 0000000000..60ef742707 --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPropertiesNoMount.java @@ -0,0 +1,37 @@ +/* + * Copyright 2013-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.fabric8.configmap.polling.reload; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @author wind57 + */ +@ConfigurationProperties("from.properties") +public class ConfigMapPropertiesNoMount { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + +} diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml new file mode 100644 index 0000000000..39f43104d0 --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml @@ -0,0 +1,24 @@ +spring: + application: + name: poll-reload-mount + cloud: + kubernetes: + reload: + enabled: true + monitoring-config-maps: true + strategy: shutdown + + config: + import: "kubernetes:,configtree:/tmp/" + +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-no-mount.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-no-mount.yaml similarity index 84% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-no-mount.yaml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-no-mount.yaml index baf0f12d35..56038d0242 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-no-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-no-mount.yaml @@ -13,6 +13,4 @@ spring: enabled: true monitoring-config-maps: true strategy: shutdown - mode: polling - period: 5000 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-with-bootstrap.yaml similarity index 55% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-with-bootstrap.yaml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-with-bootstrap.yaml index c997322d16..5b999c3ea2 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-with-bootstrap.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-with-bootstrap.yaml @@ -7,6 +7,16 @@ spring: enabled: true monitoring-config-maps: true strategy: shutdown - mode: polling - period: 5000 + +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml new file mode 100644 index 0000000000..488b2e839c --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml @@ -0,0 +1,3 @@ +spring: + config: + import: "configtree:/tmp/" diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java similarity index 70% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java index c41b6beb80..3ee9afaef9 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java @@ -19,6 +19,7 @@ import java.io.InputStream; import java.time.Duration; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -34,7 +35,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Container; import org.testcontainers.k3s.K3sContainer; import reactor.netty.http.client.HttpClient; import reactor.util.retry.Retry; @@ -51,7 +51,9 @@ public class BootstrapEnabledPollingReloadConfigMapMountIT { - private static final String IMAGE_NAME = "spring-cloud-kubernetes-fabric8-client-configmap-polling-reload"; + private static final String IMAGE_NAME = "fabric8-client-configmap-polling-and-import-reload"; + + private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; private static final String NAMESPACE = "default"; @@ -66,40 +68,40 @@ static void beforeAll() throws Exception { K3S.start(); Commons.validateImage(IMAGE_NAME, K3S); Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); + + Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util = new Util(K3S); client = util.client(); util.setUp(NAMESPACE); + util.configWatcher(Phase.CREATE); manifests(Phase.CREATE); } @AfterAll static void after() throws Exception { manifests(Phase.DELETE); + util.configWatcher(Phase.DELETE); Commons.cleanUp(IMAGE_NAME, K3S); + Commons.cleanUp(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); } /** *
-	 *     - we have bootstrap enabled, which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
-	 *     - there are no explicit config maps to search for, but what we will also read,
-	 *     	 is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - the property above means that at the moment we will be searching for config maps that only
+	 *       match the application name, in this specific test there is no such config map.
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ @Test void test() { - String logs = logs(); - // (1) - Assertions.assertTrue(logs.contains("paths property sources : [/tmp/application.properties]")); - // (2) - Assertions.assertTrue(logs.contains("will add file-based property source : /tmp/application.properties")); - // (3) WebClient webClient = builder().baseUrl("http://localhost/key").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) .block(); @@ -107,11 +109,23 @@ void test() { // we first read the initial value from the configmap Assertions.assertEquals("as-mount-initial", result); - // replace data in configmap and wait for k8s to pick it up - // our polling will detect that and restart the app + // replace data in configmap and wait for configuration watcher to pick up the + // change InputStream configMapStream = util.inputStream("mount/configmap-mount.yaml"); ConfigMap configMap = client.configMaps().load(configMapStream).get(); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of("from.properties", "as-mount-changed")); + + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>(configMap.getMetadata().getLabels()); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMap.getMetadata().setLabels(existingLabels); + + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>(configMap.getMetadata().getAnnotations()); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", + "fabric8-client-configmap-polling-and-import-reload"); + configMap.getMetadata().setAnnotations(existingAnnotations); + client.configMaps().inNamespace("default").resource(configMap).createOrReplace(); await().timeout(Duration.ofSeconds(360)).until(() -> webClient.method(HttpMethod.GET).retrieve() @@ -141,20 +155,8 @@ private static void manifests(Phase phase) { EnvVar enabledBootstrap = new EnvVarBuilder().withName("SPRING_CLOUD_BOOTSTRAP_ENABLED").withValue("TRUE") .build(); - EnvVar debugLevelReloadCommons = new EnvVarBuilder() - .withName("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD").withValue("DEBUG") - .build(); - EnvVar debugLevelConfig = new EnvVarBuilder() - .withName("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG").withValue("DEBUG") - .build(); - EnvVar debugLevelCommons = new EnvVarBuilder() - .withName("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS").withValue("DEBUG").build(); - existing.add(withBootstrapActiveProfile); existing.add(enabledBootstrap); - existing.add(debugLevelReloadCommons); - existing.add(debugLevelCommons); - existing.add(debugLevelConfig); deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(existing); if (phase.equals(Phase.CREATE)) { @@ -176,18 +178,4 @@ private RetryBackoffSpec retrySpec() { return Retry.fixedDelay(60, Duration.ofSeconds(1)).filter(Objects::nonNull); } - private String logs() { - try { - String appPodName = K3S.execInContainer("sh", "-c", - "kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout(); - - Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim()); - return execResult.getStdout(); - } - catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java similarity index 96% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java index 54c74ab944..f006ff6977 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapPollingReloadIT.java @@ -55,7 +55,7 @@ */ class ConfigMapPollingReloadIT { - private static final String IMAGE_NAME = "spring-cloud-kubernetes-fabric8-client-configmap-polling-reload"; + private static final String IMAGE_NAME = "fabric8-client-configmap-polling-and-import-reload"; private static final String NAMESPACE = "default"; @@ -84,7 +84,7 @@ static void after() throws Exception { @Test void test() { - WebClient webClient = builder().baseUrl("http://localhost/key").build(); + WebClient webClient = builder().baseUrl("http://localhost/key-no-mount").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) .block(); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/PollingReloadConfigMapMountIT.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ReloadConfigMapMountIT.java similarity index 70% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/PollingReloadConfigMapMountIT.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ReloadConfigMapMountIT.java index e05e48d6ae..47de47b8b1 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/PollingReloadConfigMapMountIT.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ReloadConfigMapMountIT.java @@ -19,6 +19,7 @@ import java.io.InputStream; import java.time.Duration; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -34,7 +35,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Container; import org.testcontainers.k3s.K3sContainer; import reactor.netty.http.client.HttpClient; import reactor.util.retry.Retry; @@ -52,9 +52,11 @@ /** * @author wind57 */ -class PollingReloadConfigMapMountIT { +class ReloadConfigMapMountIT { - private static final String IMAGE_NAME = "spring-cloud-kubernetes-fabric8-client-configmap-polling-reload"; + private static final String IMAGE_NAME = "fabric8-client-configmap-polling-and-import-reload"; + + private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; private static final String NAMESPACE = "default"; @@ -69,41 +71,40 @@ static void beforeAll() throws Exception { K3S.start(); Commons.validateImage(IMAGE_NAME, K3S); Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); + + Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util = new Util(K3S); client = util.client(); util.setUp(NAMESPACE); + util.configWatcher(Phase.CREATE); manifests(Phase.CREATE); } @AfterAll - static void after() throws Exception { + static void afterAll() throws Exception { manifests(Phase.DELETE); Commons.cleanUp(IMAGE_NAME, K3S); + Commons.cleanUp(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util.configWatcher(Phase.DELETE); } /** *
-	 *     - we have "spring.config.import: kubernetes", which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
 	 *     - the property above means that at the moment we will be searching for config maps that only
 	 *       match the application name, in this specific test there is no such config map.
-	 *     - what we will also read, is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ @Test void test() { - String logs = logs(); - // (1) - Assertions.assertTrue(logs.contains("paths property sources : [/tmp/application.properties]")); - // (2) - Assertions.assertTrue(logs.contains("will add file-based property source : /tmp/application.properties")); - // (3) WebClient webClient = builder().baseUrl("http://localhost/key").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) .block(); @@ -112,10 +113,22 @@ void test() { Assertions.assertEquals("as-mount-initial", result); // replace data in configmap and wait for k8s to pick it up - // our polling will detect that and restart the app + // our configuration watcher will schedule a http refresh event InputStream configMapStream = util.inputStream("mount/configmap-mount.yaml"); ConfigMap configMap = client.configMaps().load(configMapStream).get(); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of("from.properties", "as-mount-changed")); + + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>(configMap.getMetadata().getLabels()); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMap.getMetadata().setLabels(existingLabels); + + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>(configMap.getMetadata().getAnnotations()); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", + "fabric8-client-configmap-polling-and-import-reload"); + configMap.getMetadata().setAnnotations(existingAnnotations); + client.configMaps().inNamespace("default").resource(configMap).createOrReplace(); await().timeout(Duration.ofSeconds(360)).until(() -> webClient.method(HttpMethod.GET).retrieve() @@ -144,20 +157,8 @@ private static void manifests(Phase phase) { EnvVar disableBootstrap = new EnvVarBuilder().withName("SPRING_CLOUD_BOOTSTRAP_ENABLED").withValue("FALSE") .build(); - EnvVar debugLevelReloadCommons = new EnvVarBuilder() - .withName("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD").withValue("DEBUG") - .build(); - EnvVar debugLevelConfig = new EnvVarBuilder() - .withName("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG").withValue("DEBUG") - .build(); - EnvVar debugLevelCommons = new EnvVarBuilder() - .withName("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS").withValue("DEBUG").build(); - existing.add(mountActiveProfile); existing.add(disableBootstrap); - existing.add(debugLevelReloadCommons); - existing.add(debugLevelCommons); - existing.add(debugLevelConfig); deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(existing); if (phase.equals(Phase.CREATE)) { @@ -179,18 +180,4 @@ private RetryBackoffSpec retrySpec() { return Retry.fixedDelay(60, Duration.ofSeconds(1)).filter(Objects::nonNull); } - private String logs() { - try { - String appPodName = K3S.execInContainer("sh", "-c", - "kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout(); - - Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim()); - return execResult.getStdout(); - } - catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/configmap.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/configmap.yaml similarity index 100% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/configmap.yaml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/configmap.yaml diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/deployment.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/deployment.yaml similarity index 56% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/deployment.yaml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/deployment.yaml index 39f4572c07..7217000630 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/deployment.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/deployment.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: spring-cloud-kubernetes-fabric8-client-configmap-deployment-polling-reload + name: fabric8-client-configmap-deployment-polling-and-import-reload spec: selector: matchLabels: - app: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + app: fabric8-client-configmap-polling-and-import-reload template: metadata: labels: - app: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + app: fabric8-client-configmap-polling-and-import-reload spec: serviceAccountName: spring-cloud-kubernetes-serviceaccount containers: - - name: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload - image: docker.io/springcloud/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + - name: fabric8-client-configmap-polling-and-import-reload + image: docker.io/springcloud/fabric8-client-configmap-polling-and-import-reload imagePullPolicy: IfNotPresent readinessProbe: httpGet: diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/ingress.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml similarity index 61% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/ingress.yaml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml index fd53e216c1..6874179aa4 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/ingress.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml @@ -1,7 +1,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: spring-cloud-kubernetes-fabric8-client-configmap-ingress-polling-reload + name: fabric8-client-configmap-ingress-polling-and-import-reload namespace: default spec: rules: @@ -11,6 +11,6 @@ spec: pathType: Prefix backend: service: - name: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + name: fabric8-client-configmap-polling-and-import-reload port: number: 8080 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/logback-test.xml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/logback-test.xml similarity index 100% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/logback-test.xml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/logback-test.xml diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/configmap-mount.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/configmap-mount.yaml new file mode 100644 index 0000000000..38cdd15ecb --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/configmap-mount.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: reload-as-mount + namespace: default +data: + from.properties: 'as-mount-initial' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/deployment-mount.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/deployment-mount.yaml similarity index 52% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/deployment-mount.yaml rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/deployment-mount.yaml index 4678398618..ff641ddc8c 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/deployment-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/mount/deployment-mount.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: spring-cloud-kubernetes-fabric8-client-configmap-deployment-polling-reload + name: fabric8-client-configmap-deployment-polling-and-import-reload spec: selector: matchLabels: - app: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + app: fabric8-client-configmap-polling-and-import-reload template: metadata: labels: - app: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + app: fabric8-client-configmap-polling-and-import-reload spec: serviceAccountName: spring-cloud-kubernetes-serviceaccount containers: - - name: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload - image: docker.io/springcloud/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + - name: fabric8-client-configmap-polling-and-import-reload + image: docker.io/springcloud/fabric8-client-configmap-polling-and-import-reload imagePullPolicy: IfNotPresent readinessProbe: httpGet: @@ -29,9 +29,13 @@ spec: volumeMounts: - name: config-map-volume - mountPath: /tmp + mountPath: /tmp/props volumes: - name: config-map-volume configMap: - name: poll-reload-as-mount + name: reload-as-mount + items: + # this will result in 'props.key' being populated with the value from 'from.properties' + - key: 'from.properties' + path: key diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/service.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/service.yaml new file mode 100644 index 0000000000..b948bea582 --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: fabric8-client-configmap-polling-and-import-reload + name: fabric8-client-configmap-polling-and-import-reload +spec: + ports: + - name: http + port: 8080 + targetPort: 8080 + selector: + app: fabric8-client-configmap-polling-and-import-reload + type: ClusterIP diff --git a/spring-cloud-kubernetes-integration-tests/pom.xml b/spring-cloud-kubernetes-integration-tests/pom.xml index 06f512dd62..6ed28ea537 100644 --- a/spring-cloud-kubernetes-integration-tests/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/pom.xml @@ -52,7 +52,7 @@ spring-cloud-kubernetes-fabric8-istio-it spring-cloud-kubernetes-fabric8-client-discovery spring-cloud-kubernetes-fabric8-client-loadbalancer - spring-cloud-kubernetes-fabric8-client-configmap-polling-reload + fabric8-client-configmap-polling-and-import-reload spring-cloud-kubernetes-fabric8-client-secrets-event-reload spring-cloud-kubernetes-fabric8-client-configmap-event-reload diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-mount.yaml deleted file mode 100644 index cd1765f5c8..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/application-mount.yaml +++ /dev/null @@ -1,17 +0,0 @@ -spring: - application: - name: poll-reload-mount - cloud: - kubernetes: - reload: - enabled: true - monitoring-config-maps: true - strategy: shutdown - mode: polling - period: 5000 - config: - paths: - - /tmp/application.properties - config: - import: "kubernetes:" - diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml deleted file mode 100644 index 0aed2eb9dd..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - cloud: - kubernetes: - config: - paths: - - /tmp/application.properties diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/configmap-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/configmap-mount.yaml deleted file mode 100644 index f2ea29a5c2..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/mount/configmap-mount.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: poll-reload-as-mount - namespace: default -data: - application.properties: | - from.properties.key=as-mount-initial diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/service.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/service.yaml deleted file mode 100644 index 2995e2b6b0..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/src/test/resources/service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload - name: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload -spec: - ports: - - name: http - port: 8080 - targetPort: 8080 - selector: - app: spring-cloud-kubernetes-fabric8-client-configmap-polling-reload - type: ClusterIP diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java index 748f6203d9..7d95a6f4ca 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java @@ -277,6 +277,22 @@ public void wiremock(String namespace, String path, Phase phase) { } + public void configWatcher(Phase phase) { + + InputStream deploymentStream = inputStream("config-watcher/deployment.yaml"); + InputStream serviceStream = inputStream("config-watcher/service.yaml"); + + Deployment deployment = client.apps().deployments().load(deploymentStream).get(); + Service service = client.services().load(serviceStream).get(); + + if (phase.equals(Phase.CREATE)) { + createAndWait("default", deployment.getMetadata().getName(), deployment, service, null, true); + } + else if (phase.equals(Phase.DELETE)) { + deleteAndWait("default", deployment, service, null); + } + } + private void waitForSecret(String namespace, Secret secret, Phase phase) { String secretName = secretName(secret); await().pollInterval(Duration.ofSeconds(1)).atMost(600, TimeUnit.SECONDS).until(() -> { diff --git a/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml new file mode 100644 index 0000000000..1a13a7dc76 --- /dev/null +++ b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: spring-cloud-kubernetes-configuration-watcher-deployment +spec: + selector: + matchLabels: + app: spring-cloud-kubernetes-configuration-watcher + template: + metadata: + labels: + app: spring-cloud-kubernetes-configuration-watcher + spec: + serviceAccountName: spring-cloud-kubernetes-serviceaccount + containers: + - name: spring-cloud-kubernetes-configuration-watcher + image: docker.io/springcloud/spring-cloud-kubernetes-configuration-watcher + imagePullPolicy: IfNotPresent + readinessProbe: + httpGet: + port: 8888 + path: /actuator/health/readiness + livenessProbe: + httpGet: + port: 8888 + path: /actuator/health/liveness + ports: + - containerPort: 8888 + env: + - name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CONFIGURATION_WATCHER + value: DEBUG + - name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CLIENT_CONFIG_RELOAD + value: DEBUG + - name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD + value: DEBUG + #- name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY + # value: 100 diff --git a/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/service.yaml b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/service.yaml new file mode 100644 index 0000000000..c8496317b1 --- /dev/null +++ b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: spring-cloud-kubernetes-configuration-watcher + name: spring-cloud-kubernetes-configuration-watcher +spec: + ports: + - name: http + port: 8888 + targetPort: 8888 + selector: + app: spring-cloud-kubernetes-configuration-watcher + type: ClusterIP From 2b1a8a07efcd33abdbf9491a73f8725f3f623fb0 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 10 May 2023 22:05:31 +0300 Subject: [PATCH 010/100] more integration tests --- ...otstrapEnabledReloadConfigMapMountIT.java} | 2 +- .../pom.xml | 2 +- .../polling/reload/ConfigMapApp.java | 2 +- .../polling/reload/ConfigMapController.java | 10 ++- .../polling/reload/ConfigMapProperties.java | 6 +- .../reload/ConfigMapPropertiesNoMount.java | 37 +++++++++ .../src/main/resources/application-mount.yaml | 23 ++++++ .../resources/application-with-bootstrap.yaml | 13 ++- .../resources/bootstrap-with-bootstrap.yaml | 3 + ...otstrapEnabledReloadConfigMapMountIT.java} | 81 +++++++++---------- .../reload/ReloadConfigMapMountIT.java} | 78 ++++++++---------- .../src/test/resources/configmap-mount.yaml | 7 ++ .../src/test/resources/deployment-mount.yaml | 18 +++-- .../src/test/resources/ingress.yaml | 4 +- .../src/test/resources/logback-test.xml | 0 .../src/test/resources/service.yaml | 14 ++++ .../pom.xml | 2 +- .../src/main/resources/application-mount.yaml | 17 ---- .../resources/bootstrap-with-bootstrap.yaml | 6 -- .../src/test/resources/configmap-mount.yaml | 8 -- .../src/test/resources/service.yaml | 14 ---- .../tests/commons/native_client/Util.java | 13 +++ 22 files changed, 209 insertions(+), 151 deletions(-) rename spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/{BootstrapEnabledPollingReloadConfigMapMountIT.java => BootstrapEnabledReloadConfigMapMountIT.java} (99%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/pom.xml (97%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java (91%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java (77%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java (90%) create mode 100644 spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapPropertiesNoMount.java create mode 100644 spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/main/resources/application-with-bootstrap.yaml (55%) create mode 100644 spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java => kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java} (67%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/PollingReloadConfigMapMountIT.java => kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ReloadConfigMapMountIT.java} (69%) create mode 100644 spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/configmap-mount.yaml rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/test/resources/deployment-mount.yaml (52%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/test/resources/ingress.yaml (63%) rename spring-cloud-kubernetes-integration-tests/{spring-cloud-kubernetes-client-configmap-polling-reload => kubernetes-client-configmap-polling-and-import-reload}/src/test/resources/logback-test.xml (100%) create mode 100644 spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/service.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-mount.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/configmap-mount.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/service.yaml diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java similarity index 99% rename from spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java rename to spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java index 3ee9afaef9..e2d50939d8 100644 --- a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java @@ -49,7 +49,7 @@ import static org.awaitility.Awaitility.await; -public class BootstrapEnabledPollingReloadConfigMapMountIT { +public class BootstrapEnabledReloadConfigMapMountIT { private static final String IMAGE_NAME = "fabric8-client-configmap-polling-and-import-reload"; diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/pom.xml similarity index 97% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/pom.xml rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/pom.xml index 4f97d75c6b..acc2ffe206 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/pom.xml @@ -9,7 +9,7 @@ 3.0.3-SNAPSHOT - spring-cloud-kubernetes-client-configmap-polling-reload + kubernetes-client-configmap-polling-and-import-reload diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java similarity index 91% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java index 08f7065777..23d0024959 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java @@ -25,7 +25,7 @@ */ @SpringBootApplication -@EnableConfigurationProperties(ConfigMapProperties.class) +@EnableConfigurationProperties({ ConfigMapProperties.class, ConfigMapPropertiesNoMount.class }) public class ConfigMapApp { public static void main(String[] args) { diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java similarity index 77% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java index 7d8cbedfde..a6efd7be0e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java @@ -27,8 +27,11 @@ public class ConfigMapController { private final ConfigMapProperties properties; - public ConfigMapController(ConfigMapProperties properties) { + private final ConfigMapPropertiesNoMount propertiesNoMount; + + public ConfigMapController(ConfigMapProperties properties, ConfigMapPropertiesNoMount propertiesNoMount) { this.properties = properties; + this.propertiesNoMount = propertiesNoMount; } @GetMapping("/key") @@ -36,4 +39,9 @@ public String key() { return properties.getKey(); } + @GetMapping("/key-no-mount") + public String keyNoMount() { + return propertiesNoMount.getKey(); + } + } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java similarity index 90% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java index c4c11b438b..7d170a842b 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapProperties.java @@ -21,7 +21,7 @@ /** * @author wind57 */ -@ConfigurationProperties("from.properties") +@ConfigurationProperties("props") public class ConfigMapProperties { private String key; @@ -30,8 +30,8 @@ public String getKey() { return key; } - public void setKey(String key1) { - this.key = key1; + public void setKey(String key) { + this.key = key; } } diff --git a/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapPropertiesNoMount.java b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapPropertiesNoMount.java new file mode 100644 index 0000000000..1705109394 --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapPropertiesNoMount.java @@ -0,0 +1,37 @@ +/* + * Copyright 2013-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.client.configmap.polling.reload; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @author wind57 + */ +@ConfigurationProperties("from.properties") +public class ConfigMapPropertiesNoMount { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + +} diff --git a/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml new file mode 100644 index 0000000000..a5757adfd6 --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml @@ -0,0 +1,23 @@ +spring: + application: + name: poll-reload-mount + cloud: + kubernetes: + reload: + enabled: true + monitoring-config-maps: true + strategy: shutdown + config: + import: "kubernetes:,configtree:/tmp/" + +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-with-bootstrap.yaml similarity index 55% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-with-bootstrap.yaml rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-with-bootstrap.yaml index c997322d16..8770fd3964 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-with-bootstrap.yaml +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/application-with-bootstrap.yaml @@ -7,6 +7,15 @@ spring: enabled: true monitoring-config-maps: true strategy: shutdown - mode: polling - period: 5000 +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml new file mode 100644 index 0000000000..488b2e839c --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/resources/bootstrap-with-bootstrap.yaml @@ -0,0 +1,3 @@ +spring: + config: + import: "configtree:/tmp/" diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java similarity index 67% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java index dd2502de4a..956d9cf0d1 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledPollingReloadConfigMapMountIT.java +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/BootstrapEnabledReloadConfigMapMountIT.java @@ -18,6 +18,7 @@ import java.time.Duration; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -33,7 +34,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Container; import org.testcontainers.k3s.K3sContainer; import reactor.netty.http.client.HttpClient; import reactor.util.retry.Retry; @@ -51,9 +51,11 @@ /** * @author wind57 */ -class BootstrapEnabledPollingReloadConfigMapMountIT { +class BootstrapEnabledReloadConfigMapMountIT { - private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-configmap-polling-reload"; + private static final String IMAGE_NAME = "kubernetes-client-configmap-polling-and-import-reload"; + + private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; private static final String NAMESPACE = "default"; @@ -66,42 +68,43 @@ class BootstrapEnabledPollingReloadConfigMapMountIT { @BeforeAll static void beforeAll() throws Exception { K3S.start(); + Commons.validateImage(IMAGE_NAME, K3S); Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); + + Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util = new Util(K3S); coreV1Api = new CoreV1Api(); util.setUp(NAMESPACE); + util.configWatcher(Phase.CREATE); manifests(Phase.CREATE); } @AfterAll static void after() throws Exception { manifests(Phase.DELETE); + util.configWatcher(Phase.DELETE); Commons.cleanUp(IMAGE_NAME, K3S); + Commons.cleanUp(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); } /** *
-	 *     - we have bootstrap enabled, which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
-	 *     - there are no explicit config maps to search for, but what we will also read,
-	 *     	 is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - the property above means that at the moment we will be searching for config maps that only
+	 *       match the application name, in this specific test there is no such config map.
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ @Test void test() throws Exception { - String logs = logs(); - // (1) - Assertions.assertTrue(logs.contains("paths property sources : [/tmp/application.properties]")); - // (2) - Assertions.assertTrue(logs.contains("will add file-based property source : /tmp/application.properties")); - // (3) WebClient webClient = builder().baseUrl("http://localhost/key").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) .block(); @@ -112,10 +115,24 @@ void test() throws Exception { // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); - coreV1Api.replaceNamespacedConfigMap("poll-reload-as-mount", NAMESPACE, configMap, null, null, null, null); + configMap.setData(Map.of("from.properties", "as-mount-changed")); + + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMap.getMetadata().setLabels(existingLabels); + + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getAnnotations()).orElse(Map.of())); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", + "kubernetes-client-configmap-polling-and-import-reload"); + configMap.getMetadata().setAnnotations(existingAnnotations); + + coreV1Api.replaceNamespacedConfigMap("reload-as-mount", NAMESPACE, configMap, null, null, null, null); - await().timeout(Duration.ofSeconds(180)).until(() -> webClient.method(HttpMethod.GET).retrieve() + await().timeout(Duration.ofSeconds(360)).until(() -> webClient.method(HttpMethod.GET).retrieve() .bodyToMono(String.class).retryWhen(retrySpec()).block().equals("as-mount-changed")); } @@ -136,18 +153,8 @@ private static void manifests(Phase phase) { V1EnvVar mountActiveProfile = new V1EnvVar().name("SPRING_PROFILES_ACTIVE").value("with-bootstrap"); V1EnvVar disableBootstrap = new V1EnvVar().name("SPRING_CLOUD_BOOTSTRAP_ENABLED").value("TRUE"); - V1EnvVar debugLevelReloadCommons = new V1EnvVar() - .name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD").value("DEBUG"); - V1EnvVar debugLevelConfig = new V1EnvVar() - .name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG").value("DEBUG"); - V1EnvVar debugLevelCommons = new V1EnvVar().name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS") - .value("DEBUG"); - existing.add(mountActiveProfile); existing.add(disableBootstrap); - existing.add(debugLevelReloadCommons); - existing.add(debugLevelCommons); - existing.add(debugLevelConfig); deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(existing); if (phase.equals(Phase.CREATE)) { @@ -169,18 +176,4 @@ private RetryBackoffSpec retrySpec() { return Retry.fixedDelay(60, Duration.ofSeconds(1)).filter(Objects::nonNull); } - private String logs() { - try { - String appPodName = K3S.execInContainer("sh", "-c", - "kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout(); - - Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim()); - return execResult.getStdout(); - } - catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/PollingReloadConfigMapMountIT.java b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ReloadConfigMapMountIT.java similarity index 69% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/PollingReloadConfigMapMountIT.java rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ReloadConfigMapMountIT.java index cb366fc398..73d5c914d4 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/PollingReloadConfigMapMountIT.java +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ReloadConfigMapMountIT.java @@ -18,6 +18,7 @@ import java.time.Duration; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -33,7 +34,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Container; import org.testcontainers.k3s.K3sContainer; import reactor.netty.http.client.HttpClient; import reactor.util.retry.Retry; @@ -51,9 +51,11 @@ /** * @author wind57 */ -class PollingReloadConfigMapMountIT { +class ReloadConfigMapMountIT { - private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-configmap-polling-reload"; + private static final String IMAGE_NAME = "kubernetes-client-configmap-polling-and-import-reload"; + + private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; private static final String NAMESPACE = "default"; @@ -66,43 +68,43 @@ class PollingReloadConfigMapMountIT { @BeforeAll static void beforeAll() throws Exception { K3S.start(); + Commons.validateImage(IMAGE_NAME, K3S); Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); + + Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util = new Util(K3S); coreV1Api = new CoreV1Api(); util.setUp(NAMESPACE); + util.configWatcher(Phase.CREATE); manifests(Phase.CREATE); } @AfterAll static void after() throws Exception { manifests(Phase.DELETE); + util.configWatcher(Phase.DELETE); Commons.cleanUp(IMAGE_NAME, K3S); + Commons.cleanUp(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); } /** *
-	 *     - we have "spring.config.import: kubernetes", which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
 	 *     - the property above means that at the moment we will be searching for config maps that only
 	 *       match the application name, in this specific test there is no such config map.
-	 *     - what we will also read, is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ @Test void test() throws Exception { - String logs = logs(); - // (1) - Assertions.assertTrue(logs.contains("paths property sources : [/tmp/application.properties]")); - // (2) - Assertions.assertTrue(logs.contains("will add file-based property source : /tmp/application.properties")); - // (3) WebClient webClient = builder().baseUrl("http://localhost/key").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) .block(); @@ -113,10 +115,24 @@ void test() throws Exception { // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); - coreV1Api.replaceNamespacedConfigMap("poll-reload-as-mount", NAMESPACE, configMap, null, null, null, null); + configMap.setData(Map.of("from.properties", "as-mount-changed")); + + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMap.getMetadata().setLabels(existingLabels); + + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getAnnotations()).orElse(Map.of())); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", + "kubernetes-client-configmap-polling-and-import-reload"); + configMap.getMetadata().setAnnotations(existingAnnotations); + + coreV1Api.replaceNamespacedConfigMap("reload-as-mount", NAMESPACE, configMap, null, null, null, null); - await().timeout(Duration.ofSeconds(180)).until(() -> webClient.method(HttpMethod.GET).retrieve() + await().timeout(Duration.ofSeconds(360)).until(() -> webClient.method(HttpMethod.GET).retrieve() .bodyToMono(String.class).retryWhen(retrySpec()).block().equals("as-mount-changed")); } @@ -137,18 +153,8 @@ private static void manifests(Phase phase) { V1EnvVar mountActiveProfile = new V1EnvVar().name("SPRING_PROFILES_ACTIVE").value("mount"); V1EnvVar disableBootstrap = new V1EnvVar().name("SPRING_CLOUD_BOOTSTRAP_ENABLED").value("FALSE"); - V1EnvVar debugLevelReloadCommons = new V1EnvVar() - .name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD").value("DEBUG"); - V1EnvVar debugLevelConfig = new V1EnvVar() - .name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG").value("DEBUG"); - V1EnvVar debugLevelCommons = new V1EnvVar().name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS") - .value("DEBUG"); - existing.add(mountActiveProfile); existing.add(disableBootstrap); - existing.add(debugLevelReloadCommons); - existing.add(debugLevelCommons); - existing.add(debugLevelConfig); deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(existing); if (phase.equals(Phase.CREATE)) { @@ -170,18 +176,4 @@ private RetryBackoffSpec retrySpec() { return Retry.fixedDelay(60, Duration.ofSeconds(1)).filter(Objects::nonNull); } - private String logs() { - try { - String appPodName = K3S.execInContainer("sh", "-c", - "kubectl get pods -l app=" + IMAGE_NAME + " -o=name --no-headers | tr -d '\n'").getStdout(); - - Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim()); - return execResult.getStdout(); - } - catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - } diff --git a/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/configmap-mount.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/configmap-mount.yaml new file mode 100644 index 0000000000..38cdd15ecb --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/configmap-mount.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: reload-as-mount + namespace: default +data: + from.properties: 'as-mount-initial' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/deployment-mount.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/deployment-mount.yaml similarity index 52% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/deployment-mount.yaml rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/deployment-mount.yaml index 1405330238..356f835e2d 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/deployment-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/deployment-mount.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: spring-cloud-kubernetes-client-configmap-deployment-polling-reload + name: kubernetes-client-configmap-deployment-polling-and-import-reload spec: selector: matchLabels: - app: spring-cloud-kubernetes-client-configmap-polling-reload + app: kubernetes-client-configmap-polling-and-import-reload template: metadata: labels: - app: spring-cloud-kubernetes-client-configmap-polling-reload + app: kubernetes-client-configmap-polling-and-import-reload spec: serviceAccountName: spring-cloud-kubernetes-serviceaccount containers: - - name: spring-cloud-kubernetes-client-configmap-polling-reload - image: docker.io/springcloud/spring-cloud-kubernetes-client-configmap-polling-reload + - name: kubernetes-client-configmap-polling-and-import-reload + image: docker.io/springcloud/kubernetes-client-configmap-polling-and-import-reload imagePullPolicy: IfNotPresent readinessProbe: httpGet: @@ -29,9 +29,13 @@ spec: volumeMounts: - name: config-map-volume - mountPath: /tmp + mountPath: /tmp/props volumes: - name: config-map-volume configMap: - name: poll-reload-as-mount + name: reload-as-mount + items: + # this will result in 'props.key' being populated with the value from 'from.properties' + - key: 'from.properties' + path: key diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/ingress.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml similarity index 63% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/ingress.yaml rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml index 64f5bf4c02..4de10578ab 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/ingress.yaml +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml @@ -1,7 +1,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - name: spring-cloud-kubernetes-client-configmap-ingress-polling-reload + name: kubernetes-client-configmap-ingress-polling-and-import-reload namespace: default spec: rules: @@ -11,6 +11,6 @@ spec: pathType: Prefix backend: service: - name: spring-cloud-kubernetes-client-configmap-polling-reload + name: kubernetes-client-configmap-polling-and-import-reload port: number: 8080 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/logback-test.xml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/logback-test.xml similarity index 100% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/logback-test.xml rename to spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/logback-test.xml diff --git a/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/service.yaml b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/service.yaml new file mode 100644 index 0000000000..47379eb868 --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/test/resources/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app: kubernetes-client-configmap-polling-and-import-reload + name: kubernetes-client-configmap-polling-and-import-reload +spec: + ports: + - name: http + port: 8080 + targetPort: 8080 + selector: + app: kubernetes-client-configmap-polling-and-import-reload + type: ClusterIP diff --git a/spring-cloud-kubernetes-integration-tests/pom.xml b/spring-cloud-kubernetes-integration-tests/pom.xml index 6ed28ea537..c7b658b90b 100644 --- a/spring-cloud-kubernetes-integration-tests/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/pom.xml @@ -70,6 +70,6 @@ spring-cloud-kubernetes-client-catalog-watcher spring-cloud-kubernetes-client-discovery-it spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap - spring-cloud-kubernetes-client-configmap-polling-reload + kubernetes-client-configmap-polling-and-import-reload diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-mount.yaml deleted file mode 100644 index cd1765f5c8..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/application-mount.yaml +++ /dev/null @@ -1,17 +0,0 @@ -spring: - application: - name: poll-reload-mount - cloud: - kubernetes: - reload: - enabled: true - monitoring-config-maps: true - strategy: shutdown - mode: polling - period: 5000 - config: - paths: - - /tmp/application.properties - config: - import: "kubernetes:" - diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml deleted file mode 100644 index 0aed2eb9dd..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/main/resources/bootstrap-with-bootstrap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - cloud: - kubernetes: - config: - paths: - - /tmp/application.properties diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/configmap-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/configmap-mount.yaml deleted file mode 100644 index f2ea29a5c2..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/configmap-mount.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: poll-reload-as-mount - namespace: default -data: - application.properties: | - from.properties.key=as-mount-initial diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/service.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/service.yaml deleted file mode 100644 index 19d5acda8d..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-polling-reload/src/test/resources/service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app: spring-cloud-kubernetes-client-configmap-polling-reload - name: spring-cloud-kubernetes-client-configmap-polling-reload -spec: - ports: - - name: http - port: 8080 - targetPort: 8080 - selector: - app: spring-cloud-kubernetes-client-configmap-polling-reload - type: ClusterIP diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java index 126380321a..ce0ff4e711 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java @@ -436,6 +436,19 @@ public void wiremock(String namespace, String path, Phase phase) { } + public void configWatcher(Phase phase) { + + V1Deployment deployment = (V1Deployment) yaml("config-watcher/deployment.yaml"); + V1Service service = (V1Service) yaml("config-watcher/service.yaml"); + + if (phase.equals(Phase.CREATE)) { + createAndWait("default", deployment.getMetadata().getName(), deployment, service, null, true); + } + else { + deleteAndWait("default", deployment, service, null); + } + } + private String deploymentName(V1Deployment deployment) { return deployment.getMetadata().getName(); } From e91dcda9e71b665dfbc359fe49266891a08f717e Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 11 May 2023 20:22:17 +0300 Subject: [PATCH 011/100] trigger build From b18d05a0fa4dd343e71014dac0ddd61a97803e9d Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 11 May 2023 22:27:53 +0300 Subject: [PATCH 012/100] trigger build From c3bd950038648f00956aef47781ab46256d98dec Mon Sep 17 00:00:00 2001 From: wind57 Date: Sat, 13 May 2023 13:44:08 +0300 Subject: [PATCH 013/100] trigger build From 34fc1d06933ceb412dcfe5c595ca1e70c355cc36 Mon Sep 17 00:00:00 2001 From: wind57 Date: Mon, 17 Jul 2023 16:49:43 +0300 Subject: [PATCH 014/100] fix bad merge --- .../commons/config/SecretsPropertySourceLocator.java | 1 + .../integration/tests/commons/fabric8_client/Util.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java index 4b83def63f..4fefbe307e 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsPropertySourceLocator.java @@ -94,4 +94,5 @@ private SecretsPropertySource getSecretsPropertySourceForSingleSecret(Configurab protected abstract SecretsPropertySource getPropertySource(ConfigurableEnvironment environment, NormalizedSource normalizedSource); + } diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java index 9ee0f7156c..d3784395cb 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/fabric8_client/Util.java @@ -282,8 +282,8 @@ public void configWatcher(Phase phase) { InputStream deploymentStream = inputStream("config-watcher/deployment.yaml"); InputStream serviceStream = inputStream("config-watcher/service.yaml"); - Deployment deployment = client.apps().deployments().load(deploymentStream).get(); - Service service = client.services().load(serviceStream).get(); + Deployment deployment = client.apps().deployments().load(deploymentStream).item(); + Service service = client.services().load(serviceStream).item(); if (phase.equals(Phase.CREATE)) { createAndWait("default", deployment.getMetadata().getName(), deployment, service, null, true); From f813198bc8e0a921da103d1c46875cf971ac93e2 Mon Sep 17 00:00:00 2001 From: wind57 Date: Mon, 17 Jul 2023 20:28:45 +0300 Subject: [PATCH 015/100] trigger From fa277f928b20a8f5b9123a1716576af11acd8601 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 18 Jul 2023 11:38:21 +0300 Subject: [PATCH 016/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 13414b2905..757688cab0 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -90,7 +90,7 @@ runs: max_test_time_as_int=$(printf "%.0f\n" "$max_test_time") echo "max test time : $max_test_time_as_int" - number_of_instances=$(( $sum_of_all_tests_as_int / $max_test_time_as_int )) + number_of_instances=${{ env.NUMBER_OF_MATRIX_INSTANCES }} echo "number of instances $number_of_instances" average_time_per_instance=$(( sum_of_all_tests_as_int / number_of_instances )) From 643c72b8843a8415f48492853baf0db9e2e84f9d Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 18 Jul 2023 13:47:21 +0300 Subject: [PATCH 017/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 757688cab0..c1005fdb97 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -90,7 +90,7 @@ runs: max_test_time_as_int=$(printf "%.0f\n" "$max_test_time") echo "max test time : $max_test_time_as_int" - number_of_instances=${{ env.NUMBER_OF_MATRIX_INSTANCES }} + number_of_instances=${NUMBER_OF_JOBS} echo "number of instances $number_of_instances" average_time_per_instance=$(( sum_of_all_tests_as_int / number_of_instances )) From 5b202d545e6a8e3e8e0ed7d8e57ee9d791ef775a Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 18 Jul 2023 13:48:53 +0300 Subject: [PATCH 018/100] timeout added --- .github/workflows/maven.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index b9fd2b508e..65802dcf54 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -123,6 +123,7 @@ jobs: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30 # only run this one if there is a previous cache of test times if: needs.build.outputs.test_times_cache_present == 'true' + timeout-minutes: 60 strategy: fail-fast: true From 3ac7a9afb8cf9bfde582d596d84a7c761cef3880 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 18 Jul 2023 16:46:59 +0300 Subject: [PATCH 019/100] check if there are tests in current index at all --- .../run-and-save-test-times-when-cache-present/action.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index c1005fdb97..aee9bc83cf 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -133,6 +133,12 @@ runs: echo "current index : ${CURRENT_INDEX}" tests_to_run_in_current_index=$tests_to_take_in_current_iteration echo "time of tests in current index : $sum" + + if [[ "$sum" -eq "0" ]]; then + echo "no tests to run in current index, most probably this PR removed some tests" + tests_to_run_in_current_index='none' + fi + fi done From 874223ba145a3f07d2aae989676e4ba0e175da68 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 18 Jul 2023 18:54:10 +0300 Subject: [PATCH 020/100] fix last index none entry --- .../action.yaml | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index aee9bc83cf..4093ab1aee 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -134,6 +134,9 @@ runs: tests_to_run_in_current_index=$tests_to_take_in_current_iteration echo "time of tests in current index : $sum" + # this can be the case when we delete some tests in some PR for example + # the previous cache will contain more tests then we currently have, so some + # matrix instances will have no tests to run if [[ "$sum" -eq "0" ]]; then echo "no tests to run in current index, most probably this PR removed some tests" tests_to_run_in_current_index='none' @@ -194,13 +197,18 @@ runs: unset IFS for i in "${sliced_array[@]}"; do - filename="${i}.txt" - echo "searching for filename: ${filename}" - file=$(find . -name "${filename}") - echo "found file: ${file}" - result=$(cat "${file}" | grep 'elapsed' | awk '{print $12, $13}') - - echo "run test: ${i} in : ${result}" >> /tmp/test_times_${{ env.CURRENT_INDEX }}.txt + + # can be present in the last index as 'none,testA,testB' + if [[ "$i" -eq "none" ]]; then + echo "skipping 'none'" + else + filename="${i}.txt" + echo "searching for filename: ${filename}" + file=$(find . -name "${filename}") + echo "found file: ${file}" + result=$(cat "${file}" | grep 'elapsed' | awk '{print $12, $13}') + echo "run test: ${i} in : ${result}" >> /tmp/test_times_${{ env.CURRENT_INDEX }}.txt + fi done fi From 7bf5130070ca6827e271f6c9e843d27ca14c6e31 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 19 Jul 2023 07:28:10 +0300 Subject: [PATCH 021/100] trigger From 3cf77d09022c8022ef7c8d79ad4a20b70b54d07b Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 19 Jul 2023 10:19:00 +0300 Subject: [PATCH 022/100] trigger From 12fd72d2aa1e971885f78f308ef266c318092f00 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 25 Jul 2023 09:25:13 +0300 Subject: [PATCH 023/100] trigger From ef05092fb7702c87dab4646de974ad60f3e87bd2 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 25 Jul 2023 10:51:53 +0300 Subject: [PATCH 024/100] trigger From dccd91d451c427b1275c22eb2b4397cc630e29f9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 8 Aug 2023 11:24:35 +0300 Subject: [PATCH 025/100] trigger From 030581cb6985bc38abc1fdf0492de938bda5cfd0 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 12 Sep 2023 09:37:12 +0300 Subject: [PATCH 026/100] revert method --- .../tests/commons/native_client/Util.java | 12 ++++++++++++ .../kubernetes/tests/discovery/TestsDiscovery.java | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java index 8cbc176535..2ba64cf218 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java @@ -438,6 +438,18 @@ public void wiremock(String namespace, String path, Phase phase) { } + public void configWatcher(Phase phase) { + + V1Deployment deployment = (V1Deployment) yaml("config-watcher/deployment.yaml"); + V1Service service = (V1Service) yaml("config-watcher/service.yaml"); + + if (phase.equals(Phase.CREATE)) { + createAndWait("default", deployment.getMetadata().getName(), deployment, service, null, true); + } else { + deleteAndWait("default", deployment, service, null); + } + } + public static void patchWithMerge(String deploymentName, String namespace, String patchBody, Map podLabels) { try { diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/tests/discovery/TestsDiscovery.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/tests/discovery/TestsDiscovery.java index 22ebd00ccf..78a281a4f6 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/tests/discovery/TestsDiscovery.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/tests/discovery/TestsDiscovery.java @@ -62,9 +62,9 @@ public static void main(String[] args) throws Exception { Launcher launcher = session.getLauncher(); TestPlan testPlan = launcher.discover(request); testPlan.getRoots().stream().flatMap(x -> testPlan.getChildren(x).stream()) - .map(TestIdentifier::getLegacyReportingName).sorted().forEach(test -> { - System.out.println("spring.cloud.k8s.test.to.run -> " + test); - }); + .map(TestIdentifier::getLegacyReportingName).sorted().forEach(test -> { + System.out.println("spring.cloud.k8s.test.to.run -> " + test); + }); } } From 238a4be189f96d93ae0f41bb24a9feb3601b9cf4 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 12 Sep 2023 09:56:44 +0300 Subject: [PATCH 027/100] checkstyle --- .../integration/tests/commons/native_client/Util.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java index 2ba64cf218..21a1818347 100644 --- a/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java +++ b/spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java @@ -445,7 +445,8 @@ public void configWatcher(Phase phase) { if (phase.equals(Phase.CREATE)) { createAndWait("default", deployment.getMetadata().getName(), deployment, service, null, true); - } else { + } + else { deleteAndWait("default", deployment, service, null); } } From 9579e3a9fa7b9599a48d40ed7e51b39e1a2ef619 Mon Sep 17 00:00:00 2001 From: wind57 Date: Mon, 18 Sep 2023 22:52:35 +0300 Subject: [PATCH 028/100] dirty --- .../src/test/resources/ingress.yaml | 8 ----- .../reload/{App.java => ConfigMapApp.java} | 11 ++----- .../configmap/reload/ConfigMapProperties.java | 4 +-- .../client/configmap/reload/Controller.java | 4 +-- .../configmap/reload/LeftProperties.java | 13 --------- .../src/main/resources/application-mount.yaml | 5 +--- .../reload/K8sClientConfigMapReloadIT.java | 15 +++++----- .../reload/K8sClientReloadITUtil.java | 12 ++++++-- .../PollingReloadConfigMapMountDelegate.java | 29 +++++-------------- .../src/test/resources/configmap-mount.yaml | 3 +- .../src/test/resources/ingress.yaml | 8 ----- 11 files changed, 33 insertions(+), 79 deletions(-) rename spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/{App.java => ConfigMapApp.java} (58%) diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml index 3d60b8b5e3..4beef36c5e 100644 --- a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml @@ -1,11 +1,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml - name: fabric8-client-configmap-ingress-polling-and-import-reload -======== name: spring-k8s-client-ingress-reload ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml namespace: default spec: rules: @@ -15,10 +11,6 @@ spec: pathType: Prefix backend: service: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml - name: fabric8-client-configmap-polling-and-import-reload -======== name: spring-k8s-client-reload ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml port: number: 8080 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/App.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapApp.java similarity index 58% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/App.java rename to spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapApp.java index 4d0e7175eb..e21e08fef0 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/App.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapApp.java @@ -24,17 +24,12 @@ * @author wind57 */ @SpringBootApplication -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapApp.java -@EnableConfigurationProperties({ ConfigMapProperties.class, ConfigMapPropertiesNoMount.class }) +@EnableConfigurationProperties({ ConfigMapProperties.class, LeftProperties.class, RightProperties.class, + RightWithLabelsProperties.class }) public class ConfigMapApp { -======== -@EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class, - ConfigMapProperties.class }) -public class App { ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/App.java public static void main(String[] args) { - SpringApplication.run(App.class, args); + SpringApplication.run(ConfigMapApp.class, args); } } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapProperties.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapProperties.java index d002facd70..78607b2c24 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapProperties.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/ConfigMapProperties.java @@ -21,8 +21,8 @@ /** * @author wind57 */ -@ConfigurationProperties("from.properties") -public class ConfigMapPropertiesNoMount { +@ConfigurationProperties("props") +public class ConfigMapProperties { private String key; diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/Controller.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/Controller.java index dec721af52..615e269189 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/Controller.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/Controller.java @@ -56,8 +56,8 @@ public String witLabel() { return rightWithLabelsProperties.getValue(); } - @GetMapping("/mount") - public String key() { + @GetMapping("/key") + public String keyNoMount() { return configMapProperties.getKey(); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/LeftProperties.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/LeftProperties.java index ae38f65468..fd7a7ef669 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/LeftProperties.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/LeftProperties.java @@ -26,25 +26,12 @@ public class LeftProperties { private String value; -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/kubernetes-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/polling/reload/ConfigMapController.java - private final ConfigMapPropertiesNoMount propertiesNoMount; - - public ConfigMapController(ConfigMapProperties properties, ConfigMapPropertiesNoMount propertiesNoMount) { - this.properties = properties; - this.propertiesNoMount = propertiesNoMount; -======== public String getValue() { return value; ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/client/configmap/reload/LeftProperties.java } public void setValue(String value) { this.value = value; } - @GetMapping("/key-no-mount") - public String keyNoMount() { - return propertiesNoMount.getKey(); - } - } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml index cd1765f5c8..7a6ef76fc1 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml @@ -9,9 +9,6 @@ spring: strategy: shutdown mode: polling period: 5000 - config: - paths: - - /tmp/application.properties config: - import: "kubernetes:" + import: "kubernetes:,configtree:/tmp/" diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java index 903b118206..91920376c5 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java @@ -43,8 +43,6 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.awaitility.Awaitility.await; -import static org.springframework.cloud.kubernetes.client.configmap.reload.BootstrapEnabledPollingReloadConfigMapMountDelegate.testBootstrapEnabledPollingReloadConfigMapMount; -import static org.springframework.cloud.kubernetes.client.configmap.reload.DataChangesInConfigMapReloadDelegate.testSimple; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientReloadITUtil.builder; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientReloadITUtil.patchOne; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientReloadITUtil.patchThree; @@ -142,12 +140,13 @@ void testInformFromOneNamespaceEventNotTriggered() throws Exception { // since we patch each deployment with "replace" strategy, any of the above can be // commented out and debugged individually. private void testAllOther() throws Exception { - testInformFromOneNamespaceEventTriggered(); - testInform(); - testInformFromOneNamespaceEventTriggeredSecretsDisabled(); - testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S); - testPollingReloadConfigMapMount(DEPLOYMENT_NAME, K3S, util, DOCKER_IMAGE); - testBootstrapEnabledPollingReloadConfigMapMount(DEPLOYMENT_NAME, K3S, util, DOCKER_IMAGE); + // testInformFromOneNamespaceEventTriggered(); + // testInform(); + // testInformFromOneNamespaceEventTriggeredSecretsDisabled(); + // testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S); + testPollingReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); + // testBootstrapEnabledPollingReloadConfigMapMount(DEPLOYMENT_NAME, K3S, util, + // DOCKER_IMAGE); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientReloadITUtil.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientReloadITUtil.java index 8922dd82ea..655149dc51 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientReloadITUtil.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientReloadITUtil.java @@ -263,7 +263,13 @@ private K8sClientReloadITUtil() { { "configMap": { "defaultMode": 420, - "name": "poll-reload-as-mount" + "name": "poll-reload-as-mount", + "items": [ + { + "key": "from.properties", + "path": "key" + } + ] }, "name": "config-map-volume" } @@ -273,7 +279,7 @@ private K8sClientReloadITUtil() { "image": "image_name_here", "volumeMounts": [ { - "mountPath": "/tmp", + "mountPath": "/tmp/props", "name": "config-map-volume" } ], @@ -347,7 +353,7 @@ private K8sClientReloadITUtil() { "image": "image_name_here", "volumeMounts": [ { - "mountPath": "/tmp", + "mountPath": "/tmp/props", "name": "config-map-volume" } ], diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java index 8bae0696fe..bac39b2b2d 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java @@ -22,9 +22,7 @@ import io.kubernetes.client.openapi.apis.CoreV1Api; import io.kubernetes.client.openapi.models.V1ConfigMap; import org.junit.jupiter.api.Assertions; -import org.testcontainers.k3s.K3sContainer; -import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient; @@ -45,34 +43,23 @@ private PollingReloadConfigMapMountDelegate() { /** *
-	 *     - we have "spring.config.import: kubernetes", which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
 	 *     - the property above means that at the moment we will be searching for config maps that only
 	 *       match the application name, in this specific test there is no such config map.
-	 *     - what we will also read, is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see BODY_FIVE)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ - static void testPollingReloadConfigMapMount(String deploymentName, K3sContainer k3sContainer, Util util, - String imageName) throws Exception { + static void testPollingReloadConfigMapMount(String deploymentName, Util util, String imageName) throws Exception { patchFive(deploymentName, "default", imageName); - // (1) - Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", k3sContainer, - deploymentName); - - // (2) - Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", k3sContainer, - deploymentName); - // (3) - WebClient webClient = builder().baseUrl("http://localhost/mount").build(); + WebClient webClient = builder().baseUrl("http://localhost/key").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) .block(); @@ -82,7 +69,7 @@ static void testPollingReloadConfigMapMount(String deploymentName, K3sContainer // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); + configMap.setData(Map.of("data", "from.properties=as-mount-changed")); new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null, null); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/configmap-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/configmap-mount.yaml index f2ea29a5c2..e0cf495c6c 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/configmap-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/configmap-mount.yaml @@ -4,5 +4,4 @@ metadata: name: poll-reload-as-mount namespace: default data: - application.properties: | - from.properties.key=as-mount-initial + from.properties: "as-mount-initial" diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml index 3d60b8b5e3..4beef36c5e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml @@ -1,11 +1,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml - name: fabric8-client-configmap-ingress-polling-and-import-reload -======== name: spring-k8s-client-ingress-reload ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml namespace: default spec: rules: @@ -15,10 +11,6 @@ spec: pathType: Prefix backend: service: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml - name: fabric8-client-configmap-polling-and-import-reload -======== name: spring-k8s-client-reload ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/resources/ingress.yaml port: number: 8080 From ddb563c99cdc608edf31dd1fd728dcee3af85ee3 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 20 Sep 2023 07:48:12 +0300 Subject: [PATCH 029/100] dirty --- .../src/main/resources/application-mount.yaml | 18 ++++++++++-------- .../reload/K8sClientConfigMapReloadIT.java | 10 ++++++++++ .../PollingReloadConfigMapMountDelegate.java | 13 +++++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml index 7a6ef76fc1..7a977072cb 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-mount.yaml @@ -1,14 +1,16 @@ spring: application: name: poll-reload-mount - cloud: - kubernetes: - reload: - enabled: true - monitoring-config-maps: true - strategy: shutdown - mode: polling - period: 5000 config: import: "kubernetes:,configtree:/tmp/" +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java index 91920376c5..a12bf7736d 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java @@ -55,6 +55,8 @@ */ class K8sClientConfigMapReloadIT { + private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; + private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-event-and-polling-reload"; private static final String DEPLOYMENT_NAME = "spring-k8s-client-reload"; @@ -72,13 +74,19 @@ class K8sClientConfigMapReloadIT { @BeforeAll static void beforeAll() throws Exception { K3S.start(); + Commons.validateImage(IMAGE_NAME, K3S); Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); + + Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util = new Util(K3S); util.createNamespace("left"); util.createNamespace("right"); util.setUpClusterWide(NAMESPACE, Set.of("left", "right")); util.setUp(NAMESPACE); + util.configWatcher(Phase.CREATE); api = new CoreV1Api(); } @@ -88,7 +96,9 @@ static void afterAll() throws Exception { manifests(Phase.DELETE); util.deleteNamespace("left"); util.deleteNamespace("right"); + util.configWatcher(Phase.DELETE); Commons.cleanUp(IMAGE_NAME, K3S); + Commons.cleanUp(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); Commons.systemPrune(); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java index bac39b2b2d..c45e71c1e0 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java @@ -17,7 +17,9 @@ package org.springframework.cloud.kubernetes.client.configmap.reload; import java.time.Duration; +import java.util.HashMap; import java.util.Map; +import java.util.Optional; import io.kubernetes.client.openapi.apis.CoreV1Api; import io.kubernetes.client.openapi.models.V1ConfigMap; @@ -70,6 +72,17 @@ static void testPollingReloadConfigMapMount(String deploymentName, Util util, St // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); configMap.setData(Map.of("data", "from.properties=as-mount-changed")); + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMap.getMetadata().setLabels(existingLabels); + + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getAnnotations()).orElse(Map.of())); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", "spring-k8s-client-reload"); + configMap.getMetadata().setAnnotations(existingAnnotations); new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null, null); From a6b2ca8d1f4b6902f6b8543c2db9181e451909a5 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 20 Sep 2023 11:15:01 +0300 Subject: [PATCH 030/100] fix issue --- ...rnetesClientDiscoveryHealthITDelegate.java | 69 ++++++++++--------- .../it/DiscoveryClientFilterNamespaceIT.java | 7 +- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/src/test/java/org/springframework/cloud/kubernetes/client/discovery/it/KubernetesClientDiscoveryHealthITDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/src/test/java/org/springframework/cloud/kubernetes/client/discovery/it/KubernetesClientDiscoveryHealthITDelegate.java index ee03815f27..f11fb27899 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/src/test/java/org/springframework/cloud/kubernetes/client/discovery/it/KubernetesClientDiscoveryHealthITDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/src/test/java/org/springframework/cloud/kubernetes/client/discovery/it/KubernetesClientDiscoveryHealthITDelegate.java @@ -156,8 +156,8 @@ void testDefaultConfiguration(K3sContainer container) { String healthResult = healthClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) .retryWhen(retrySpec()).block(); - String infoResult = infoClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(retrySpec()).block(); + String infoResult = infoClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) + .block(); Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) .extractingJsonPathStringValue("$.components.discoveryComposite.status").isEqualTo("UP"); @@ -188,55 +188,56 @@ void testDefaultConfiguration(K3sContainer container) { } private void assertHealth(String healthResult) { - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.status").isEqualTo("UP"); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.status").isEqualTo("UP"); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.hostIp").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.hostIp").isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathBooleanValue( - "$.components.kubernetes.details.inside").isEqualTo(true); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathBooleanValue("$.components.kubernetes.details.inside").isEqualTo(true); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.labels.app").isEqualTo("spring-cloud-kubernetes-client-discovery-it"); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.labels.app") + .isEqualTo("spring-cloud-kubernetes-client-discovery-it"); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.namespace").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.namespace").isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.nodeName").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.nodeName").isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.podIp").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.podIp").isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.podName").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.podName").isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)).extractingJsonPathStringValue( - "$.components.kubernetes.details.serviceAccount").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(healthResult)) + .extractingJsonPathStringValue("$.components.kubernetes.details.serviceAccount").isNotEmpty(); } private void assertInfo(String infoResult) { - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue( - "$.kubernetes.hostIp").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue("$.kubernetes.hostIp") + .isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathBooleanValue( - "$.kubernetes.inside").isEqualTo(true); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathBooleanValue("$.kubernetes.inside") + .isEqualTo(true); - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue( - "$.kubernetes.namespace").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)) + .extractingJsonPathStringValue("$.kubernetes.namespace").isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue( - "$.kubernetes.nodeName").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue("$.kubernetes.nodeName") + .isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue( - "$.kubernetes.podIp").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue("$.kubernetes.podIp") + .isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue( - "$.kubernetes.podName").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue("$.kubernetes.podName") + .isNotEmpty(); - Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)).extractingJsonPathStringValue( - "$.kubernetes.serviceAccount").isNotEmpty(); + Assertions.assertThat(BASIC_JSON_TESTER.from(infoResult)) + .extractingJsonPathStringValue("$.kubernetes.serviceAccount").isNotEmpty(); } private WebClient.Builder builder() { diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java index 65491ee126..3d42774cdc 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java @@ -71,6 +71,8 @@ class DiscoveryClientFilterNamespaceIT { private static RbacAuthorizationV1Api rbacApi; + private static V1ClusterRoleBinding clusterRole; + @BeforeAll static void beforeAll() throws Exception { K3S.start(); @@ -83,18 +85,19 @@ static void beforeAll() throws Exception { util = new Util(K3S); rbacApi = new RbacAuthorizationV1Api(); + clusterRole = (V1ClusterRoleBinding) util + .yaml("namespace-filter/cluster-admin-serviceaccount-role.yaml"); util.createNamespace(NAMESPACE_LEFT); util.createNamespace(NAMESPACE_RIGHT); util.setUp(NAMESPACE); - V1ClusterRoleBinding clusterRole = (V1ClusterRoleBinding) util - .yaml("namespace-filter/cluster-admin-serviceaccount-role.yaml"); rbacApi.createClusterRoleBinding(clusterRole, null, null, null, null); discoveryServer(Phase.CREATE); } @AfterAll static void afterAll() throws Exception { + rbacApi.deleteClusterRoleBinding(clusterRole.getMetadata().getName(), null, null, null, null, null, null); Commons.cleanUp(DISCOVERY_SERVER_APP_NAME, K3S); Commons.cleanUp(SPRING_CLOUD_K8S_DISCOVERY_CLIENT_APP_NAME, K3S); discoveryServer(Phase.DELETE); From 3ed982ac5035dc2ebfea0b49d4d50e6353d8ad62 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 20 Sep 2023 12:42:06 +0300 Subject: [PATCH 031/100] fix issue --- .../it/DiscoveryClientFilterNamespaceIT.java | 9 +++++---- .../discoveryclient/it/DiscoveryClientIT.java | 12 +++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java index 3d42774cdc..fe10560904 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientFilterNamespaceIT.java @@ -71,7 +71,7 @@ class DiscoveryClientFilterNamespaceIT { private static RbacAuthorizationV1Api rbacApi; - private static V1ClusterRoleBinding clusterRole; + private static V1ClusterRoleBinding clusterRoleBinding; @BeforeAll static void beforeAll() throws Exception { @@ -85,19 +85,20 @@ static void beforeAll() throws Exception { util = new Util(K3S); rbacApi = new RbacAuthorizationV1Api(); - clusterRole = (V1ClusterRoleBinding) util + clusterRoleBinding = (V1ClusterRoleBinding) util .yaml("namespace-filter/cluster-admin-serviceaccount-role.yaml"); util.createNamespace(NAMESPACE_LEFT); util.createNamespace(NAMESPACE_RIGHT); util.setUp(NAMESPACE); - rbacApi.createClusterRoleBinding(clusterRole, null, null, null, null); + rbacApi.createClusterRoleBinding(clusterRoleBinding, null, null, null, null); discoveryServer(Phase.CREATE); } @AfterAll static void afterAll() throws Exception { - rbacApi.deleteClusterRoleBinding(clusterRole.getMetadata().getName(), null, null, null, null, null, null); + rbacApi.deleteClusterRoleBinding(clusterRoleBinding.getMetadata().getName(), null, null, null, null, null, + null); Commons.cleanUp(DISCOVERY_SERVER_APP_NAME, K3S); Commons.cleanUp(SPRING_CLOUD_K8S_DISCOVERY_CLIENT_APP_NAME, K3S); discoveryServer(Phase.DELETE); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientIT.java index 7f4903717e..e3ca48a385 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/discoveryclient/it/DiscoveryClientIT.java @@ -113,6 +113,10 @@ class DiscoveryClientIT { private static Util util; + private static RbacAuthorizationV1Api rbacApi; + + private static V1ClusterRoleBinding clusterRoleBinding; + @BeforeAll static void beforeAll() throws Exception { K3S.start(); @@ -124,15 +128,15 @@ static void beforeAll() throws Exception { Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_DISCOVERY_CLIENT_APP_NAME, K3S); util = new Util(K3S); + rbacApi = new RbacAuthorizationV1Api(); util.setUp(NAMESPACE); util.createNamespace(NAMESPACE_LEFT); util.createNamespace(NAMESPACE_RIGHT); - RbacAuthorizationV1Api rbacApi = new RbacAuthorizationV1Api(); - V1ClusterRoleBinding clusterRole = (V1ClusterRoleBinding) util + clusterRoleBinding = (V1ClusterRoleBinding) util .yaml("namespace-filter/cluster-admin-serviceaccount-role.yaml"); - rbacApi.createClusterRoleBinding(clusterRole, null, null, null, null); + rbacApi.createClusterRoleBinding(clusterRoleBinding, null, null, null, null); util.wiremock(NAMESPACE_LEFT, "/wiremock-" + NAMESPACE_LEFT, Phase.CREATE, false); util.wiremock(NAMESPACE_RIGHT, "/wiremock-" + NAMESPACE_RIGHT, Phase.CREATE, false); @@ -143,6 +147,8 @@ static void beforeAll() throws Exception { @AfterAll static void afterAll() throws Exception { + rbacApi.deleteClusterRoleBinding(clusterRoleBinding.getMetadata().getName(), null, null, null, null, null, + null); Commons.cleanUp(DISCOVERY_SERVER_APP_NAME, K3S); Commons.cleanUp(SPRING_CLOUD_K8S_DISCOVERY_CLIENT_APP_NAME, K3S); From 83cc3943adc5da2c5723b4ff5fbf5c08351800b9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 20 Sep 2023 12:52:15 +0300 Subject: [PATCH 032/100] fix merge --- .../cloud/kubernetes/reload/App.java | 41 ------------------- .../cloud/kubernetes/reload/ConfigMapApp.java | 8 +--- .../PollingReloadConfigMapMountDelegate.java | 6 +-- 3 files changed, 3 insertions(+), 52 deletions(-) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java deleted file mode 100644 index 3a6116b47b..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2013-2022 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.reload; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.EnableConfigurationProperties; - -/** - * @author wind57 - */ -@SpringBootApplication -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java -@EnableConfigurationProperties({ ConfigMapProperties.class, LeftProperties.class, RightProperties.class, - RightWithLabelsProperties.class }) -public class ConfigMapApp { -======== -@EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class, - ConfigMapProperties.class, SecretsProperties.class }) -public class App { ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java - - public static void main(String[] args) { - SpringApplication.run(ConfigMapApp.class, args); - } - -} diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java index 3a6116b47b..bbe3df2823 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java @@ -24,15 +24,9 @@ * @author wind57 */ @SpringBootApplication -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java -@EnableConfigurationProperties({ ConfigMapProperties.class, LeftProperties.class, RightProperties.class, - RightWithLabelsProperties.class }) -public class ConfigMapApp { -======== @EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class, ConfigMapProperties.class, SecretsProperties.class }) -public class App { ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java +public class ConfigMapApp { public static void main(String[] args) { SpringApplication.run(ConfigMapApp.class, args); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java index 09045e830b..9205efcbd8 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java @@ -59,10 +59,8 @@ static void testPollingReloadConfigMapMount(String deploymentName, Util util, St // (3) WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key").build(); - String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen( - K8sClientConfigMapReloadITUtil.retrySpec() - ) - .block(); + String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) + .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block(); // we first read the initial value from the configmap Assertions.assertEquals("as-mount-initial", result); From 3eb159e2f31db41d84901e84e7781cbd8008676f Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 20 Sep 2023 14:30:30 +0300 Subject: [PATCH 033/100] dirty --- .../src/test/resources/ingress.yaml | 2 +- .../reload/{ConfigMapApp.java => App.java} | 4 +- .../cloud/kubernetes/reload/Controller.java | 2 +- .../reload/K8sClientConfigMapReloadIT.java | 2 +- ...java => ReloadConfigMapMountDelegate.java} | 7 +- .../it/ReactiveDiscoveryClientIT.java | 150 ------------------ .../resources/config-watcher/deployment.yaml | 4 +- 7 files changed, 10 insertions(+), 161 deletions(-) rename spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/{ConfigMapApp.java => App.java} (93%) rename spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/{PollingReloadConfigMapMountDelegate.java => ReloadConfigMapMountDelegate.java} (96%) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-reactive-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/client/reactive/discovery/it/ReactiveDiscoveryClientIT.java diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml index 4beef36c5e..37eb4a2d6b 100644 --- a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml @@ -11,6 +11,6 @@ spec: pathType: Prefix backend: service: - name: spring-k8s-client-reload + name: fabric8-client-configmap-polling-and-import-reload port: number: 8080 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java similarity index 93% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java rename to spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java index bbe3df2823..a39ba5a64e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/ConfigMapApp.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/App.java @@ -26,10 +26,10 @@ @SpringBootApplication @EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class, ConfigMapProperties.class, SecretsProperties.class }) -public class ConfigMapApp { +public class App { public static void main(String[] args) { - SpringApplication.run(ConfigMapApp.class, args); + SpringApplication.run(App.class, args); } } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java index 55c6394169..e349d9074d 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java @@ -56,7 +56,7 @@ public String witLabel() { return rightWithLabelsProperties.getValue(); } - @GetMapping("/key") + @GetMapping("/key-no-mount") public String keyNoMount() { return configMapProperties.getKey(); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java index f03e6a87e7..e1afe4c6d7 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java @@ -48,7 +48,7 @@ import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchThree; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchTwo; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.retrySpec; -import static org.springframework.cloud.kubernetes.client.configmap.reload.PollingReloadConfigMapMountDelegate.testPollingReloadConfigMapMount; +import static org.springframework.cloud.kubernetes.client.configmap.reload.ReloadConfigMapMountDelegate.testPollingReloadConfigMapMount; /** * @author wind57 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java similarity index 96% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java rename to spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java index 9205efcbd8..1c4b109d40 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/PollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java @@ -34,9 +34,9 @@ /** * @author wind57 */ -final class PollingReloadConfigMapMountDelegate { +final class ReloadConfigMapMountDelegate { - private PollingReloadConfigMapMountDelegate() { + private ReloadConfigMapMountDelegate() { } @@ -57,8 +57,7 @@ static void testPollingReloadConfigMapMount(String deploymentName, Util util, St K8sClientConfigMapReloadITUtil.patchFive(deploymentName, "default", imageName); - // (3) - WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key").build(); + WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key-no-mount").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block(); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-reactive-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/client/reactive/discovery/it/ReactiveDiscoveryClientIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-reactive-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/client/reactive/discovery/it/ReactiveDiscoveryClientIT.java deleted file mode 100644 index c9de33d25a..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-reactive-discoveryclient-it/src/test/java/org/springframework/cloud/kubernetes/client/reactive/discovery/it/ReactiveDiscoveryClientIT.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2013-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.client.reactive.discovery.it; - -import java.time.Duration; -import java.util.Arrays; -import java.util.Map; -import java.util.Objects; - -import io.kubernetes.client.openapi.models.V1Deployment; -import io.kubernetes.client.openapi.models.V1Ingress; -import io.kubernetes.client.openapi.models.V1Service; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.testcontainers.k3s.K3sContainer; -import reactor.netty.http.client.HttpClient; -import reactor.util.retry.Retry; -import reactor.util.retry.RetryBackoffSpec; - -import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; -import org.springframework.cloud.kubernetes.integration.tests.commons.Phase; -import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.core.ResolvableType; -import org.springframework.http.HttpMethod; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Ryan Baxter - */ -class ReactiveDiscoveryClientIT { - - private static final String HEALTH_URL = "http://localhost:80/reactive-discovery-it/actuator/health"; - - private static final String SERVICES_URL = "http://localhost:80/reactive-discovery-it/services"; - - private static final String SPRING_CLOUD_K8S_REACTIVE_DISCOVERY_APP_NAME = "spring-cloud-kubernetes-client-reactive-discoveryclient-it"; - - private static final String NAMESPACE = "default"; - - private static final K3sContainer K3S = Commons.container(); - - private static Util util; - - @BeforeAll - static void beforeAll() throws Exception { - K3S.start(); - Commons.validateImage(SPRING_CLOUD_K8S_REACTIVE_DISCOVERY_APP_NAME, K3S); - Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_REACTIVE_DISCOVERY_APP_NAME, K3S); - util = new Util(K3S); - util.setUp(NAMESPACE); - } - - @AfterAll - static void afterAll() throws Exception { - Commons.cleanUp(SPRING_CLOUD_K8S_REACTIVE_DISCOVERY_APP_NAME, K3S); - Commons.systemPrune(); - } - - @BeforeEach - void setup() { - util.wiremock(NAMESPACE, "/wiremock", Phase.CREATE, false); - } - - @AfterEach - void after() { - util.wiremock(NAMESPACE, "/wiremock", Phase.DELETE, false); - reactiveDiscoveryIt(Phase.DELETE); - } - - @Test - void testReactiveDiscoveryClient() { - reactiveDiscoveryIt(Phase.CREATE); - testLoadBalancer(); - testHealth(); - } - - @SuppressWarnings("unchecked") - private void testHealth() { - - WebClient.Builder builder = builder(); - WebClient serviceClient = builder.baseUrl(HEALTH_URL).build(); - ResolvableType resolvableType = ResolvableType.forClassWithGenerics(Map.class, String.class, Object.class); - @SuppressWarnings("unchecked") - Map health = (Map) serviceClient.method(HttpMethod.GET).retrieve() - .bodyToMono(ParameterizedTypeReference.forType(resolvableType.getType())).retryWhen(retrySpec()) - .block(); - - Map components = (Map) health.get("components"); - - Assertions.assertTrue(components.containsKey("reactiveDiscoveryClients")); - Map discoveryComposite = (Map) components.get("discoveryComposite"); - Assertions.assertEquals(discoveryComposite.get("status"), "UP"); - } - - private void testLoadBalancer() { - - WebClient.Builder builder = builder(); - WebClient serviceClient = builder.baseUrl(SERVICES_URL).build(); - String servicesResponse = serviceClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(retrySpec()).block(); - - Assertions - .assertTrue(Arrays.stream(servicesResponse.split(",")).anyMatch("service-wiremock"::equalsIgnoreCase)); - } - - private void reactiveDiscoveryIt(Phase phase) { - V1Deployment deployment = (V1Deployment) util - .yaml("spring-cloud-kubernetes-client-reactive-discoveryclient-it-deployment.yaml"); - V1Service service = (V1Service) util - .yaml("spring-cloud-kubernetes-client-reactive-discoveryclient-it-service.yaml"); - V1Ingress ingress = (V1Ingress) util - .yaml("spring-cloud-kubernetes-client-reactive-discoveryclient-it-ingress.yaml"); - - if (phase.equals(Phase.CREATE)) { - util.createAndWait(NAMESPACE, null, deployment, service, ingress, true); - } - else if (phase.equals(Phase.DELETE)) { - util.deleteAndWait(NAMESPACE, deployment, service, ingress); - } - } - - private WebClient.Builder builder() { - return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create())); - } - - private RetryBackoffSpec retrySpec() { - return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull); - } - -} diff --git a/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml index 1a13a7dc76..388a873ae9 100644 --- a/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml +++ b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml @@ -33,5 +33,5 @@ spec: value: DEBUG - name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD value: DEBUG - #- name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY - # value: 100 + - name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY + value: "10000" From ce72d2f66c86444b66e779c7d882544cd2af4bbb Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 20 Sep 2023 18:24:13 +0300 Subject: [PATCH 034/100] dirty --- .../src/main/resources/application-mount.yaml | 6 --- .../cloud/kubernetes/reload/Controller.java | 14 +++++ .../resources/application-with-bootstrap.yaml | 19 ++++--- ...pEnabledReloadConfigMapMountDelegate.java} | 51 ++++++++++--------- .../reload/K8sClientConfigMapReloadIT.java | 7 ++- .../K8sClientConfigMapReloadITUtil.java | 8 ++- .../reload/ReloadConfigMapMountDelegate.java | 4 +- .../resources/config-watcher/deployment.yaml | 4 +- 8 files changed, 66 insertions(+), 47 deletions(-) rename spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/{BootstrapEnabledPollingReloadConfigMapMountDelegate.java => BootstrapEnabledReloadConfigMapMountDelegate.java} (59%) diff --git a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml index 39f43104d0..0fffac11f8 100644 --- a/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/resources/application-mount.yaml @@ -1,12 +1,6 @@ spring: application: name: poll-reload-mount - cloud: - kubernetes: - reload: - enabled: true - monitoring-config-maps: true - strategy: shutdown config: import: "kubernetes:,configtree:/tmp/" diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java index e349d9074d..23ac695dd3 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/java/org/springframework/cloud/kubernetes/reload/Controller.java @@ -16,6 +16,10 @@ package org.springframework.cloud.kubernetes.reload; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -61,4 +65,14 @@ public String keyNoMount() { return configMapProperties.getKey(); } + @GetMapping("/debug") + public String debug() { + try { + return Files.readAllLines(Paths.get("/tmp/props/key")).get(0); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-with-bootstrap.yaml index 56038d0242..92152ef039 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-with-bootstrap.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/main/resources/application-with-bootstrap.yaml @@ -6,11 +6,16 @@ spring: application: name: poll-reload config: - import: "kubernetes:" - cloud: - kubernetes: - reload: - enabled: true - monitoring-config-maps: true - strategy: shutdown + import: "kubernetes:,configtree:/tmp/" + +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java similarity index 59% rename from spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java rename to spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java index e6900bc575..118b62f970 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java @@ -17,14 +17,14 @@ package org.springframework.cloud.kubernetes.client.configmap.reload; import java.time.Duration; +import java.util.HashMap; import java.util.Map; +import java.util.Optional; import io.kubernetes.client.openapi.apis.CoreV1Api; import io.kubernetes.client.openapi.models.V1ConfigMap; import org.junit.jupiter.api.Assertions; -import org.testcontainers.k3s.K3sContainer; -import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient; @@ -34,40 +34,30 @@ /** * @author wind57 */ -final class BootstrapEnabledPollingReloadConfigMapMountDelegate { +final class BootstrapEnabledReloadConfigMapMountDelegate { private static final String NAMESPACE = "default"; /** *
-	 *     - we have bootstrap enabled, which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
-	 *     - there are no explicit config maps to search for, but what we will also read,
-	 *     	 is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - the property above means that at the moment we will be searching for config maps that only
+	 *       match the application name, in this specific test there is no such config map.
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ - static void testBootstrapEnabledPollingReloadConfigMapMount(String deploymentName, K3sContainer k3sContainer, - Util util, String imageName) throws Exception { + static void testBootstrapEnabledReloadConfigMapMount(String deploymentName, Util util, String imageName) + throws Exception { recreateMountConfigMap(util); K8sClientConfigMapReloadITUtil.patchSix(deploymentName, "default", imageName); - // (1) - Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", k3sContainer, - deploymentName); - - // (2) - Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", k3sContainer, - deploymentName); - - // (3) - WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/mount").build(); + WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key-no-mount").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block(); @@ -77,8 +67,19 @@ static void testBootstrapEnabledPollingReloadConfigMapMount(String deploymentNam // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); - new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", NAMESPACE, configMap, null, null, null, + configMap.setData(Map.of("from.properties", "as-mount-changed")); + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMap.getMetadata().setLabels(existingLabels); + + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>( + Optional.ofNullable(configMap.getMetadata().getAnnotations()).orElse(Map.of())); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", "spring-k8s-client-reload"); + configMap.getMetadata().setAnnotations(existingAnnotations); + new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null, null); await().timeout(Duration.ofSeconds(180)) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java index e1afe4c6d7..2714ec7507 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java @@ -43,12 +43,12 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.awaitility.Awaitility.await; +import static org.springframework.cloud.kubernetes.client.configmap.reload.BootstrapEnabledReloadConfigMapMountDelegate.testBootstrapEnabledReloadConfigMapMount; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.builder; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchOne; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchThree; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchTwo; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.retrySpec; -import static org.springframework.cloud.kubernetes.client.configmap.reload.ReloadConfigMapMountDelegate.testPollingReloadConfigMapMount; /** * @author wind57 @@ -154,9 +154,8 @@ private void testAllOther() throws Exception { // testInform(); // testInformFromOneNamespaceEventTriggeredSecretsDisabled(); // testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S); - testPollingReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); - // testBootstrapEnabledPollingReloadConfigMapMount(DEPLOYMENT_NAME, K3S, util, - // DOCKER_IMAGE); + // testReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); + testBootstrapEnabledReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadITUtil.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadITUtil.java index 5527868aae..a0446ec622 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadITUtil.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadITUtil.java @@ -342,7 +342,13 @@ private K8sClientConfigMapReloadITUtil() { { "configMap": { "defaultMode": 420, - "name": "poll-reload-as-mount" + "name": "poll-reload-as-mount", + "items": [ + { + "key": "from.properties", + "path": "key" + } + ] }, "name": "config-map-volume" } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java index 1c4b109d40..ef09f09c6e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java @@ -53,7 +53,7 @@ private ReloadConfigMapMountDelegate() { * and schedule a refresh event, based on http. * */ - static void testPollingReloadConfigMapMount(String deploymentName, Util util, String imageName) throws Exception { + static void testReloadConfigMapMount(String deploymentName, Util util, String imageName) throws Exception { K8sClientConfigMapReloadITUtil.patchFive(deploymentName, "default", imageName); @@ -67,7 +67,7 @@ static void testPollingReloadConfigMapMount(String deploymentName, Util util, St // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("data", "from.properties=as-mount-changed")); + configMap.setData(Map.of("from.properties", "as-mount-changed")); // add label so that configuration-watcher picks this up Map existingLabels = new HashMap<>( Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); diff --git a/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml index 388a873ae9..2cf04f3712 100644 --- a/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml +++ b/spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml @@ -33,5 +33,5 @@ spec: value: DEBUG - name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD value: DEBUG - - name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY - value: "10000" +# - name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY +# value: "10000" From bf0c4072602d4c1a23ef4ddfc987f81231b91f08 Mon Sep 17 00:00:00 2001 From: wind57 Date: Thu, 21 Sep 2023 09:18:11 +0300 Subject: [PATCH 035/100] drop test that we do not need anymore --- ...apEnabledReloadConfigMapMountDelegate.java | 98 ------------------- .../reload/K8sClientConfigMapReloadIT.java | 14 +-- 2 files changed, 7 insertions(+), 105 deletions(-) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java deleted file mode 100644 index 118b62f970..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/BootstrapEnabledReloadConfigMapMountDelegate.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2013-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.client.configmap.reload; - -import java.time.Duration; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import io.kubernetes.client.openapi.apis.CoreV1Api; -import io.kubernetes.client.openapi.models.V1ConfigMap; -import org.junit.jupiter.api.Assertions; - -import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; -import org.springframework.http.HttpMethod; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.awaitility.Awaitility.await; - -/** - * @author wind57 - */ -final class BootstrapEnabledReloadConfigMapMountDelegate { - - private static final String NAMESPACE = "default"; - - /** - *
-	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
-	 *       from config maps.
-	 *     - the property above means that at the moment we will be searching for config maps that only
-	 *       match the application name, in this specific test there is no such config map.
-	 *     - what we will also read, is /tmp directory according to configtree rules.
-	 *       As such, a property "props.key" (see deployment-mount.yaml) will be in environment.
-	 *
-	 *     - we then change the config map content, wait for configuration watcher to pick up the change
-	 *       and schedule a refresh event, based on http.
-	 * 
- */ - static void testBootstrapEnabledReloadConfigMapMount(String deploymentName, Util util, String imageName) - throws Exception { - - recreateMountConfigMap(util); - K8sClientConfigMapReloadITUtil.patchSix(deploymentName, "default", imageName); - - WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key-no-mount").build(); - String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block(); - - // we first read the initial value from the configmap - Assertions.assertEquals("as-mount-initial", result); - - // replace data in configmap and wait for k8s to pick it up - // our polling will detect that and restart the app - V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("from.properties", "as-mount-changed")); - // add label so that configuration-watcher picks this up - Map existingLabels = new HashMap<>( - Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); - existingLabels.put("spring.cloud.kubernetes.config", "true"); - configMap.getMetadata().setLabels(existingLabels); - - // add annotation for which app to send the http event to - Map existingAnnotations = new HashMap<>( - Optional.ofNullable(configMap.getMetadata().getAnnotations()).orElse(Map.of())); - existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", "spring-k8s-client-reload"); - configMap.getMetadata().setAnnotations(existingAnnotations); - new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null, - null); - - await().timeout(Duration.ofSeconds(180)) - .until(() -> webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block().equals("as-mount-changed")); - - } - - private static void recreateMountConfigMap(Util util) { - V1ConfigMap mountConfigMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - - util.deleteAndWait("default", mountConfigMap, null); - util.createAndWait("default", mountConfigMap, null); - } - -} diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java index 2714ec7507..296a84b277 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java @@ -43,12 +43,13 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.awaitility.Awaitility.await; -import static org.springframework.cloud.kubernetes.client.configmap.reload.BootstrapEnabledReloadConfigMapMountDelegate.testBootstrapEnabledReloadConfigMapMount; +import static org.springframework.cloud.kubernetes.client.configmap.reload.DataChangesInConfigMapReloadDelegate.testSimple; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.builder; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchOne; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchThree; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchTwo; import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.retrySpec; +import static org.springframework.cloud.kubernetes.client.configmap.reload.ReloadConfigMapMountDelegate.testReloadConfigMapMount; /** * @author wind57 @@ -150,12 +151,11 @@ void testInformFromOneNamespaceEventNotTriggered() throws Exception { // since we patch each deployment with "replace" strategy, any of the above can be // commented out and debugged individually. private void testAllOther() throws Exception { - // testInformFromOneNamespaceEventTriggered(); - // testInform(); - // testInformFromOneNamespaceEventTriggeredSecretsDisabled(); - // testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S); - // testReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); - testBootstrapEnabledReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); + testInformFromOneNamespaceEventTriggered(); + testInform(); + testInformFromOneNamespaceEventTriggeredSecretsDisabled(); + testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S); + testReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); } From ab5796b27308868fa326de5b052219a12e6db2d1 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 09:00:55 +0300 Subject: [PATCH 036/100] test --- .../action.yaml | 2 +- .../action.yaml | 2 +- .../save-controller-images/action.yaml | 15 -------------- .../save-integration-tests-images/action.yaml | 20 ------------------- 4 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/composites/save-controller-images/action.yaml delete mode 100644 .github/workflows/composites/save-integration-tests-images/action.yaml diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml index 39e79ebdd7..0cb4085b21 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml @@ -61,7 +61,7 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${TEST_ARG[@]} \ -e clean install \ - -U -P sonar -nsu --batch-mode \ + -P sonar -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index ce8c81cff3..f658cfbf58 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -150,7 +150,7 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ -e clean install \ - -U -P sonar -nsu --batch-mode \ + -P sonar -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ diff --git a/.github/workflows/composites/save-controller-images/action.yaml b/.github/workflows/composites/save-controller-images/action.yaml deleted file mode 100644 index 056b1b2adb..0000000000 --- a/.github/workflows/composites/save-controller-images/action.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: save controller docker images -description: save controller docker images -runs: - using: "composite" - steps: - - name: save controller docker images - shell: bash - run: | - mkdir -p /tmp/docker/images - TAG=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) - cd spring-cloud-kubernetes-controllers - while read controller_image; do - docker save -o /tmp/docker/images/${controller_image}.tar docker.io/springcloud/${controller_image}:$TAG - done < <(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q | grep -v 'spring-cloud-kubernetes-controllers') - cd .. diff --git a/.github/workflows/composites/save-integration-tests-images/action.yaml b/.github/workflows/composites/save-integration-tests-images/action.yaml deleted file mode 100644 index cbc92e55f7..0000000000 --- a/.github/workflows/composites/save-integration-tests-images/action.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: save integration tests docker images -description: save integration tests docker images -runs: - using: "composite" - steps: - - name: save integration tests docker images - shell: bash - run: | - mkdir -p /tmp/docker/images - TAG=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) - cd spring-cloud-kubernetes-integration-tests - while read integ_test; do - docker save -o /tmp/docker/images/${integ_test}.tar docker.io/springcloud/${integ_test}:$TAG - done < <(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q \ - | grep -v 'spring-cloud-kubernetes-integration-tests' \ - | grep -v 'spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps' \ - | grep -v 'spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app' \ - | grep -v 'spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps' \ - | grep -v 'spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app' ) - cd .. From 80c100c1ea084e761bbba334e06470faec3538e6 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 09:27:38 +0300 Subject: [PATCH 037/100] placeholder commit From 4763bdc5bcb5541082c582fd1237d4696241d0ba Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 10:53:24 +0300 Subject: [PATCH 038/100] test --- .../spring-cloud-kubernetes-client-catalog-watcher/pom.xml | 1 + .../pom.xml | 1 + .../spring-cloud-kubernetes-client-discovery-it/pom.xml | 1 + .../pom.xml | 1 + .../spring-cloud-kubernetes-client-loadbalancer-it/pom.xml | 1 + .../pom.xml | 1 + .../spring-cloud-kubernetes-configuration-watcher-it/pom.xml | 1 + .../spring-cloud-kubernetes-discoveryclient-it/pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + .../spring-cloud-kubernetes-fabric8-client-configmap/pom.xml | 1 + .../pom.xml | 1 + .../spring-cloud-kubernetes-fabric8-client-discovery/pom.xml | 1 + .../spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml | 1 + .../pom.xml | 1 + .../spring-cloud-kubernetes-fabric8-istio-it/pom.xml | 1 + 17 files changed, 17 insertions(+) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml index 38f4e18e73..2b5afdca5d 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml @@ -86,6 +86,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml index 382886e789..530756302e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml @@ -55,6 +55,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml index ec84212c8a..243f1a4d32 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml @@ -96,6 +96,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml index dfc5d03931..10a1503128 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml @@ -95,6 +95,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml index 61e6ba120f..1aea888da1 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml @@ -91,6 +91,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml index ba73ef90b8..38b3156899 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml @@ -55,6 +55,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml index 69d3aac1de..4179f2975c 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml @@ -111,6 +111,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml index 74e485be7f..512716a58c 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml @@ -92,6 +92,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml index e30c96300f..0f93f700fb 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml @@ -86,6 +86,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml index a1ba8bb15b..bc22366d8b 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml @@ -93,6 +93,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml index c5b250af03..5add6f8edd 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml @@ -96,6 +96,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml index f95d31e806..5d411470b7 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml @@ -86,6 +86,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml index 0f5a4a4934..d0eb7669fd 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml @@ -90,6 +90,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml index dfe6a31ec6..bb1d63c5dc 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml @@ -86,6 +86,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml index 9362129cb0..1df946c6c0 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml @@ -86,6 +86,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml index 0778446710..1c071aa98f 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml @@ -88,6 +88,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml index c1d9fb67a5..3c047314dd 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml @@ -86,6 +86,7 @@ org.apache.maven.plugins maven-failsafe-plugin + 3.1.2 From 970c875e3e4ceaf444e687a6be7be56bf548b183 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 11:42:21 +0300 Subject: [PATCH 039/100] test --- .github/workflows/composites/clean-space/action.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 69d61642fd..e110dc0c7e 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,6 +7,14 @@ runs: shell: bash run: | sudo apt-get update + + + # temporary workaround for an error in free disk space action + # https://github.com/jlumbroso/free-disk-space/issues/14 + - name: Update Package List and Remove Dotnet + shell: bash + run: | + sudo apt-get update - name: Free Disk Space uses: jlumbroso/free-disk-space@main From edcc9964527cf151de7c0f16346c679f8c4f33f4 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 12:20:39 +0300 Subject: [PATCH 040/100] test --- .github/workflows/composites/clean-space/action.yaml | 8 -------- .github/workflows/maven.yaml | 10 +++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index e110dc0c7e..69d61642fd 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,14 +7,6 @@ runs: shell: bash run: | sudo apt-get update - - - # temporary workaround for an error in free disk space action - # https://github.com/jlumbroso/free-disk-space/issues/14 - - name: Update Package List and Remove Dotnet - shell: bash - run: | - sudo apt-get update - name: Free Disk Space uses: jlumbroso/free-disk-space@main diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 6264d4c008..eb0740edf4 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 env: # this might get set to true if there is an existing cache of test times # this happens in 'matrix-bounds-on-test-times-cache-hit' @@ -96,7 +96,7 @@ jobs: test_when_cache_present: needs: [ build ] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30 # only run this one if there is a previous cache of test times @@ -145,7 +145,7 @@ jobs: test_when_cache_missing: needs: [ build ] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30 timeout-minutes: 60 @@ -197,7 +197,7 @@ jobs: uses: ./.github/workflows/composites/run-and-save-test-times-when-cache-missing save_test_times_when_cache_missing: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: [build, test_when_cache_missing ] steps: @@ -210,7 +210,7 @@ jobs: uses: ./.github/workflows/composites/test-times save_test_times_when_cache_present: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: [ build, test_when_cache_present ] steps: From 82d5f2ff89af9e96324715d3e9a151fc6e3639d9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 12:52:54 +0300 Subject: [PATCH 041/100] test --- .github/workflows/composites/clean-space/action.yaml | 1 + .github/workflows/maven.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 69d61642fd..e65d11f0c0 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,6 +7,7 @@ runs: shell: bash run: | sudo apt-get update + sudo apt-get remove google-cloud-sdk* - name: Free Disk Space uses: jlumbroso/free-disk-space@main diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index eb0740edf4..6264d4c008 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: # this might get set to true if there is an existing cache of test times # this happens in 'matrix-bounds-on-test-times-cache-hit' @@ -96,7 +96,7 @@ jobs: test_when_cache_present: needs: [ build ] - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30 # only run this one if there is a previous cache of test times @@ -145,7 +145,7 @@ jobs: test_when_cache_missing: needs: [ build ] - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest env: SEGMENT_DOWNLOAD_TIMEOUT_MINS: 30 timeout-minutes: 60 @@ -197,7 +197,7 @@ jobs: uses: ./.github/workflows/composites/run-and-save-test-times-when-cache-missing save_test_times_when_cache_missing: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: [build, test_when_cache_missing ] steps: @@ -210,7 +210,7 @@ jobs: uses: ./.github/workflows/composites/test-times save_test_times_when_cache_present: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: [ build, test_when_cache_present ] steps: From 2b56337faa481f1e02bb2514095caa36a2fb5e96 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 12:54:50 +0300 Subject: [PATCH 042/100] test --- .github/workflows/composites/clean-space/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index e65d11f0c0..a61f9558e1 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,7 +7,7 @@ runs: shell: bash run: | sudo apt-get update - sudo apt-get remove google-cloud-sdk* + sudo apt-get purge google-cloud-sdk - name: Free Disk Space uses: jlumbroso/free-disk-space@main From dcbc5decdccdae860f15a75e89a4322475779359 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 13:09:07 +0300 Subject: [PATCH 043/100] test --- .github/workflows/composites/clean-space/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index a61f9558e1..4f70007353 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,7 +7,7 @@ runs: shell: bash run: | sudo apt-get update - sudo apt-get purge google-cloud-sdk + sudo apt-get remove google-cloud-sdk - name: Free Disk Space uses: jlumbroso/free-disk-space@main From d48d61ff3c48e6ea6706aa220971881b56942647 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 13:17:16 +0300 Subject: [PATCH 044/100] test --- .github/workflows/composites/clean-space/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 4f70007353..b8e8b619a1 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,7 +7,7 @@ runs: shell: bash run: | sudo apt-get update - sudo apt-get remove google-cloud-sdk + sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri - name: Free Disk Space uses: jlumbroso/free-disk-space@main From db8d950892bf7400c7d55919a11564262d82b0a5 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 13:20:29 +0300 Subject: [PATCH 045/100] test --- .github/workflows/composites/clean-space/action.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index b8e8b619a1..fd1f337aa7 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -3,11 +3,11 @@ description: clean space runs: using: "composite" steps: - - name: apt-update - shell: bash - run: | - sudo apt-get update - sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri +# - name: apt-update +# shell: bash +# run: | +# sudo apt-get update +# sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri - name: Free Disk Space uses: jlumbroso/free-disk-space@main From ae31faf5be485cb1177be65ce40a83670ec73392 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 13:55:02 +0300 Subject: [PATCH 046/100] test --- .github/workflows/composites/clean-space/action.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index fd1f337aa7..3b2761a64c 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -3,11 +3,9 @@ description: clean space runs: using: "composite" steps: -# - name: apt-update -# shell: bash -# run: | -# sudo apt-get update -# sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + - name: gcloud + shell: bash + run: gcloud info - name: Free Disk Space uses: jlumbroso/free-disk-space@main From dfca45b9ef1a4618df5c7b2ab7bb0a6d8aaacc4a Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 14:08:20 +0300 Subject: [PATCH 047/100] test --- .github/workflows/composites/clean-space/action.yaml | 3 --- .github/workflows/maven.yaml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 3b2761a64c..f115de3a20 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -3,9 +3,6 @@ description: clean space runs: using: "composite" steps: - - name: gcloud - shell: bash - run: gcloud info - name: Free Disk Space uses: jlumbroso/free-disk-space@main diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 6264d4c008..4fcc70635b 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -29,9 +29,6 @@ jobs: - name: checkout project uses: actions/checkout@v2 - - name: clean space - uses: ./.github/workflows/composites/clean-space - - name: set env variables uses: ./.github/workflows/composites/env-variables From 34648ebd07b36a70d598ad3b61de9f629ac35c90 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 14:19:09 +0300 Subject: [PATCH 048/100] placeholder commit From 1eacf6cbbe1235a37b912ad6ec6f3bed0d4a952a Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 14:27:40 +0300 Subject: [PATCH 049/100] test --- .github/workflows/composites/clean-space/action.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index f115de3a20..3b2761a64c 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -3,6 +3,9 @@ description: clean space runs: using: "composite" steps: + - name: gcloud + shell: bash + run: gcloud info - name: Free Disk Space uses: jlumbroso/free-disk-space@main From c77b86acc4a4febe8da63b5783f0b1eac657fb71 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 14:39:06 +0300 Subject: [PATCH 050/100] test --- .github/workflows/composites/clean-space/action.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 3b2761a64c..e1bb096bd5 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -5,7 +5,9 @@ runs: steps: - name: gcloud shell: bash - run: gcloud info + run: | + sudo apt-get update + gcloud info - name: Free Disk Space uses: jlumbroso/free-disk-space@main From 5c244f5edb3ed12776f97dd28046d417e7b6ebd5 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 18:50:16 +0300 Subject: [PATCH 051/100] review comments --- spring-cloud-kubernetes-integration-tests/pom.xml | 11 +++++++++++ .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../pom.xml | 1 - .../spring-cloud-kubernetes-fabric8-istio-it/pom.xml | 1 - 18 files changed, 11 insertions(+), 17 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/pom.xml b/spring-cloud-kubernetes-integration-tests/pom.xml index ebd7479cf8..142af47a7c 100644 --- a/spring-cloud-kubernetes-integration-tests/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/pom.xml @@ -32,6 +32,17 @@ + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + + diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml index 2b5afdca5d..38f4e18e73 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-catalog-watcher/pom.xml @@ -86,7 +86,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml index 530756302e..382886e789 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-configmap-test-app/pom.xml @@ -55,7 +55,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml index 243f1a4d32..ec84212c8a 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-discovery-it/pom.xml @@ -96,7 +96,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml index 10a1503128..dfc5d03931 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/pom.xml @@ -95,7 +95,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml index 1aea888da1..61e6ba120f 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-loadbalancer-it/pom.xml @@ -91,7 +91,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml index 38b3156899..ba73ef90b8 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-secrets-event-reload-multiple-apps/spring-cloud-kubernetes-client-configuration-watcher-secrets-test-app/pom.xml @@ -55,7 +55,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml index 4179f2975c..69d3aac1de 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/pom.xml @@ -111,7 +111,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml index 512716a58c..74e485be7f 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-discoveryclient-it/pom.xml @@ -92,7 +92,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml index 0f93f700fb..e30c96300f 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml @@ -86,7 +86,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml index bc22366d8b..a1ba8bb15b 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-event-reload/pom.xml @@ -93,7 +93,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml index 5add6f8edd..c5b250af03 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap-polling-reload/pom.xml @@ -96,7 +96,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml index 5d411470b7..f95d31e806 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-configmap/pom.xml @@ -86,7 +86,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml index d0eb7669fd..0f5a4a4934 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery-with-bootstrap/pom.xml @@ -90,7 +90,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml index bb1d63c5dc..dfe6a31ec6 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-discovery/pom.xml @@ -86,7 +86,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml index 1df946c6c0..9362129cb0 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-loadbalancer/pom.xml @@ -86,7 +86,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml index 1c071aa98f..0778446710 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-secrets-event-reload/pom.xml @@ -88,7 +88,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml index 3c047314dd..c1d9fb67a5 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/pom.xml @@ -86,7 +86,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.1.2 From 6810e8f6bcff9ea9ca42b1d8a4e07d759df3fed9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 19:37:56 +0300 Subject: [PATCH 052/100] test --- .github/workflows/composites/clean-space/action.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index e1bb096bd5..f0e9488b01 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -7,7 +7,14 @@ runs: shell: bash run: | sudo apt-get update - gcloud info + sudo apt-get remove -y '^dotnet-.*' + sudo apt-get remove -y '^llvm-.*' + sudo apt-get remove -y 'php.*' + sudo apt-get remove -y '^mongodb-.*' + sudo apt-get remove -y '^mysql-.*' + sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + sudo apt-get autoremove -y + sudo apt-get clean - name: Free Disk Space uses: jlumbroso/free-disk-space@main @@ -16,5 +23,5 @@ runs: android: true dotnet: true haskell: true - large-packages: true + large-packages: false swap-storage: true From dc62bbc6eade9231fca82df7b7f7735ba7f85335 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 19:48:30 +0300 Subject: [PATCH 053/100] test --- .../composites/clean-space/action.yaml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index f0e9488b01..5f76a9f56a 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -12,16 +12,16 @@ runs: sudo apt-get remove -y 'php.*' sudo apt-get remove -y '^mongodb-.*' sudo apt-get remove -y '^mysql-.*' - sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + sudo apt-get remove -y azure-cli # google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri sudo apt-get autoremove -y sudo apt-get clean - - name: Free Disk Space - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - android: true - dotnet: true - haskell: true - large-packages: false - swap-storage: true +# - name: Free Disk Space +# uses: jlumbroso/free-disk-space@main +# with: +# tool-cache: true +# android: true +# dotnet: true +# haskell: true +# large-packages: false +# swap-storage: true From 5d5ea38c31d693dcb2836db9cca4484dde3a82ec Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 20:05:04 +0300 Subject: [PATCH 054/100] test --- .github/workflows/composites/clean-space/action.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 5f76a9f56a..07affc2139 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -12,9 +12,10 @@ runs: sudo apt-get remove -y 'php.*' sudo apt-get remove -y '^mongodb-.*' sudo apt-get remove -y '^mysql-.*' - sudo apt-get remove -y azure-cli # google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri - sudo apt-get autoremove -y - sudo apt-get clean + sudo apt-get remove -y azure-cli # google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + sudo apt-get remove -y google-cloud-sdk + #sudo apt-get autoremove -y + #sudo apt-get clean # - name: Free Disk Space # uses: jlumbroso/free-disk-space@main From f31d7414544fa277fb6d3c362aa91aadf5c2468a Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 20:16:31 +0300 Subject: [PATCH 055/100] test --- .github/workflows/composites/clean-space/action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 07affc2139..2bf4004714 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -14,8 +14,8 @@ runs: sudo apt-get remove -y '^mysql-.*' sudo apt-get remove -y azure-cli # google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri sudo apt-get remove -y google-cloud-sdk - #sudo apt-get autoremove -y - #sudo apt-get clean + sudo apt-get autoremove -y + sudo apt-get clean # - name: Free Disk Space # uses: jlumbroso/free-disk-space@main From 8de4b9c09390f9d952becc250ef4f4b68dc87bfa Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 20:24:27 +0300 Subject: [PATCH 056/100] test --- .../composites/clean-space/action.yaml | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 2bf4004714..1e33aa9f4f 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -3,6 +3,7 @@ description: clean space runs: using: "composite" steps: + - name: gcloud shell: bash run: | @@ -12,17 +13,15 @@ runs: sudo apt-get remove -y 'php.*' sudo apt-get remove -y '^mongodb-.*' sudo apt-get remove -y '^mysql-.*' - sudo apt-get remove -y azure-cli # google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri - sudo apt-get remove -y google-cloud-sdk - sudo apt-get autoremove -y + sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri sudo apt-get clean -# - name: Free Disk Space -# uses: jlumbroso/free-disk-space@main -# with: -# tool-cache: true -# android: true -# dotnet: true -# haskell: true -# large-packages: false -# swap-storage: true + - name: Free Disk Space + uses: jlumbroso/free-disk-space@main + with: + tool-cache: true + android: true + dotnet: true + haskell: true + large-packages: false + swap-storage: true From 7715ca5883f8968a4ef154c1b529c4ea128b67b5 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 20:32:09 +0300 Subject: [PATCH 057/100] test --- .github/workflows/composites/clean-space/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 1e33aa9f4f..db87c9a28d 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -13,7 +13,7 @@ runs: sudo apt-get remove -y 'php.*' sudo apt-get remove -y '^mongodb-.*' sudo apt-get remove -y '^mysql-.*' - sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri sudo apt-get clean - name: Free Disk Space From 40c45148a9da56eb0ef906a080c469180c52d958 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 20:43:14 +0300 Subject: [PATCH 058/100] test --- .github/workflows/composites/clean-space/action.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index db87c9a28d..792bd071a5 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -4,6 +4,10 @@ runs: using: "composite" steps: + - name: remove google-cloud-sdk + shell: bash + run: sudo apt-get remove -y google-cloud-sdk + - name: gcloud shell: bash run: | @@ -13,7 +17,8 @@ runs: sudo apt-get remove -y 'php.*' sudo apt-get remove -y '^mongodb-.*' sudo apt-get remove -y '^mysql-.*' - sudo apt-get remove -y azure-cli google-cloud-sdk google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri + sudo apt-get autoremove -y sudo apt-get clean - name: Free Disk Space From 67d1cc4eef488235ef73123bc0e6fc5a85769712 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 20:50:22 +0300 Subject: [PATCH 059/100] test --- .github/workflows/composites/clean-space/action.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 792bd071a5..10c8985855 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -6,12 +6,13 @@ runs: - name: remove google-cloud-sdk shell: bash - run: sudo apt-get remove -y google-cloud-sdk + run: | + sudo apt-get update + sudo apt-get remove -y google-cloud-sdk - name: gcloud shell: bash run: | - sudo apt-get update sudo apt-get remove -y '^dotnet-.*' sudo apt-get remove -y '^llvm-.*' sudo apt-get remove -y 'php.*' From 622cc946a8b4d8ced507053e3528a2901df50328 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 21:00:18 +0300 Subject: [PATCH 060/100] test --- .github/workflows/composites/clean-space/action.yaml | 1 + .github/workflows/maven.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 10c8985855..a0e78799a6 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -8,6 +8,7 @@ runs: shell: bash run: | sudo apt-get update + gcloud info sudo apt-get remove -y google-cloud-sdk - name: gcloud diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 4fcc70635b..6264d4c008 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -29,6 +29,9 @@ jobs: - name: checkout project uses: actions/checkout@v2 + - name: clean space + uses: ./.github/workflows/composites/clean-space + - name: set env variables uses: ./.github/workflows/composites/env-variables From 78734c14cb348d346f529a3238bc8afc0070fad3 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 21:02:57 +0300 Subject: [PATCH 061/100] test --- .github/workflows/composites/clean-space/action.yaml | 2 +- .github/workflows/maven.yaml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index a0e78799a6..23507eb189 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -11,7 +11,7 @@ runs: gcloud info sudo apt-get remove -y google-cloud-sdk - - name: gcloud + - name: same as 'large-packages' but without 'google-cloud-sdk' shell: bash run: | sudo apt-get remove -y '^dotnet-.*' diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 6264d4c008..4fcc70635b 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -29,9 +29,6 @@ jobs: - name: checkout project uses: actions/checkout@v2 - - name: clean space - uses: ./.github/workflows/composites/clean-space - - name: set env variables uses: ./.github/workflows/composites/env-variables From c2ad21e443aba983f7506eb185f17e838d28c20c Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 21:12:38 +0300 Subject: [PATCH 062/100] test --- .github/workflows/composites/clean-space/action.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 23507eb189..1e08c8f49b 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -4,13 +4,6 @@ runs: using: "composite" steps: - - name: remove google-cloud-sdk - shell: bash - run: | - sudo apt-get update - gcloud info - sudo apt-get remove -y google-cloud-sdk - - name: same as 'large-packages' but without 'google-cloud-sdk' shell: bash run: | From 1d853d206d1e049a9edea4956a9d02b870d8706f Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 21:15:51 +0300 Subject: [PATCH 063/100] test --- .github/workflows/composites/clean-space/action.yaml | 9 +++++++++ .github/workflows/maven.yaml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 1e08c8f49b..ba3b646879 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -4,6 +4,15 @@ runs: using: "composite" steps: + - name: manually remove gcloud + shell: bash + run: | + gcloud_sdk_root=$(gcloud info --format='value(installation.sdk_root)') + gcloud_global_config=$(gcloud info --format='value(config.paths.global_config_dir)') + + sudo rm -fr $gcloud_sdk_root + sudo rm -fr $gcloud_global_config + - name: same as 'large-packages' but without 'google-cloud-sdk' shell: bash run: | diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 4fcc70635b..6264d4c008 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -29,6 +29,9 @@ jobs: - name: checkout project uses: actions/checkout@v2 + - name: clean space + uses: ./.github/workflows/composites/clean-space + - name: set env variables uses: ./.github/workflows/composites/env-variables From 5e985c5e3c50e05f6b16c83a5a5537875cd5471d Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 21:31:06 +0300 Subject: [PATCH 064/100] test --- .github/workflows/composites/clean-space/action.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index ba3b646879..588253a3e6 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -10,6 +10,9 @@ runs: gcloud_sdk_root=$(gcloud info --format='value(installation.sdk_root)') gcloud_global_config=$(gcloud info --format='value(config.paths.global_config_dir)') + echo "will remove directory : $gcloud_sdk_root" + echo "will remove directory : $gcloud_global_config" + sudo rm -fr $gcloud_sdk_root sudo rm -fr $gcloud_global_config From c982060ef0d1317fa9161b4e0e116f652ba43079 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 21:38:38 +0300 Subject: [PATCH 065/100] test --- .github/workflows/maven.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/maven.yaml b/.github/workflows/maven.yaml index 6264d4c008..4fcc70635b 100644 --- a/.github/workflows/maven.yaml +++ b/.github/workflows/maven.yaml @@ -29,9 +29,6 @@ jobs: - name: checkout project uses: actions/checkout@v2 - - name: clean space - uses: ./.github/workflows/composites/clean-space - - name: set env variables uses: ./.github/workflows/composites/env-variables From 8a42c1582d13c7768cac841818aff5753390b940 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 22:20:46 +0300 Subject: [PATCH 066/100] fix build --- .github/workflows/composites/clean-space/action.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index 588253a3e6..2f9906ce2e 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -4,6 +4,9 @@ runs: using: "composite" steps: + ### this is supposed to be simpler, but it's a work-around for: + ### https://github.com/jlumbroso/free-disk-space/issues/14 + - name: manually remove gcloud shell: bash run: | From 6a07b131506b7ac03ade2a9fe11f690e1ca70bce Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Sep 2023 22:58:55 +0300 Subject: [PATCH 067/100] placeholder commit From e9077e285f78ad5c781754c45576ef431a9942a3 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 07:32:32 +0300 Subject: [PATCH 068/100] review comments --- .../action.yaml | 2 +- .../action.yaml | 2 +- .../pom.xml | 27 ++++++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml index 0cb4085b21..b1d18fef80 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml @@ -61,7 +61,7 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${TEST_ARG[@]} \ -e clean install \ - -P sonar -nsu --batch-mode \ + -P 'sonar, run-on-github-actions' -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index f658cfbf58..7130a907c9 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -150,7 +150,7 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ -e clean install \ - -P sonar -nsu --batch-mode \ + -P 'sonar, run-on-github-actions' -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ diff --git a/spring-cloud-kubernetes-integration-tests/pom.xml b/spring-cloud-kubernetes-integration-tests/pom.xml index 142af47a7c..d1b0cbaf50 100644 --- a/spring-cloud-kubernetes-integration-tests/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/pom.xml @@ -33,18 +33,25 @@ - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.1.2 - - - - + + + run-on-github-actions + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.1.2 + + + + + + + From 5a7695a53209e195dbc8d9ccf31ec74f2084fbc0 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 14:00:54 +0300 Subject: [PATCH 069/100] merge --- .../kubernetes-leader-election-example/pom.xml | 4 ++-- spring-cloud-kubernetes-integration-tests/pom.xml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml index d6bc61dbc0..e13b268c78 100644 --- a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml +++ b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml @@ -75,11 +75,11 @@ maven-surefire-plugin - 2.22.2 + 3.1.2 maven-failsafe-plugin - 2.22.2 + 3.1.2 diff --git a/spring-cloud-kubernetes-integration-tests/pom.xml b/spring-cloud-kubernetes-integration-tests/pom.xml index d1b0cbaf50..1dae169f19 100644 --- a/spring-cloud-kubernetes-integration-tests/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/pom.xml @@ -46,6 +46,12 @@ maven-failsafe-plugin 3.1.2 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + From 593b94f8c35908fd1c96282a84b7ea830fb4b13f Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 15:14:00 +0300 Subject: [PATCH 070/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 7130a907c9..546a266905 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -147,7 +147,7 @@ runs: echo "will run tests : $tests_to_run_in_current_index" - ./mvnw -s .settings.xml \ + ./mvnw -X -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ -e clean install \ -P 'sonar, run-on-github-actions' -nsu --batch-mode \ From 3666b6b5442ccd7c7eb44b22eea45d8a424545ba Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 19:33:44 +0300 Subject: [PATCH 071/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 546a266905..7130a907c9 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -147,7 +147,7 @@ runs: echo "will run tests : $tests_to_run_in_current_index" - ./mvnw -X -s .settings.xml \ + ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ -e clean install \ -P 'sonar, run-on-github-actions' -nsu --batch-mode \ From 036dc8edd5117644db50bb52aec5e98deae0278a Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 21:08:06 +0300 Subject: [PATCH 072/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 1 + .../kubernetes-leader-election-example/pom.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 7130a907c9..289e0d059f 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -149,6 +149,7 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ + -DUNIQUE_PER_MATRIX_STEP=${CURRENT_INDEX} -e clean install \ -P 'sonar, run-on-github-actions' -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ diff --git a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml index e245d5cfe8..7b9fe603b2 100644 --- a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml +++ b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml @@ -76,6 +76,9 @@ maven-surefire-plugin 3.1.2 + + ${project.build.directory}/surefire-reports/${UNIQUE_PER_MATRIX_STEP} + maven-failsafe-plugin From 4733c6ea94db402631a3e405d66cffd457e2d288 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 21:09:05 +0300 Subject: [PATCH 073/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 289e0d059f..c249a5bd62 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -149,7 +149,7 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ - -DUNIQUE_PER_MATRIX_STEP=${CURRENT_INDEX} + -DUNIQUE_PER_MATRIX_STEP=${CURRENT_INDEX} \ -e clean install \ -P 'sonar, run-on-github-actions' -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ From aff5a588e74083bbff0cb6da8f441af6e470f8d2 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Sep 2023 21:56:05 +0300 Subject: [PATCH 074/100] test --- .../run-and-save-test-times-when-cache-present/action.yaml | 1 - .../kubernetes-leader-election-example/pom.xml | 3 --- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index c249a5bd62..7130a907c9 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -149,7 +149,6 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ - -DUNIQUE_PER_MATRIX_STEP=${CURRENT_INDEX} \ -e clean install \ -P 'sonar, run-on-github-actions' -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ diff --git a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml index 7b9fe603b2..e245d5cfe8 100644 --- a/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml +++ b/spring-cloud-kubernetes-examples/kubernetes-leader-election-example/pom.xml @@ -76,9 +76,6 @@ maven-surefire-plugin 3.1.2 - - ${project.build.directory}/surefire-reports/${UNIQUE_PER_MATRIX_STEP} - maven-failsafe-plugin From e13bcd3209513dddd0fb2a72206f4d72478bb577 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 29 Sep 2023 09:33:32 +0300 Subject: [PATCH 075/100] fix --- .../composites/clean-space/action.yaml | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/.github/workflows/composites/clean-space/action.yaml b/.github/workflows/composites/clean-space/action.yaml index cba74e0221..f115de3a20 100644 --- a/.github/workflows/composites/clean-space/action.yaml +++ b/.github/workflows/composites/clean-space/action.yaml @@ -4,25 +4,6 @@ runs: using: "composite" steps: - ### this is supposed to be simpler, but it's a work-around for: - ### https://github.com/jlumbroso/free-disk-space/issues/14 - - - name: manually remove gcloud - shell: bash - run: sudo apt-get remove google-cloud-cli - - - name: same as 'large-packages' but without 'google-cloud-sdk' - shell: bash - run: | - sudo apt-get remove -y '^dotnet-.*' - sudo apt-get remove -y '^llvm-.*' - sudo apt-get remove -y 'php.*' - sudo apt-get remove -y '^mongodb-.*' - sudo apt-get remove -y '^mysql-.*' - sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri - sudo apt-get autoremove -y - sudo apt-get clean - - name: Free Disk Space uses: jlumbroso/free-disk-space@main with: @@ -30,5 +11,5 @@ runs: android: true dotnet: true haskell: true - large-packages: false + large-packages: true swap-storage: true From 0515920476866923c1b6bfb0a9cc4257490f0452 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 29 Sep 2023 12:18:07 +0300 Subject: [PATCH 076/100] fix --- .../composites/pre-test-actions/action.yaml | 2 +- .../action.yaml | 3 ++- .../action.yaml | 3 ++- pom.xml | 13 +++++++++-- .../pom.xml | 23 ------------------- 5 files changed, 16 insertions(+), 28 deletions(-) diff --git a/.github/workflows/composites/pre-test-actions/action.yaml b/.github/workflows/composites/pre-test-actions/action.yaml index 657c55e886..3fd401e81f 100644 --- a/.github/workflows/composites/pre-test-actions/action.yaml +++ b/.github/workflows/composites/pre-test-actions/action.yaml @@ -25,7 +25,7 @@ runs: - name: build project shell: bash run: | - ./mvnw clean install -Dskip.build.image=true -DskipITs -DskipTests -T1C -U -B -q + ./mvnw clean install -DCURRENT_INSTANCE=${CURRENT_INDEX} -Dskip.build.image=true -DskipITs -DskipTests -T1C -U -B -q - name: build controllers project uses: ./.github/workflows/composites/build-controllers-project diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml index b1d18fef80..d262d89bbd 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-missing/action.yaml @@ -60,8 +60,9 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${TEST_ARG[@]} \ + -DCURRENT_INSTANCE=${CURRENT_INDEX} \ -e clean install \ - -P 'sonar, run-on-github-actions' -nsu --batch-mode \ + -P sonar -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ diff --git a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml index 7130a907c9..ce2242c3fc 100644 --- a/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml +++ b/.github/workflows/composites/run-and-save-test-times-when-cache-present/action.yaml @@ -149,8 +149,9 @@ runs: ./mvnw -s .settings.xml \ -DtestsToRun=${tests_to_run_in_current_index} \ + -DCURRENT_INSTANCE=${CURRENT_INDEX} \ -e clean install \ - -P 'sonar, run-on-github-actions' -nsu --batch-mode \ + -P sonar -nsu --batch-mode \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ -Dhttp.keepAlive=false \ -Dmaven.wagon.http.pool=false \ diff --git a/pom.xml b/pom.xml index 2f693f6818..199db284b2 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,7 @@ + one 4.8.1 4.0.5-SNAPSHOT @@ -69,8 +70,6 @@ 4.0.1 4.0.5-SNAPSHOT - 3.1.0 - true true @@ -205,8 +204,18 @@ ${testsToRun} + ${project.build.directory}/surefire-reports/${CURRENT_INSTANCE} + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + ${project.build.directory}/failsafe-reports/${CURRENT_INSTANCE} + org.apache.maven.plugins maven-checkstyle-plugin diff --git a/spring-cloud-kubernetes-integration-tests/pom.xml b/spring-cloud-kubernetes-integration-tests/pom.xml index 1dae169f19..03363f509a 100644 --- a/spring-cloud-kubernetes-integration-tests/pom.xml +++ b/spring-cloud-kubernetes-integration-tests/pom.xml @@ -35,29 +35,6 @@ - - - run-on-github-actions - - - - - org.apache.maven.plugins - maven-failsafe-plugin - 3.1.2 - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.1.2 - - - - - - - From 565679c21b8e39d15cd6208669e341d6184b65ab Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 29 Sep 2023 12:24:12 +0300 Subject: [PATCH 077/100] test --- .../composites/build-controllers-project/action.yaml | 6 +++++- .github/workflows/composites/pre-test-actions/action.yaml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/composites/build-controllers-project/action.yaml b/.github/workflows/composites/build-controllers-project/action.yaml index 307451c8f5..df34f3c443 100644 --- a/.github/workflows/composites/build-controllers-project/action.yaml +++ b/.github/workflows/composites/build-controllers-project/action.yaml @@ -7,5 +7,9 @@ runs: shell: bash run: | cd spring-cloud-kubernetes-controllers - .././mvnw -T 1C -U clean install + .././mvnw -DCURRENT_INSTANCE=${CURRENT_INDEX} -T 1C -U clean install cd .. + + - name: show target path + shell: bash + run: ls spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configuration-watcher/target/surefire-reports diff --git a/.github/workflows/composites/pre-test-actions/action.yaml b/.github/workflows/composites/pre-test-actions/action.yaml index 3fd401e81f..657c55e886 100644 --- a/.github/workflows/composites/pre-test-actions/action.yaml +++ b/.github/workflows/composites/pre-test-actions/action.yaml @@ -25,7 +25,7 @@ runs: - name: build project shell: bash run: | - ./mvnw clean install -DCURRENT_INSTANCE=${CURRENT_INDEX} -Dskip.build.image=true -DskipITs -DskipTests -T1C -U -B -q + ./mvnw clean install -Dskip.build.image=true -DskipITs -DskipTests -T1C -U -B -q - name: build controllers project uses: ./.github/workflows/composites/build-controllers-project From 3a869235fd3a1df0ea440725b3bfaabb0c9d929f Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 29 Sep 2023 15:27:10 +0300 Subject: [PATCH 078/100] test --- .../workflows/composites/build-controllers-project/action.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/composites/build-controllers-project/action.yaml b/.github/workflows/composites/build-controllers-project/action.yaml index df34f3c443..f9df2c519d 100644 --- a/.github/workflows/composites/build-controllers-project/action.yaml +++ b/.github/workflows/composites/build-controllers-project/action.yaml @@ -5,6 +5,8 @@ runs: steps: - name: build controllers project shell: bash + env: + CURRENT_INDEX: ${{ matrix.current_index }} run: | cd spring-cloud-kubernetes-controllers .././mvnw -DCURRENT_INSTANCE=${CURRENT_INDEX} -T 1C -U clean install From 03274168fa2133c0277350d84598264a5ccd0ec5 Mon Sep 17 00:00:00 2001 From: wind57 Date: Mon, 2 Oct 2023 15:49:34 +0300 Subject: [PATCH 079/100] review comments --- .../composites/build-controllers-project/action.yaml | 4 ---- pom.xml | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/composites/build-controllers-project/action.yaml b/.github/workflows/composites/build-controllers-project/action.yaml index f9df2c519d..dff8da1648 100644 --- a/.github/workflows/composites/build-controllers-project/action.yaml +++ b/.github/workflows/composites/build-controllers-project/action.yaml @@ -11,7 +11,3 @@ runs: cd spring-cloud-kubernetes-controllers .././mvnw -DCURRENT_INSTANCE=${CURRENT_INDEX} -T 1C -U clean install cd .. - - - name: show target path - shell: bash - run: ls spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configuration-watcher/target/surefire-reports diff --git a/pom.xml b/pom.xml index 199db284b2..271e4616b0 100644 --- a/pom.xml +++ b/pom.xml @@ -62,6 +62,10 @@ + + + + one 4.8.1 From 5eb8ee81dbe43bbc23eb3b61e8d586a1ebab2a26 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sun, 8 Oct 2023 11:18:24 +0300 Subject: [PATCH 080/100] dirty (integration tests should fail) --- .../cloud/kubernetes/fabric8/reload/App.java | 5 ----- .../kubernetes/fabric8/reload/LeftProperties.java | 13 ------------- 2 files changed, 18 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java index c0429da65d..f6a855befd 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java @@ -24,14 +24,9 @@ * @author wind57 */ @SpringBootApplication -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapApp.java -@EnableConfigurationProperties({ ConfigMapProperties.class, ConfigMapPropertiesNoMount.class }) -public class ConfigMapApp { -======== @EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class, ConfigMapProperties.class, SecretProperties.class }) public class App { ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java public static void main(String[] args) { SpringApplication.run(App.class, args); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/LeftProperties.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/LeftProperties.java index 07a55ae45d..4d3d30d57d 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/LeftProperties.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/LeftProperties.java @@ -26,25 +26,12 @@ public class LeftProperties { private String value; -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/configmap/polling/reload/ConfigMapController.java - private final ConfigMapPropertiesNoMount propertiesNoMount; - - public ConfigMapController(ConfigMapProperties properties, ConfigMapPropertiesNoMount propertiesNoMount) { - this.properties = properties; - this.propertiesNoMount = propertiesNoMount; -======== public String getValue() { return value; ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/LeftProperties.java } public void setValue(String value) { this.value = value; } - @GetMapping("/key-no-mount") - public String keyNoMount() { - return propertiesNoMount.getKey(); - } - } From f10aa59d06b6aefda42a777d0610dd5e02cbf03d Mon Sep 17 00:00:00 2001 From: wind57 Date: Sun, 8 Oct 2023 14:46:01 +0300 Subject: [PATCH 081/100] dirty --- .../src/main/resources/application-mount.yaml | 3 - .../resources/bootstrap-with-bootstrap.yaml | 6 -- ...edPollingReloadConfigMapMountDelegate.java | 79 ------------------- .../fabric8/reload/Fabric8EventReloadIT.java | 20 ++--- .../kubernetes/fabric8/reload/TestUtil.java | 56 ------------- .../src/test/resources/deployment.yaml | 17 ---- .../src/test/resources/ingress.yaml | 9 --- 7 files changed, 6 insertions(+), 184 deletions(-) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/bootstrap-with-bootstrap.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml index cd1765f5c8..66dc860a12 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml @@ -9,9 +9,6 @@ spring: strategy: shutdown mode: polling period: 5000 - config: - paths: - - /tmp/application.properties config: import: "kubernetes:" diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/bootstrap-with-bootstrap.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/bootstrap-with-bootstrap.yaml deleted file mode 100644 index 0aed2eb9dd..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/bootstrap-with-bootstrap.yaml +++ /dev/null @@ -1,6 +0,0 @@ -spring: - cloud: - kubernetes: - config: - paths: - - /tmp/application.properties diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java deleted file mode 100644 index 450494e445..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/BootstrapEnabledPollingReloadConfigMapMountDelegate.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.fabric8.reload; - -import java.io.InputStream; -import java.time.Duration; -import java.util.Map; - -import io.fabric8.kubernetes.api.model.ConfigMap; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.utils.Serialization; -import org.junit.jupiter.api.Assertions; -import org.testcontainers.k3s.K3sContainer; - -import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; -import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util; -import org.springframework.http.HttpMethod; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.awaitility.Awaitility.await; - -final class BootstrapEnabledPollingReloadConfigMapMountDelegate { - - /** - *
-	 *     - we have bootstrap enabled, which means we will 'locate' property sources
-	 *       from config maps.
-	 *     - there are no explicit config maps to search for, but what we will also read,
-	 *     	 is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
-	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
-	 * 
- */ - static void testPollingReloadConfigMapWithBootstrap(KubernetesClient client, Util util, K3sContainer container, - String appLabelValue) { - // (1) - Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", container, appLabelValue); - // (2) - Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", container, - appLabelValue); - // (3) - WebClient webClient = TestUtil.builder().baseUrl("http://localhost/key").build(); - String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(TestUtil.retrySpec()).block(); - - // we first read the initial value from the configmap - Assertions.assertEquals("as-mount-initial", result); - - // replace data in configmap and wait for k8s to pick it up - // our polling will detect that and restart the app - InputStream configMapStream = util.inputStream("configmap.yaml"); - ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); - client.configMaps().inNamespace("default").resource(configMap).createOrReplace(); - - await().timeout(Duration.ofSeconds(360)).until(() -> webClient.method(HttpMethod.GET).retrieve() - .bodyToMono(String.class).retryWhen(TestUtil.retrySpec()).block().equals("as-mount-changed")); - - } - -} diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java index 98ba5cef4d..06cdd59ae6 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java @@ -132,14 +132,13 @@ void testInformFromOneNamespaceEventNotTriggered() { return "left-initial".equals(innerResult); }); - testInformFromOneNamespaceEventTriggered(); - testInform(); - testInformFromOneNamespaceEventTriggeredSecretsDisabled(); - testDataChangesInConfigMap(); + // testInformFromOneNamespaceEventTriggered(); + // testInform(); + // testInformFromOneNamespaceEventTriggeredSecretsDisabled(); + // testDataChangesInConfigMap(); testConfigMapPollingReload(); - testConfigMapMountPollingReload(); - testPollingReloadConfigMapWithBootstrap(); - testSecretReload(); + // testConfigMapMountPollingReload(); + // testSecretReload(); } /** @@ -314,13 +313,6 @@ void testConfigMapMountPollingReload() { ConfigMapMountPollingReloadDelegate.testConfigMapMountPollingReload(client, util, K3S, IMAGE_NAME); } - void testPollingReloadConfigMapWithBootstrap() { - TestUtil.reCreateSources(util, client); - TestUtil.patchSeven(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); - BootstrapEnabledPollingReloadConfigMapMountDelegate.testPollingReloadConfigMapWithBootstrap(client, util, K3S, - IMAGE_NAME); - } - void testSecretReload() { TestUtil.patchEight(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); SecretsEventsReloadDelegate.testSecretReload(client, K3S, IMAGE_NAME); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java index 0c3281925a..332e53fd08 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java @@ -247,58 +247,6 @@ final class TestUtil { } """; - private static final String BODY_SEVEN = """ - { - "spec": { - "template": { - "spec": { - "volumes": [ - { - "configMap": { - "defaultMode": 420, - "name": "poll-reload" - }, - "name": "config-map-volume" - } - ], - "containers": [{ - "volumeMounts": [ - { - "mountPath": "/tmp", - "name": "config-map-volume" - } - ], - "name": "spring-cloud-kubernetes-fabric8-client-configmap-event-reload", - "image": "image_name_here", - "env": [ - { - "name": "SPRING_PROFILES_ACTIVE", - "value": "with-bootstrap" - }, - { - "name": "SPRING_CLOUD_BOOTSTRAP_ENABLED", - "value": "TRUE" - }, - { - "name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD", - "value": "DEBUG" - }, - { - "name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG", - "value": "DEBUG" - }, - { - "name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS", - "value": "DEBUG" - } - ] - }] - } - } - } - } - """; - private static final String BODY_EIGHT = """ { "spec": { @@ -366,10 +314,6 @@ static void patchSix(Util util, String dockerImage, String deploymentName, Strin util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_SIX, POD_LABELS); } - static void patchSeven(Util util, String dockerImage, String deploymentName, String namespace) { - util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_SEVEN, POD_LABELS); - } - static void patchEight(Util util, String dockerImage, String deploymentName, String namespace) { util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_EIGHT, POD_LABELS); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/deployment.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/deployment.yaml index 8f13a0b665..aba13d5127 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/deployment.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/deployment.yaml @@ -1,22 +1,6 @@ apiVersion: apps/v1 kind: Deployment metadata: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/deployment.yaml - name: fabric8-client-configmap-deployment-polling-and-import-reload -spec: - selector: - matchLabels: - app: fabric8-client-configmap-polling-and-import-reload - template: - metadata: - labels: - app: fabric8-client-configmap-polling-and-import-reload - spec: - serviceAccountName: spring-cloud-kubernetes-serviceaccount - containers: - - name: fabric8-client-configmap-polling-and-import-reload - image: docker.io/springcloud/fabric8-client-configmap-polling-and-import-reload -======== name: spring-cloud-kubernetes-fabric8-client-reload spec: selector: @@ -31,7 +15,6 @@ spec: containers: - name: spring-cloud-kubernetes-fabric8-client-reload image: docker.io/springcloud/spring-cloud-kubernetes-fabric8-client-reload ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/deployment.yaml imagePullPolicy: IfNotPresent readinessProbe: httpGet: diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/ingress.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/ingress.yaml index 7c3a17dcb3..d34a7ebebe 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/ingress.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/ingress.yaml @@ -1,12 +1,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml name: spring-k8s-client-ingress-reload -======== - name: spring-cloud-kubernetes-fabric8-client-reload-ingress ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/ingress.yaml - namespace: default spec: rules: - http: @@ -15,10 +10,6 @@ spec: pathType: Prefix backend: service: -<<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/fabric8-client-configmap-polling-and-import-reload/src/test/resources/ingress.yaml - name: fabric8-client-configmap-polling-and-import-reload -======== name: spring-cloud-kubernetes-fabric8-client-reload ->>>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/ingress.yaml port: number: 8080 From ffc71f084f64be46a491150dbbbc3c5f472350e8 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sun, 8 Oct 2023 18:04:01 +0300 Subject: [PATCH 082/100] fix --- .../reload/ReloadConfigMapMountDelegate.java | 2 +- .../cloud/kubernetes/fabric8/reload/App.java | 2 +- .../reload/ConfigMapNoMountProperties.java | 34 +++++++++++++ .../fabric8/reload/ConfigMapProperties.java | 2 +- .../kubernetes/fabric8/reload/Controller.java | 10 +++- .../resources/application-configtree.yaml | 16 ++++++ .../src/main/resources/application-mount.yaml | 14 ------ .../ConfigMapMountPollingReloadDelegate.java | 50 ++++++++++--------- .../fabric8/reload/Fabric8EventReloadIT.java | 22 +++++--- .../kubernetes/fabric8/reload/TestUtil.java | 15 ++++-- .../test/resources/configmap-configtree.yaml | 7 +++ 11 files changed, 123 insertions(+), 51 deletions(-) create mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapNoMountProperties.java create mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml create mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/configmap-configtree.yaml diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java index ef09f09c6e..54d33d8442 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/ReloadConfigMapMountDelegate.java @@ -47,7 +47,7 @@ private ReloadConfigMapMountDelegate() { * - the property above means that at the moment we will be searching for config maps that only * match the application name, in this specific test there is no such config map. * - what we will also read, is /tmp directory according to configtree rules. - * As such, a property "props.key" (see deployment-mount.yaml) will be in environment. + * As such, a property "props.key" (see K8sClientConfigMapReloadITUtil::BODY_FIVE) will be in environment. * * - we then change the config map content, wait for configuration watcher to pick up the change * and schedule a refresh event, based on http. diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java index f6a855befd..1077120154 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/App.java @@ -25,7 +25,7 @@ */ @SpringBootApplication @EnableConfigurationProperties({ LeftProperties.class, RightProperties.class, RightWithLabelsProperties.class, - ConfigMapProperties.class, SecretProperties.class }) + ConfigMapProperties.class, SecretProperties.class, ConfigMapNoMountProperties.class }) public class App { public static void main(String[] args) { diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapNoMountProperties.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapNoMountProperties.java new file mode 100644 index 0000000000..f2d3ae503c --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapNoMountProperties.java @@ -0,0 +1,34 @@ +/* + * Copyright 2013-2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.cloud.kubernetes.fabric8.reload; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("props") +public class ConfigMapNoMountProperties { + + private String key; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + +} diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapProperties.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapProperties.java index c6f4229b04..5f8f78c616 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapProperties.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapProperties.java @@ -21,7 +21,7 @@ /** * @author wind57 */ -@ConfigurationProperties("props") +@ConfigurationProperties("from.properties") public class ConfigMapProperties { private String key; diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/Controller.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/Controller.java index e79c04ba06..58ec809f24 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/Controller.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/reload/Controller.java @@ -35,14 +35,17 @@ public class Controller { private final SecretProperties secretProperties; + private final ConfigMapNoMountProperties configMapNoMountProperties; + public Controller(LeftProperties leftProperties, RightProperties rightProperties, RightWithLabelsProperties rightWithLabelsProperties, ConfigMapProperties configMapProperties, - SecretProperties secretProperties) { + SecretProperties secretProperties, ConfigMapNoMountProperties configMapNoMountProperties) { this.leftProperties = leftProperties; this.rightProperties = rightProperties; this.rightWithLabelsProperties = rightWithLabelsProperties; this.configMapProperties = configMapProperties; this.secretProperties = secretProperties; + this.configMapNoMountProperties = configMapNoMountProperties; } @GetMapping("/left") @@ -65,6 +68,11 @@ public String key() { return configMapProperties.getKey(); } + @GetMapping("/key-no-mount") + public String keyNoMount() { + return configMapNoMountProperties.getKey(); + } + @GetMapping("/key-from-secret") public String keyFromSecret() { return secretProperties.getKey(); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml new file mode 100644 index 0000000000..7a977072cb --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml @@ -0,0 +1,16 @@ +spring: + application: + name: poll-reload-mount + config: + import: "kubernetes:,configtree:/tmp/" + +management: + endpoint: + refresh: + enabled: true + restart: + enabled: true + endpoints: + web: + exposure: + include: '*' diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml deleted file mode 100644 index 66dc860a12..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-mount.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: poll-reload-mount - cloud: - kubernetes: - reload: - enabled: true - monitoring-config-maps: true - strategy: shutdown - mode: polling - period: 5000 - config: - import: "kubernetes:" - diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapMountPollingReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapMountPollingReloadDelegate.java index 2642296b09..2c4cddca22 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapMountPollingReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/ConfigMapMountPollingReloadDelegate.java @@ -18,20 +18,21 @@ import java.io.InputStream; import java.time.Duration; +import java.util.HashMap; import java.util.Map; +import java.util.Optional; import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.utils.Serialization; import org.junit.jupiter.api.Assertions; -import org.testcontainers.k3s.K3sContainer; -import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient; import static org.awaitility.Awaitility.await; +import static org.springframework.cloud.kubernetes.fabric8.reload.TestUtil.replaceConfigMap; /** * @author wind57 @@ -40,28 +41,19 @@ final class ConfigMapMountPollingReloadDelegate { /** *
-	 *     - we have "spring.config.import: kubernetes", which means we will 'locate' property sources
+	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
 	 *       from config maps.
 	 *     - the property above means that at the moment we will be searching for config maps that only
 	 *       match the application name, in this specific test there is no such config map.
-	 *     - what we will also read, is 'spring.cloud.kubernetes.config.paths', which we have set to
-	 *     	 '/tmp/application.properties'
-	 *       in this test. That is populated by the volumeMounts (see deployment-mount.yaml)
-	 *     - we first assert that we are actually reading the path based source via (1), (2) and (3).
+	 *     - what we will also read, is /tmp directory according to configtree rules.
+	 *       As such, a property "props.key" (see TestUtil::BODY_SIX) will be in environment.
 	 *
-	 *     - we then change the config map content, wait for k8s to pick it up and replace them
-	 *     - our polling will then detect that change, and trigger a reload.
+	 *     - we then change the config map content, wait for configuration watcher to pick up the change
+	 *       and schedule a refresh event, based on http.
 	 * 
*/ - static void testConfigMapMountPollingReload(KubernetesClient client, Util util, K3sContainer container, - String appLabelValue) { - // (1) - Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", container, appLabelValue); - // (2) - Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", container, - appLabelValue); - // (3) - WebClient webClient = TestUtil.builder().baseUrl("http://localhost/key").build(); + static void testConfigMapMountPollingReload(KubernetesClient client, Util util) { + WebClient webClient = TestUtil.builder().baseUrl("http://localhost/key-no-mount").build(); String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) .retryWhen(TestUtil.retrySpec()).block(); @@ -70,12 +62,24 @@ static void testConfigMapMountPollingReload(KubernetesClient client, Util util, // replace data in configmap and wait for k8s to pick it up // our polling will detect that and restart the app - InputStream configMapStream = util.inputStream("configmap.yaml"); - ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class); - configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed")); - client.configMaps().inNamespace("default").resource(configMap).createOrReplace(); + InputStream configMapMountStream = util.inputStream("configmap-configtree.yaml"); + ConfigMap configMapMount = Serialization.unmarshal(configMapMountStream, ConfigMap.class); + configMapMount.setData(Map.of("from.properties", "as-mount-changed")); + // add label so that configuration-watcher picks this up + Map existingLabels = new HashMap<>( + Optional.ofNullable(configMapMount.getMetadata().getLabels()).orElse(Map.of())); + existingLabels.put("spring.cloud.kubernetes.config", "true"); + configMapMount.getMetadata().setLabels(existingLabels); - await().timeout(Duration.ofSeconds(360)).until(() -> webClient.method(HttpMethod.GET).retrieve() + // add annotation for which app to send the http event to + Map existingAnnotations = new HashMap<>( + Optional.ofNullable(configMapMount.getMetadata().getAnnotations()).orElse(Map.of())); + existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", + "spring-cloud-kubernetes-fabric8-client-reload"); + configMapMount.getMetadata().setAnnotations(existingAnnotations); + replaceConfigMap(client, configMapMount, "default"); + + await().timeout(Duration.ofSeconds(180)).until(() -> webClient.method(HttpMethod.GET).retrieve() .bodyToMono(String.class).retryWhen(TestUtil.retrySpec()).block().equals("as-mount-changed")); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java index 06cdd59ae6..873aaedc5b 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java @@ -50,6 +50,8 @@ */ class Fabric8EventReloadIT { + private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; + private static final String IMAGE_NAME = "spring-cloud-kubernetes-fabric8-client-reload"; private static final String DOCKER_IMAGE = "docker.io/springcloud/" + IMAGE_NAME + ":" + pomVersion(); @@ -65,9 +67,13 @@ class Fabric8EventReloadIT { @BeforeAll static void beforeAll() throws Exception { K3S.start(); + Commons.validateImage(IMAGE_NAME, K3S); Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); + Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S); + util = new Util(K3S); client = util.client(); @@ -75,6 +81,7 @@ static void beforeAll() throws Exception { util.createNamespace("right"); util.setUpClusterWide(NAMESPACE, Set.of("left", "right")); util.setUp(NAMESPACE); + util.configWatcher(Phase.CREATE); manifests(Phase.CREATE); } @@ -83,6 +90,7 @@ static void beforeAll() throws Exception { static void afterAll() throws Exception { util.deleteNamespace("left"); util.deleteNamespace("right"); + util.configWatcher(Phase.DELETE); Commons.cleanUp(IMAGE_NAME, K3S); Commons.systemPrune(); @@ -132,13 +140,13 @@ void testInformFromOneNamespaceEventNotTriggered() { return "left-initial".equals(innerResult); }); - // testInformFromOneNamespaceEventTriggered(); - // testInform(); - // testInformFromOneNamespaceEventTriggeredSecretsDisabled(); - // testDataChangesInConfigMap(); + testInformFromOneNamespaceEventTriggered(); + testInform(); + testInformFromOneNamespaceEventTriggeredSecretsDisabled(); + testDataChangesInConfigMap(); testConfigMapPollingReload(); - // testConfigMapMountPollingReload(); - // testSecretReload(); + testConfigMapMountPollingReload(); + testSecretReload(); } /** @@ -310,7 +318,7 @@ void testConfigMapPollingReload() { void testConfigMapMountPollingReload() { TestUtil.reCreateSources(util, client); TestUtil.patchSix(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); - ConfigMapMountPollingReloadDelegate.testConfigMapMountPollingReload(client, util, K3S, IMAGE_NAME); + ConfigMapMountPollingReloadDelegate.testConfigMapMountPollingReload(client, util); } void testSecretReload() { diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java index 332e53fd08..c92d4d9c75 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java @@ -204,7 +204,13 @@ final class TestUtil { { "configMap": { "defaultMode": 420, - "name": "poll-reload" + "name": "poll-reload-configtree", + "items": [ + { + "key": "from.properties", + "path": "key" + } + ] }, "name": "config-map-volume" } @@ -212,7 +218,7 @@ final class TestUtil { "containers": [{ "volumeMounts": [ { - "mountPath": "/tmp", + "mountPath": "/tmp/props", "name": "config-map-volume" } ], @@ -221,7 +227,7 @@ final class TestUtil { "env": [ { "name": "SPRING_PROFILES_ACTIVE", - "value": "mount" + "value": "configtree" }, { "name": "SPRING_CLOUD_BOOTSTRAP_ENABLED", @@ -276,14 +282,17 @@ static void reCreateSources(Util util, KubernetesClient client) { InputStream leftConfigMapStream = util.inputStream("left-configmap.yaml"); InputStream rightConfigMapStream = util.inputStream("right-configmap.yaml"); InputStream configMapStream = util.inputStream("configmap.yaml"); + InputStream configMapMountStream = util.inputStream("configmap-configtree.yaml"); ConfigMap leftConfigMap = Serialization.unmarshal(leftConfigMapStream, ConfigMap.class); ConfigMap rightConfigMap = Serialization.unmarshal(rightConfigMapStream, ConfigMap.class); ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class); + ConfigMap configMapMount = Serialization.unmarshal(configMapMountStream, ConfigMap.class); replaceConfigMap(client, leftConfigMap, "left"); replaceConfigMap(client, rightConfigMap, "right"); replaceConfigMap(client, configMap, "default"); + replaceConfigMap(client, configMapMount, "default"); } static void replaceConfigMap(KubernetesClient client, ConfigMap configMap, String namespace) { diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/configmap-configtree.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/configmap-configtree.yaml new file mode 100644 index 0000000000..810e482a7c --- /dev/null +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/configmap-configtree.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: poll-reload-configtree + namespace: default +data: + from.properties: "as-mount-initial" From 7aece4d42b9007fb5076c933490ff12c7e9e31bd Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Oct 2023 20:39:22 +0300 Subject: [PATCH 083/100] rename method --- .../kubernetes/fabric8/reload/Fabric8EventReloadIT.java | 2 +- .../cloud/kubernetes/fabric8/reload/TestUtil.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java index 873aaedc5b..98a3777610 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/Fabric8EventReloadIT.java @@ -322,7 +322,7 @@ void testConfigMapMountPollingReload() { } void testSecretReload() { - TestUtil.patchEight(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); + TestUtil.patchSeven(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); SecretsEventsReloadDelegate.testSecretReload(client, K3S, IMAGE_NAME); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java index c92d4d9c75..1fe0498038 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/reload/TestUtil.java @@ -253,7 +253,7 @@ final class TestUtil { } """; - private static final String BODY_EIGHT = """ + private static final String BODY_SEVEN = """ { "spec": { "template": { @@ -323,8 +323,8 @@ static void patchSix(Util util, String dockerImage, String deploymentName, Strin util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_SIX, POD_LABELS); } - static void patchEight(Util util, String dockerImage, String deploymentName, String namespace) { - util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_EIGHT, POD_LABELS); + static void patchSeven(Util util, String dockerImage, String deploymentName, String namespace) { + util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_SEVEN, POD_LABELS); } static WebClient.Builder builder() { From 564c86585fa4a8f07febda6b0cdacab7d81e3cca Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Oct 2023 22:35:21 +0300 Subject: [PATCH 084/100] fix --- .../fabric8/client/reload/ConfigMapNoMountProperties.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapNoMountProperties.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapNoMountProperties.java index f2d3ae503c..2636073e3e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapNoMountProperties.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapNoMountProperties.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.cloud.kubernetes.fabric8.reload; +package org.springframework.cloud.kubernetes.fabric8.client.reload; import org.springframework.boot.context.properties.ConfigurationProperties; From 9e9d7b08decb0d0d89c811027221c6614c790fc7 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Oct 2023 22:43:39 +0300 Subject: [PATCH 085/100] fix --- .../client/reload/ConfigMapMountPollingReloadDelegate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java index 6f80cec400..ed500fd967 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java @@ -77,7 +77,7 @@ static void testConfigMapMountPollingReload(KubernetesClient client, Util util) existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", "spring-cloud-kubernetes-fabric8-client-reload"); configMapMount.getMetadata().setAnnotations(existingAnnotations); - replaceConfigMap(client, configMapMount, "default"); + TestUtil.replaceConfigMap(client, configMapMount, "default"); await().timeout(Duration.ofSeconds(180)).until(() -> webClient.method(HttpMethod.GET).retrieve() .bodyToMono(String.class).retryWhen(TestUtil.retrySpec()).block().equals("as-mount-changed")); From 2d67ca55489522a9dfbeaf0452df6b3a4a20070e Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Oct 2023 22:51:17 +0300 Subject: [PATCH 086/100] checkstyle --- .../client/reload/ConfigMapMountPollingReloadDelegate.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java index ed500fd967..c0b1450f24 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java @@ -32,7 +32,6 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.awaitility.Awaitility.await; -import static org.springframework.cloud.kubernetes.fabric8.reload.TestUtil.replaceConfigMap; /** * @author wind57 From 0c02d742513179ffcfa5d6e381b6804dfcb054c4 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sat, 14 Oct 2023 13:03:22 +0300 Subject: [PATCH 087/100] fix --- .../configmap/K8sClientConfigMapReloadIT.java | 18 +--- .../PollingReloadConfigMapMountDelegate.java | 91 ------------------- 2 files changed, 1 insertion(+), 108 deletions(-) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java index e7f23a5327..fae4ba8285 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java @@ -43,37 +43,21 @@ import org.springframework.web.reactive.function.client.WebClient; import static org.awaitility.Awaitility.await; -<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java -import static org.springframework.cloud.kubernetes.client.configmap.reload.DataChangesInConfigMapReloadDelegate.testSimple; -import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.builder; -import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchOne; -import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchThree; -import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.patchTwo; -import static org.springframework.cloud.kubernetes.client.configmap.reload.K8sClientConfigMapReloadITUtil.retrySpec; -import static org.springframework.cloud.kubernetes.client.configmap.reload.ReloadConfigMapMountDelegate.testReloadConfigMapMount; -======= -import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.BootstrapEnabledPollingReloadConfigMapMountDelegate.testBootstrapEnabledPollingReloadConfigMapMount; import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.DataChangesInConfigMapReloadDelegate.testSimple; import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.K8sClientConfigMapReloadITUtil.builder; import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.K8sClientConfigMapReloadITUtil.patchOne; import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.K8sClientConfigMapReloadITUtil.patchThree; import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.K8sClientConfigMapReloadITUtil.patchTwo; import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.K8sClientConfigMapReloadITUtil.retrySpec; -import static org.springframework.cloud.kubernetes.k8s.client.reload.configmap.PollingReloadConfigMapMountDelegate.testPollingReloadConfigMapMount; ->>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java /** * @author wind57 */ class K8sClientConfigMapReloadIT { -<<<<<<< HEAD:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-event-and-polling-reload/src/test/java/org/springframework/cloud/kubernetes/client/configmap/reload/K8sClientConfigMapReloadIT.java private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-event-and-polling-reload"; -======= - private static final String IMAGE_NAME = "spring-cloud-kubernetes-k8s-client-reload"; ->>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java private static final String DEPLOYMENT_NAME = "spring-k8s-client-reload"; @@ -170,7 +154,7 @@ private void testAllOther() throws Exception { testInform(); testInformFromOneNamespaceEventTriggeredSecretsDisabled(); testSimple(DOCKER_IMAGE, DEPLOYMENT_NAME, K3S); - testReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); + ReloadConfigMapMountDelegate.testReloadConfigMapMount(DEPLOYMENT_NAME, util, DOCKER_IMAGE); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java deleted file mode 100644 index c0b5c534ee..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/PollingReloadConfigMapMountDelegate.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.k8s.client.reload.configmap; - -import java.time.Duration; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - -import io.kubernetes.client.openapi.apis.CoreV1Api; -import io.kubernetes.client.openapi.models.V1ConfigMap; -import org.junit.jupiter.api.Assertions; - -import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; -import org.springframework.http.HttpMethod; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.awaitility.Awaitility.await; - -/** - * @author wind57 - */ -final class ReloadConfigMapMountDelegate { - - private ReloadConfigMapMountDelegate() { - - } - - /** - *
-	 *     - we have "spring.config.import: kubernetes:,configtree:/tmp/", which means we will 'locate' property sources
-	 *       from config maps.
-	 *     - the property above means that at the moment we will be searching for config maps that only
-	 *       match the application name, in this specific test there is no such config map.
-	 *     - what we will also read, is /tmp directory according to configtree rules.
-	 *       As such, a property "props.key" (see K8sClientConfigMapReloadITUtil::BODY_FIVE) will be in environment.
-	 *
-	 *     - we then change the config map content, wait for configuration watcher to pick up the change
-	 *       and schedule a refresh event, based on http.
-	 * 
- */ - static void testReloadConfigMapMount(String deploymentName, Util util, String imageName) throws Exception { - - K8sClientConfigMapReloadITUtil.patchFive(deploymentName, "default", imageName); - - WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key-no-mount").build(); - String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block(); - - // we first read the initial value from the configmap - Assertions.assertEquals("as-mount-initial", result); - - // replace data in configmap and wait for k8s to pick it up - // our polling will detect that and restart the app - V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml"); - configMap.setData(Map.of("from.properties", "as-mount-changed")); - // add label so that configuration-watcher picks this up - Map existingLabels = new HashMap<>( - Optional.ofNullable(configMap.getMetadata().getLabels()).orElse(Map.of())); - existingLabels.put("spring.cloud.kubernetes.config", "true"); - configMap.getMetadata().setLabels(existingLabels); - - // add annotation for which app to send the http event to - Map existingAnnotations = new HashMap<>( - Optional.ofNullable(configMap.getMetadata().getAnnotations()).orElse(Map.of())); - existingAnnotations.put("spring.cloud.kubernetes.configmap.apps", "spring-k8s-client-reload"); - configMap.getMetadata().setAnnotations(existingAnnotations); - new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null, - null); - - await().timeout(Duration.ofSeconds(180)) - .until(() -> webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block().equals("as-mount-changed")); - - } - -} From 9841b69a0ea85e067f8e1de34fe74c085e1cea26 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 17 Oct 2023 08:53:43 +0200 Subject: [PATCH 088/100] fix --- .../client/reload/Fabric8EventReloadIT.java | 4 +- .../fabric8/client/reload/TestUtil.java | 57 ------------------- 2 files changed, 2 insertions(+), 59 deletions(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/Fabric8EventReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/Fabric8EventReloadIT.java index 21818d7d7e..0c2c278e6e 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/Fabric8EventReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/Fabric8EventReloadIT.java @@ -311,12 +311,12 @@ void testDataChangesInConfigMap() { void testConfigMapMountPollingReload() { TestUtil.reCreateSources(util, client); - TestUtil.patchSix(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); + TestUtil.patchFive(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); ConfigMapMountPollingReloadDelegate.testConfigMapMountPollingReload(client, util); } void testSecretReload() { - TestUtil.patchSeven(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); + TestUtil.patchSix(util, DOCKER_IMAGE, IMAGE_NAME, NAMESPACE); SecretsEventsReloadDelegate.testSecretReload(client, K3S, IMAGE_NAME); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/TestUtil.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/TestUtil.java index aa60c52f38..87220411d6 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/TestUtil.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/TestUtil.java @@ -233,59 +233,6 @@ final class TestUtil { "spec": { "template": { "spec": { - "volumes": [ - { - "configMap": { - "defaultMode": 420, - "name": "poll-reload" - }, - "name": "config-map-volume" - } - ], - "containers": [{ - "volumeMounts": [ - { - "mountPath": "/tmp", - "name": "config-map-volume" - } - ], - "name": "spring-cloud-kubernetes-fabric8-client-configmap-event-reload", - "image": "image_name_here", - "env": [ - { - "name": "SPRING_PROFILES_ACTIVE", - "value": "with-bootstrap" - }, - { - "name": "SPRING_CLOUD_BOOTSTRAP_ENABLED", - "value": "TRUE" - }, - { - "name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD", - "value": "DEBUG" - }, - { - "name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG", - "value": "DEBUG" - }, - { - "name": "LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS", - "value": "DEBUG" - } - ] - }] - } - } - } - } - """; - - private static final String BODY_SEVEN = """ - { - "spec": { - "template": { - "spec": { ->>>>>>> main:spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/TestUtil.java "containers": [{ "name": "spring-cloud-kubernetes-fabric8-client-configmap-event-reload", "image": "image_name_here", @@ -351,10 +298,6 @@ static void patchSix(Util util, String dockerImage, String deploymentName, Strin util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_SIX, POD_LABELS); } - static void patchSeven(Util util, String dockerImage, String deploymentName, String namespace) { - util.patchWithReplace(dockerImage, deploymentName, namespace, BODY_SEVEN, POD_LABELS); - } - static WebClient.Builder builder() { return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.create())); } From 2ceabef1d676b1c3581729573bf8c9b9a9e06497 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 18 Oct 2023 07:17:25 +0200 Subject: [PATCH 089/100] fix --- .../k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java index fae4ba8285..05cfb11bb7 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/K8sClientConfigMapReloadIT.java @@ -57,7 +57,7 @@ class K8sClientConfigMapReloadIT { private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher"; - private static final String IMAGE_NAME = "spring-cloud-kubernetes-client-event-and-polling-reload"; + private static final String IMAGE_NAME = "spring-cloud-kubernetes-k8s-client-reload"; private static final String DEPLOYMENT_NAME = "spring-k8s-client-reload"; From 17c926c95b8d4f1765e368cfc3dceac5cdce1948 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 20 Oct 2023 18:30:02 +0200 Subject: [PATCH 090/100] fix --- .../watcher/ActuatorRefreshIT.java | 209 ------------------ 1 file changed, 209 deletions(-) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/src/test/java/org/springframework/cloud/kubernetes/configuration/watcher/ActuatorRefreshIT.java diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/src/test/java/org/springframework/cloud/kubernetes/configuration/watcher/ActuatorRefreshIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/src/test/java/org/springframework/cloud/kubernetes/configuration/watcher/ActuatorRefreshIT.java deleted file mode 100644 index 7f1af69e45..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-configuration-watcher-it/src/test/java/org/springframework/cloud/kubernetes/configuration/watcher/ActuatorRefreshIT.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2013-2020 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.configuration.watcher; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import com.github.tomakehurst.wiremock.client.WireMock; -import io.kubernetes.client.openapi.models.V1ConfigMap; -import io.kubernetes.client.openapi.models.V1ConfigMapBuilder; -import io.kubernetes.client.openapi.models.V1Deployment; -import io.kubernetes.client.openapi.models.V1EnvVar; -import io.kubernetes.client.openapi.models.V1Service; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.testcontainers.containers.Container; -import org.testcontainers.k3s.K3sContainer; - -import org.springframework.cloud.kubernetes.integration.tests.commons.Commons; -import org.springframework.cloud.kubernetes.integration.tests.commons.Phase; -import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; - -import static org.awaitility.Awaitility.await; - -/** - * @author Ryan Baxter - */ -class ActuatorRefreshIT { - - private static final String SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME = "spring-cloud-kubernetes-configuration-watcher"; - - private static final String WIREMOCK_HOST = "localhost"; - - private static final String WIREMOCK_PATH = "/"; - - private static final int WIREMOCK_PORT = 80; - - private static final String NAMESPACE = "default"; - - private static final K3sContainer K3S = Commons.container(); - - private static Util util; - - @BeforeAll - static void beforeAll() throws Exception { - K3S.start(); - Commons.validateImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S); - Commons.loadSpringCloudKubernetesImage(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S); - util = new Util(K3S); - util.setUp(NAMESPACE); - } - - @AfterAll - static void afterAll() throws Exception { - Commons.cleanUp(SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME, K3S); - Commons.systemPrune(); - } - - @BeforeEach - void setup() { - util.wiremock(NAMESPACE, "/", Phase.CREATE); - } - - @AfterEach - void after() { - util.wiremock(NAMESPACE, "/", Phase.DELETE); - } - - /* - * this test loads uses two services: wiremock on port 8080 and configuration-watcher - * on port 8888. we deploy configuration-watcher first and configure it via a - * configmap with the same name. then, we mock the call to actuator/refresh endpoint - * and deploy a new configmap: "service-wiremock", this in turn will trigger that - * refresh that we capture and assert for. - */ - // curl :8080/__admin/mappings - @Test - void testActuatorRefresh() { - configWatcher(Phase.CREATE, false); - - WireMock.configureFor(WIREMOCK_HOST, WIREMOCK_PORT, WIREMOCK_PATH); - await().timeout(Duration.ofSeconds(60)) - .until(() -> WireMock - .stubFor(WireMock.post(WireMock.urlEqualTo("/actuator/refresh")) - .willReturn(WireMock.aResponse().withBody("{}").withStatus(200))) - .getResponse().wasConfigured()); - - // Create new configmap to trigger controller to signal app to refresh - V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName("service-wiremock") - .addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "bar").build(); - util.createAndWait(NAMESPACE, configMap, null); - - // Wait a bit before we verify - await().atMost(Duration.ofSeconds(30)).until( - () -> !WireMock.findAll(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))).isEmpty()); - - WireMock.verify(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))); - util.deleteAndWait(NAMESPACE, configMap, null); - - configWatcher(Phase.DELETE, false); - } - - /* - * same test as above, but reload is disabled. - */ - @Test - void testActuatorRefreshReloadDisabled() { - configWatcher(Phase.CREATE, true); - - WireMock.configureFor(WIREMOCK_HOST, WIREMOCK_PORT, WIREMOCK_PATH); - await().timeout(Duration.ofSeconds(60)) - .until(() -> WireMock - .stubFor(WireMock.post(WireMock.urlEqualTo("/actuator/refresh")) - .willReturn(WireMock.aResponse().withBody("{}").withStatus(200))) - .getResponse().wasConfigured()); - - // Create new configmap to trigger controller to signal app to refresh - V1ConfigMap configMap = new V1ConfigMapBuilder().editOrNewMetadata().withName("service-wiremock") - .addToLabels("spring.cloud.kubernetes.config", "true").endMetadata().addToData("foo", "bar").build(); - util.createAndWait(NAMESPACE, configMap, null); - - // Wait a bit before we verify - await().atMost(Duration.ofSeconds(30)).until( - () -> !WireMock.findAll(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))).isEmpty()); - - Assertions.assertTrue(logs().contains("creating NOOP strategy because reload is disabled")); - // nothing related to 'ConfigReloadUtil' is present in logs - // this proves that once we disable reload everything still works - Assertions.assertFalse(logs().contains("ConfigReloadUtil")); - - WireMock.verify(WireMock.postRequestedFor(WireMock.urlEqualTo("/actuator/refresh"))); - util.deleteAndWait(NAMESPACE, configMap, null); - - configWatcher(Phase.DELETE, true); - } - - private void configWatcher(Phase phase, boolean disableReload) { - V1ConfigMap configMap = (V1ConfigMap) util - .yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-configmap.yaml"); - V1Deployment deployment = (V1Deployment) util - .yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-http-deployment.yaml"); - - List envVars = new ArrayList<>( - Optional.ofNullable(deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getEnv()) - .orElse(new ArrayList<>())); - - V1EnvVar commonsDebug = new V1EnvVar() - .name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD").value("DEBUG"); - V1EnvVar watcherDebug = new V1EnvVar() - .name("LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_CONFIGURATION_WATCHER").value("DEBUG"); - - envVars.add(commonsDebug); - envVars.add(watcherDebug); - - if (disableReload) { - V1EnvVar disableReloadEnvVar = new V1EnvVar().name("SPRING_CLOUD_KUBERNETES_RELOAD_ENABLED").value("FALSE"); - envVars.add(disableReloadEnvVar); - deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setEnv(envVars); - } - - V1Service service = (V1Service) util - .yaml("config-watcher/spring-cloud-kubernetes-configuration-watcher-service.yaml"); - - if (phase.equals(Phase.CREATE)) { - util.createAndWait(NAMESPACE, configMap, null); - util.createAndWait(NAMESPACE, null, deployment, service, null, true); - } - else { - util.deleteAndWait(NAMESPACE, configMap, null); - util.deleteAndWait(NAMESPACE, deployment, service, null); - } - - } - - private String logs() { - try { - String appPodName = K3S.execInContainer("sh", "-c", "kubectl get pods -l app=" - + SPRING_CLOUD_K8S_CONFIG_WATCHER_APP_NAME + " -o=name --no-headers | tr -d '\n'").getStdout(); - - Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim()); - return execResult.getStdout(); - } - catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } - -} From 1969a1d93f0e091c7f96836e8e204547d46117e8 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 3 Nov 2023 18:29:08 +0200 Subject: [PATCH 091/100] trigger From 4d7359eec36b14b9847c604526fbef896be1518d Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 14 Nov 2023 22:42:04 +0200 Subject: [PATCH 092/100] trigger From 61e5f19b6828fa43ca11bc8d680f1b79529b8d5b Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 27 Dec 2023 22:18:26 +0200 Subject: [PATCH 093/100] fix --- .../cloud/kubernetes/commons/SanitizeTests.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java index ba87eac7c3..d1154c3878 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java @@ -26,11 +26,11 @@ import org.springframework.boot.actuate.endpoint.Sanitizer; import org.springframework.boot.actuate.endpoint.SanitizingFunction; import org.springframework.cloud.bootstrap.config.BootstrapPropertySource; -import org.springframework.cloud.kubernetes.commons.config.MountConfigMapPropertySource; import org.springframework.cloud.kubernetes.commons.config.SecretsPropertySource; import org.springframework.cloud.kubernetes.commons.config.SourceData; import org.springframework.core.env.CompositePropertySource; import org.springframework.core.env.EnumerablePropertySource; +import org.springframework.core.env.MapPropertySource; import static org.springframework.boot.actuate.endpoint.SanitizableData.SANITIZED_VALUE; @@ -82,7 +82,7 @@ void bootstrapPropertySourceSecrets() { void notSecretsPropertySource() { BootstrapPropertySource bootstrapPropertySource = new BootstrapPropertySource<>( - new MountConfigMapPropertySource("mount-source", Map.of())); + new DummyPropertySource("mount-source", Map.of())); Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS); SanitizableData sanitizableData = new SanitizableData(bootstrapPropertySource, "secret", "xyz"); @@ -108,7 +108,7 @@ void compositeOneSecretOneMount() { compositePropertySource.addFirstPropertySource( new SecretsPropertySource(new SourceData("secret-source", Map.of("secret", "xyz")))); compositePropertySource - .addFirstPropertySource(new MountConfigMapPropertySource("mount-source", Map.of("mount", "abc"))); + .addFirstPropertySource(new DummyPropertySource("mount-source", Map.of("mount", "abc"))); Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS); SanitizableData sanitizableDataSecret = new SanitizableData(compositePropertySource, "secret", "xyz"); @@ -118,4 +118,12 @@ void compositeOneSecretOneMount() { Assertions.assertEquals(sanitizer.sanitize(sanitizableDataMount, SHOW_UNSANITIZED), "abc"); } + static class DummyPropertySource extends MapPropertySource { + + DummyPropertySource(String name, Map source) { + super(name, source); + } + + } + } From 593b22bb7fec2846dc9140e211d02c37312553db Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Mar 2024 18:18:33 +0200 Subject: [PATCH 094/100] formatting --- .../kubernetes/commons/SanitizeTests.java | 3 +- .../it/PodModeSpecificNamespaceTest.java | 54 +++++++++---------- .../it/ServiceModeSpecificNamespaceTest.java | 27 +++++----- .../resources/application-configtree.yaml | 2 +- 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java index d1154c3878..203da9dd50 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/SanitizeTests.java @@ -107,8 +107,7 @@ void compositeOneSecretOneMount() { CompositePropertySource compositePropertySource = new CompositePropertySource("composite"); compositePropertySource.addFirstPropertySource( new SecretsPropertySource(new SourceData("secret-source", Map.of("secret", "xyz")))); - compositePropertySource - .addFirstPropertySource(new DummyPropertySource("mount-source", Map.of("mount", "abc"))); + compositePropertySource.addFirstPropertySource(new DummyPropertySource("mount-source", Map.of("mount", "abc"))); Sanitizer sanitizer = new Sanitizer(SANITIZING_FUNCTIONS); SanitizableData sanitizableDataSecret = new SanitizableData(compositePropertySource, "secret", "xyz"); diff --git a/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/PodModeSpecificNamespaceTest.java b/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/PodModeSpecificNamespaceTest.java index fc5692de83..780e8624c2 100644 --- a/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/PodModeSpecificNamespaceTest.java +++ b/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/PodModeSpecificNamespaceTest.java @@ -58,10 +58,9 @@ /** * @author wind57 */ -@SpringBootTest( - properties = { "spring.cloud.kubernetes.loadbalancer.mode=POD", "spring.main.cloud-platform=KUBERNETES", +@SpringBootTest(properties = { "spring.cloud.kubernetes.loadbalancer.mode=POD", "spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.discovery.all-namespaces=false", "spring.cloud.kubernetes.client.namespace=a" }, - classes = { LoadBalancerConfiguration.class, Configuration.class }) + classes = { LoadBalancerConfiguration.class, Configuration.class }) class PodModeSpecificNamespaceTest { private static final String SERVICE_A_URL = "http://service-a"; @@ -77,7 +76,7 @@ class PodModeSpecificNamespaceTest { private static WireMockServer serviceBMockServer; private static final MockedStatic MOCKED_STATIC = Mockito - .mockStatic(KubernetesServiceInstanceMapper.class); + .mockStatic(KubernetesServiceInstanceMapper.class); @Autowired private WebClient.Builder builder; @@ -103,10 +102,10 @@ static void beforeAll() { // we mock host creation so that it becomes something like : localhost:8888 // then wiremock can catch this request, and we can assert for the result MOCKED_STATIC.when(() -> KubernetesServiceInstanceMapper.createHost("service-a", "a", "cluster.local")) - .thenReturn("localhost"); + .thenReturn("localhost"); MOCKED_STATIC.when(() -> KubernetesServiceInstanceMapper.createHost("service-b", "b", "cluster.local")) - .thenReturn("localhost"); + .thenReturn("localhost"); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://localhost:" + wireMockServer.port()); @@ -143,18 +142,18 @@ void test() { Service serviceB = Util.createService("b", "service-a", SERVICE_B_PORT); Endpoints endpointsA = new EndpointsBuilder() - .withSubsets(new EndpointSubsetBuilder() - .withPorts(new EndpointPortBuilder().withPort(SERVICE_A_PORT).build()) - .withAddresses(new EndpointAddressBuilder().withIp("127.0.0.1").build()).build()) - .withMetadata(new ObjectMetaBuilder().withName("no-port-name-service").withNamespace("a").build()) - .build(); + .withSubsets(new EndpointSubsetBuilder() + .withPorts(new EndpointPortBuilder().withPort(SERVICE_A_PORT).build()) + .withAddresses(new EndpointAddressBuilder().withIp("127.0.0.1").build()).build()) + .withMetadata(new ObjectMetaBuilder().withName("no-port-name-service").withNamespace("a").build()) + .build(); Endpoints endpointsB = new EndpointsBuilder() - .withSubsets(new EndpointSubsetBuilder() - .withPorts(new EndpointPortBuilder().withPort(SERVICE_B_PORT).build()) - .withAddresses(new EndpointAddressBuilder().withIp("127.0.0.1").build()).build()) - .withMetadata(new ObjectMetaBuilder().withName("no-port-name-service").withNamespace("b").build()) - .build(); + .withSubsets(new EndpointSubsetBuilder() + .withPorts(new EndpointPortBuilder().withPort(SERVICE_B_PORT).build()) + .withAddresses(new EndpointAddressBuilder().withIp("127.0.0.1").build()).build()) + .withMetadata(new ObjectMetaBuilder().withName("no-port-name-service").withNamespace("b").build()) + .build(); String endpointsAListAsString = Serialization.asJson(new EndpointsListBuilder().withItems(endpointsA).build()); String endpointsBListAsString = Serialization.asJson(new EndpointsListBuilder().withItems(endpointsB).build()); @@ -162,34 +161,34 @@ void test() { String serviceAString = Serialization.asJson(serviceA); String serviceBString = Serialization.asJson(serviceB); - wireMockServer - .stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/a/endpoints?fieldSelector=metadata.name%3Dservice-a")) + wireMockServer.stubFor(WireMock + .get(WireMock.urlEqualTo("/api/v1/namespaces/a/endpoints?fieldSelector=metadata.name%3Dservice-a")) .willReturn(WireMock.aResponse().withBody(endpointsAListAsString).withStatus(200))); - wireMockServer - .stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/b/endpoints?fieldSelector=metadata.name%3Dservice-b")) + wireMockServer.stubFor(WireMock + .get(WireMock.urlEqualTo("/api/v1/namespaces/b/endpoints?fieldSelector=metadata.name%3Dservice-b")) .willReturn(WireMock.aResponse().withBody(endpointsBListAsString).withStatus(200))); wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/a/services/service-a")) - .willReturn(WireMock.aResponse().withBody(serviceAString).withStatus(200))); + .willReturn(WireMock.aResponse().withBody(serviceAString).withStatus(200))); wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/b/services/service-a")) - .willReturn(WireMock.aResponse().withBody(serviceBString).withStatus(200))); + .willReturn(WireMock.aResponse().withBody(serviceBString).withStatus(200))); serviceAMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/")) - .willReturn(WireMock.aResponse().withBody("service-a-reached").withStatus(200))); + .willReturn(WireMock.aResponse().withBody("service-a-reached").withStatus(200))); serviceBMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/")) - .willReturn(WireMock.aResponse().withBody("service-b-reached").withStatus(200))); + .willReturn(WireMock.aResponse().withBody("service-b-reached").withStatus(200))); String serviceAResult = builder.baseUrl(SERVICE_A_URL).build().method(HttpMethod.GET).retrieve() - .bodyToMono(String.class).block(); + .bodyToMono(String.class).block(); Assertions.assertThat(serviceAResult).isEqualTo("service-a-reached"); CachingServiceInstanceListSupplier supplier = (CachingServiceInstanceListSupplier) loadBalancerClientFactory - .getIfAvailable().getProvider("service-a", ServiceInstanceListSupplier.class).getIfAvailable(); + .getIfAvailable().getProvider("service-a", ServiceInstanceListSupplier.class).getIfAvailable(); Assertions.assertThat(supplier.getDelegate().getClass()) - .isSameAs(DiscoveryClientServiceInstanceListSupplier.class); + .isSameAs(DiscoveryClientServiceInstanceListSupplier.class); } @TestConfiguration @@ -212,5 +211,4 @@ public static void main(String[] args) { } - } diff --git a/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/ServiceModeSpecificNamespaceTest.java b/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/ServiceModeSpecificNamespaceTest.java index 5369e61304..339c4f0f9d 100644 --- a/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/ServiceModeSpecificNamespaceTest.java +++ b/spring-cloud-kubernetes-fabric8-loadbalancer/src/test/java/org/springframework/cloud/kubernetes/fabric8/loadbalancer/it/ServiceModeSpecificNamespaceTest.java @@ -52,9 +52,10 @@ * @author wind57 */ @SpringBootTest( - properties = { "spring.cloud.kubernetes.loadbalancer.mode=SERVICE", "spring.main.cloud-platform=KUBERNETES", - "spring.cloud.kubernetes.discovery.all-namespaces=false", "spring.cloud.kubernetes.client.namespace=a" }, - classes = { LoadBalancerConfiguration.class, Configuration.class }) + properties = { "spring.cloud.kubernetes.loadbalancer.mode=SERVICE", "spring.main.cloud-platform=KUBERNETES", + "spring.cloud.kubernetes.discovery.all-namespaces=false", + "spring.cloud.kubernetes.client.namespace=a" }, + classes = { LoadBalancerConfiguration.class, Configuration.class }) class ServiceModeSpecificNamespaceTest { private static final String SERVICE_A_URL = "http://service-a"; @@ -70,7 +71,7 @@ class ServiceModeSpecificNamespaceTest { private static WireMockServer serviceBMockServer; private static final MockedStatic MOCKED_STATIC = Mockito - .mockStatic(KubernetesServiceInstanceMapper.class); + .mockStatic(KubernetesServiceInstanceMapper.class); @Autowired private WebClient.Builder builder; @@ -96,10 +97,10 @@ static void beforeAll() { // we mock host creation so that it becomes something like : localhost:8888 // then wiremock can catch this request, and we can assert for the result MOCKED_STATIC.when(() -> KubernetesServiceInstanceMapper.createHost("service-a", "a", "cluster.local")) - .thenReturn("localhost"); + .thenReturn("localhost"); MOCKED_STATIC.when(() -> KubernetesServiceInstanceMapper.createHost("service-b", "b", "cluster.local")) - .thenReturn("localhost"); + .thenReturn("localhost"); // Configure the kubernetes master url to point to the mock server System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "http://localhost:" + wireMockServer.port()); @@ -138,26 +139,24 @@ void test() { String serviceAJson = Serialization.asJson(serviceA); String serviceBJson = Serialization.asJson(serviceB); - wireMockServer - .stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/a/services/service-a")) + wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/a/services/service-a")) .willReturn(WireMock.aResponse().withBody(serviceAJson).withStatus(200))); - wireMockServer - .stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/b/services/service-a")) + wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/api/v1/namespaces/b/services/service-a")) .willReturn(WireMock.aResponse().withBody(serviceBJson).withStatus(200))); serviceAMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/")) - .willReturn(WireMock.aResponse().withBody("service-a-reached").withStatus(200))); + .willReturn(WireMock.aResponse().withBody("service-a-reached").withStatus(200))); serviceBMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/")) - .willReturn(WireMock.aResponse().withBody("service-b-reached").withStatus(200))); + .willReturn(WireMock.aResponse().withBody("service-b-reached").withStatus(200))); String serviceAResult = builder.baseUrl(SERVICE_A_URL).build().method(HttpMethod.GET).retrieve() - .bodyToMono(String.class).block(); + .bodyToMono(String.class).block(); Assertions.assertThat(serviceAResult).isEqualTo("service-a-reached"); CachingServiceInstanceListSupplier supplier = (CachingServiceInstanceListSupplier) loadBalancerClientFactory - .getIfAvailable().getProvider("service-a", ServiceInstanceListSupplier.class).getIfAvailable(); + .getIfAvailable().getProvider("service-a", ServiceInstanceListSupplier.class).getIfAvailable(); Assertions.assertThat(supplier.getDelegate().getClass()).isSameAs(Fabric8ServicesListSupplier.class); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml index 7a977072cb..04c058f32c 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml @@ -2,7 +2,7 @@ spring: application: name: poll-reload-mount config: - import: "kubernetes:,configtree:/tmp/" + import: "kubernetes:,configtree:/tmp/,vault://" management: endpoint: From 90831d9733d4889a28544dcbd23dd4681682a9be Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 26 Mar 2024 18:37:45 +0200 Subject: [PATCH 095/100] revert from vauld --- .../src/main/resources/application-configtree.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml index 04c058f32c..7a977072cb 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml @@ -2,7 +2,7 @@ spring: application: name: poll-reload-mount config: - import: "kubernetes:,configtree:/tmp/,vault://" + import: "kubernetes:,configtree:/tmp/" management: endpoint: From a6566c1092eee08bf0d48ee4fd31b4390c11bb36 Mon Sep 17 00:00:00 2001 From: wind57 Date: Wed, 1 May 2024 16:44:02 +0300 Subject: [PATCH 096/100] placeholder commit From cee5464b4ec554bc46033f51c0d0af691f02bc0c Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 6 Sep 2024 09:34:28 +0300 Subject: [PATCH 097/100] formatting --- ...ntConfigMapPropertySourceLocatorTests.java | 4 +- ...ConfigMapConfigPropertiesBindingTests.java | 62 +++++++++---------- .../SecretsConfigPropertiesBindingTests.java | 62 +++++++++---------- .../ConfigMapMountPollingReloadDelegate.java | 16 +++-- .../ReloadConfigMapMountDelegate.java | 7 ++- 5 files changed, 81 insertions(+), 70 deletions(-) diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java index 0ae9ea9e0b..0e32570864 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java @@ -97,7 +97,7 @@ public void afterEach() { void locateWithoutSources() { CoreV1Api api = new CoreV1Api(); stubFor(get("/api/v1/namespaces/default/configmaps") - .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); + .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); MockEnvironment mockEnvironment = new MockEnvironment(); @@ -159,7 +159,7 @@ void testLocateWithoutNamespaceConstructor() { void testLocateWithoutNamespace() { CoreV1Api api = new CoreV1Api(); stubFor(get("/api/v1/namespaces/default/configmaps") - .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); + .willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(PROPERTIES_CONFIGMAP_LIST)))); ConfigMapConfigProperties configMapConfigProperties = new ConfigMapConfigProperties(true, List.of(), Map.of(), true, "bootstrap-640", null, false, false, false, RetryProperties.DEFAULT); assertThatThrownBy(() -> new KubernetesClientConfigMapPropertySourceLocator(api, configMapConfigProperties, diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java index a206bbfa2c..7ad2ecc7b5 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesBindingTests.java @@ -58,38 +58,38 @@ void testWithDefaults() { @Test void testWithNonDefaults() { new ApplicationContextRunner().withUserConfiguration(Config.class) - .withPropertyValues("spring.cloud.kubernetes.config.enableApi=false", - "spring.cloud.kubernetes.config.sources[0].name=source-a", - "spring.cloud.kubernetes.config.sources[0].namespace=source-namespace-a", - "spring.cloud.kubernetes.config.sources[0].labels.key=source-value", - "spring.cloud.kubernetes.config.sources[0].explicit-prefix=source-prefix", - "spring.cloud.kubernetes.config.sources[0].use-name-as-prefix=true", - "spring.cloud.kubernetes.config.sources[0].include-profile-specific-sources=true", - "spring.cloud.kubernetes.config.labels.label-a=label-a", - "spring.cloud.kubernetes.config.enabled=false", "spring.cloud.kubernetes.config.name=name", - "spring.cloud.kubernetes.config.namespace=namespace", - "spring.cloud.kubernetes.config.use-name-as-prefix=true", - "spring.cloud.kubernetes.config.include-profile-specific-sources=true", - "spring.cloud.kubernetes.config.fail-fast=true", - "spring.cloud.kubernetes.config.retry.initial-interval=1", - "spring.cloud.kubernetes.config.retry.multiplier=1.2", - "spring.cloud.kubernetes.config.retry.max-interval=3", - "spring.cloud.kubernetes.config.retry.max-attempts=4", - "spring.cloud.kubernetes.config.retry.enabled=false") - .run(context -> { - ConfigMapConfigProperties props = context.getBean(ConfigMapConfigProperties.class); - Assertions.assertNotNull(props); - Assertions.assertFalse(props.enableApi()); + .withPropertyValues("spring.cloud.kubernetes.config.enableApi=false", + "spring.cloud.kubernetes.config.sources[0].name=source-a", + "spring.cloud.kubernetes.config.sources[0].namespace=source-namespace-a", + "spring.cloud.kubernetes.config.sources[0].labels.key=source-value", + "spring.cloud.kubernetes.config.sources[0].explicit-prefix=source-prefix", + "spring.cloud.kubernetes.config.sources[0].use-name-as-prefix=true", + "spring.cloud.kubernetes.config.sources[0].include-profile-specific-sources=true", + "spring.cloud.kubernetes.config.labels.label-a=label-a", + "spring.cloud.kubernetes.config.enabled=false", "spring.cloud.kubernetes.config.name=name", + "spring.cloud.kubernetes.config.namespace=namespace", + "spring.cloud.kubernetes.config.use-name-as-prefix=true", + "spring.cloud.kubernetes.config.include-profile-specific-sources=true", + "spring.cloud.kubernetes.config.fail-fast=true", + "spring.cloud.kubernetes.config.retry.initial-interval=1", + "spring.cloud.kubernetes.config.retry.multiplier=1.2", + "spring.cloud.kubernetes.config.retry.max-interval=3", + "spring.cloud.kubernetes.config.retry.max-attempts=4", + "spring.cloud.kubernetes.config.retry.enabled=false") + .run(context -> { + ConfigMapConfigProperties props = context.getBean(ConfigMapConfigProperties.class); + Assertions.assertNotNull(props); + Assertions.assertFalse(props.enableApi()); - Assertions.assertEquals(props.sources().size(), 1); - ConfigMapConfigProperties.Source source = props.sources().get(0); - Assertions.assertEquals(source.name(), "source-a"); - Assertions.assertEquals(source.namespace(), "source-namespace-a"); - Assertions.assertEquals(source.labels().size(), 1); - Assertions.assertEquals(source.labels().get("key"), "source-value"); - Assertions.assertEquals(source.explicitPrefix(), "source-prefix"); - Assertions.assertTrue(source.useNameAsPrefix()); - Assertions.assertTrue(source.includeProfileSpecificSources()); + Assertions.assertEquals(props.sources().size(), 1); + ConfigMapConfigProperties.Source source = props.sources().get(0); + Assertions.assertEquals(source.name(), "source-a"); + Assertions.assertEquals(source.namespace(), "source-namespace-a"); + Assertions.assertEquals(source.labels().size(), 1); + Assertions.assertEquals(source.labels().get("key"), "source-value"); + Assertions.assertEquals(source.explicitPrefix(), "source-prefix"); + Assertions.assertTrue(source.useNameAsPrefix()); + Assertions.assertTrue(source.includeProfileSpecificSources()); Assertions.assertEquals(props.labels().size(), 1); Assertions.assertEquals(props.labels().get("label-a"), "label-a"); diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java index 89022c8583..a756310bb4 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigPropertiesBindingTests.java @@ -58,38 +58,38 @@ void testWithDefaults() { @Test void testWithNonDefaults() { new ApplicationContextRunner().withUserConfiguration(Config.class) - .withPropertyValues("spring.cloud.kubernetes.secrets.enableApi=false", - "spring.cloud.kubernetes.secrets.sources[0].name=source-a", - "spring.cloud.kubernetes.secrets.sources[0].namespace=source-namespace-a", - "spring.cloud.kubernetes.secrets.sources[0].labels.key=source-value", - "spring.cloud.kubernetes.secrets.sources[0].explicit-prefix=source-prefix", - "spring.cloud.kubernetes.secrets.sources[0].use-name-as-prefix=true", - "spring.cloud.kubernetes.secrets.sources[0].include-profile-specific-sources=true", - "spring.cloud.kubernetes.secrets.labels.label-a=label-a", - "spring.cloud.kubernetes.secrets.enabled=false", "spring.cloud.kubernetes.secrets.name=name", - "spring.cloud.kubernetes.secrets.namespace=namespace", - "spring.cloud.kubernetes.secrets.use-name-as-prefix=true", - "spring.cloud.kubernetes.secrets.include-profile-specific-sources=true", - "spring.cloud.kubernetes.secrets.fail-fast=true", - "spring.cloud.kubernetes.secrets.retry.initial-interval=1", - "spring.cloud.kubernetes.secrets.retry.multiplier=1.2", - "spring.cloud.kubernetes.secrets.retry.max-interval=3", - "spring.cloud.kubernetes.secrets.retry.max-attempts=4", - "spring.cloud.kubernetes.secrets.retry.enabled=false") - .run(context -> { - SecretsConfigProperties props = context.getBean(SecretsConfigProperties.class); - Assertions.assertNotNull(props); - Assertions.assertFalse(props.enableApi()); + .withPropertyValues("spring.cloud.kubernetes.secrets.enableApi=false", + "spring.cloud.kubernetes.secrets.sources[0].name=source-a", + "spring.cloud.kubernetes.secrets.sources[0].namespace=source-namespace-a", + "spring.cloud.kubernetes.secrets.sources[0].labels.key=source-value", + "spring.cloud.kubernetes.secrets.sources[0].explicit-prefix=source-prefix", + "spring.cloud.kubernetes.secrets.sources[0].use-name-as-prefix=true", + "spring.cloud.kubernetes.secrets.sources[0].include-profile-specific-sources=true", + "spring.cloud.kubernetes.secrets.labels.label-a=label-a", + "spring.cloud.kubernetes.secrets.enabled=false", "spring.cloud.kubernetes.secrets.name=name", + "spring.cloud.kubernetes.secrets.namespace=namespace", + "spring.cloud.kubernetes.secrets.use-name-as-prefix=true", + "spring.cloud.kubernetes.secrets.include-profile-specific-sources=true", + "spring.cloud.kubernetes.secrets.fail-fast=true", + "spring.cloud.kubernetes.secrets.retry.initial-interval=1", + "spring.cloud.kubernetes.secrets.retry.multiplier=1.2", + "spring.cloud.kubernetes.secrets.retry.max-interval=3", + "spring.cloud.kubernetes.secrets.retry.max-attempts=4", + "spring.cloud.kubernetes.secrets.retry.enabled=false") + .run(context -> { + SecretsConfigProperties props = context.getBean(SecretsConfigProperties.class); + Assertions.assertNotNull(props); + Assertions.assertFalse(props.enableApi()); - Assertions.assertEquals(props.sources().size(), 1); - SecretsConfigProperties.Source source = props.sources().get(0); - Assertions.assertEquals(source.name(), "source-a"); - Assertions.assertEquals(source.namespace(), "source-namespace-a"); - Assertions.assertEquals(source.labels().size(), 1); - Assertions.assertEquals(source.labels().get("key"), "source-value"); - Assertions.assertEquals(source.explicitPrefix(), "source-prefix"); - Assertions.assertTrue(source.useNameAsPrefix()); - Assertions.assertTrue(source.includeProfileSpecificSources()); + Assertions.assertEquals(props.sources().size(), 1); + SecretsConfigProperties.Source source = props.sources().get(0); + Assertions.assertEquals(source.name(), "source-a"); + Assertions.assertEquals(source.namespace(), "source-namespace-a"); + Assertions.assertEquals(source.labels().size(), 1); + Assertions.assertEquals(source.labels().get("key"), "source-value"); + Assertions.assertEquals(source.explicitPrefix(), "source-prefix"); + Assertions.assertTrue(source.useNameAsPrefix()); + Assertions.assertTrue(source.includeProfileSpecificSources()); Assertions.assertEquals(props.labels().size(), 1); Assertions.assertEquals(props.labels().get("label-a"), "label-a"); diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java index c0b1450f24..3b96a1fe13 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java @@ -53,8 +53,11 @@ final class ConfigMapMountPollingReloadDelegate { */ static void testConfigMapMountPollingReload(KubernetesClient client, Util util) { WebClient webClient = TestUtil.builder().baseUrl("http://localhost/key-no-mount").build(); - String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(TestUtil.retrySpec()).block(); + String result = webClient.method(HttpMethod.GET) + .retrieve() + .bodyToMono(String.class) + .retryWhen(TestUtil.retrySpec()) + .block(); // we first read the initial value from the configmap Assertions.assertEquals("as-mount-initial", result); @@ -78,8 +81,13 @@ static void testConfigMapMountPollingReload(KubernetesClient client, Util util) configMapMount.getMetadata().setAnnotations(existingAnnotations); TestUtil.replaceConfigMap(client, configMapMount, "default"); - await().timeout(Duration.ofSeconds(180)).until(() -> webClient.method(HttpMethod.GET).retrieve() - .bodyToMono(String.class).retryWhen(TestUtil.retrySpec()).block().equals("as-mount-changed")); + await().timeout(Duration.ofSeconds(180)) + .until(() -> webClient.method(HttpMethod.GET) + .retrieve() + .bodyToMono(String.class) + .retryWhen(TestUtil.retrySpec()) + .block() + .equals("as-mount-changed")); } diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java index abfa7601fc..46b3c2b534 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java @@ -58,8 +58,11 @@ static void testReloadConfigMapMount(String deploymentName, Util util, String im K8sClientConfigMapReloadITUtil.patchFive(deploymentName, "default", imageName); WebClient webClient = K8sClientConfigMapReloadITUtil.builder().baseUrl("http://localhost/key-no-mount").build(); - String result = webClient.method(HttpMethod.GET).retrieve().bodyToMono(String.class) - .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()).block(); + String result = webClient.method(HttpMethod.GET) + .retrieve() + .bodyToMono(String.class) + .retryWhen(K8sClientConfigMapReloadITUtil.retrySpec()) + .block(); // we first read the initial value from the configmap Assertions.assertEquals("as-mount-initial", result); From 3a03d1b6e3ad033bb5fed353af24cf16aebb18d8 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sun, 8 Sep 2024 00:33:04 +0300 Subject: [PATCH 098/100] fix tests --- ...BootstrapConfigMapsFromFilePathsTests.java | 38 ------------------- ...onfigDataConfigMapsFromFilePathsTests.java | 38 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/BootstrapConfigMapsFromFilePathsTests.java delete mode 100644 spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigDataConfigMapsFromFilePathsTests.java diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/BootstrapConfigMapsFromFilePathsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/BootstrapConfigMapsFromFilePathsTests.java deleted file mode 100644 index d7a2e0034f..0000000000 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/BootstrapConfigMapsFromFilePathsTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.fabric8.config.configmaps_from_file_paths; - -import java.io.IOException; - -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -import org.junit.jupiter.api.BeforeAll; - -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "spring.cloud.bootstrap.enabled=true" }) -@EnableKubernetesMockClient(crud = true, https = false) -class BootstrapConfigMapsFromFilePathsTests extends ConfigMapsFromFilePaths { - - private static KubernetesClient mockClient; - - @BeforeAll - static void setUpBeforeClass() throws IOException { - setUpBeforeClass(mockClient); - } - -} diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigDataConfigMapsFromFilePathsTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigDataConfigMapsFromFilePathsTests.java deleted file mode 100644 index a071f8ddbc..0000000000 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/configmaps_from_file_paths/ConfigDataConfigMapsFromFilePathsTests.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.cloud.kubernetes.fabric8.config.configmaps_from_file_paths; - -import java.io.IOException; - -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; -import org.junit.jupiter.api.BeforeAll; - -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "spring.config.import=kubernetes:" }) -@EnableKubernetesMockClient(crud = true, https = false) -class ConfigDataConfigMapsFromFilePathsTests extends ConfigMapsFromFilePaths { - - private static KubernetesClient mockClient; - - @BeforeAll - static void setUpBeforeClass() throws IOException { - setUpBeforeClass(mockClient); - } - -} From 497d847a47ffa8594639383ec5b0989bb2a987f2 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Sep 2024 15:58:58 +0300 Subject: [PATCH 099/100] checkstyle --- .../fabric8/config/config_maps_mixed/ConfigMapsMixed.java | 3 +-- .../client/reload/ConfigMapMountPollingReloadDelegate.java | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_mixed/ConfigMapsMixed.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_mixed/ConfigMapsMixed.java index f29d143d18..90fc6aa1ae 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_mixed/ConfigMapsMixed.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/config_maps_mixed/ConfigMapsMixed.java @@ -31,8 +31,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TestApplication.class, properties = { "spring.application.name=" + ConfigMapsMixed.APPLICATION_NAME, - "spring.cloud.kubernetes.config.enableApi=true", - "spring.main.cloud-platform=KUBERNETES" }) + "spring.cloud.kubernetes.config.enableApi=true", "spring.main.cloud-platform=KUBERNETES" }) abstract class ConfigMapsMixed { protected static final String APPLICATION_NAME = "configmap-mixed-example"; diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java index 292802037e..3b96a1fe13 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapMountPollingReloadDelegate.java @@ -27,7 +27,6 @@ import io.fabric8.kubernetes.client.utils.Serialization; import org.junit.jupiter.api.Assertions; -import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient; From c04bbd544263264687955ca6efef13212ac68c4d Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Sep 2024 18:07:52 +0300 Subject: [PATCH 100/100] checkstyle --- .../client/reload/configmap/ReloadConfigMapMountDelegate.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java index 24c2ecbb2b..46b3c2b534 100644 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java +++ b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-k8s-client-reload/src/test/java/org/springframework/cloud/kubernetes/k8s/client/reload/configmap/ReloadConfigMapMountDelegate.java @@ -25,7 +25,6 @@ import io.kubernetes.client.openapi.models.V1ConfigMap; import org.junit.jupiter.api.Assertions; -import org.springframework.cloud.kubernetes.commons.config.Constants; import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util; import org.springframework.http.HttpMethod; import org.springframework.web.reactive.function.client.WebClient;