Skip to content

Commit 0417ece

Browse files
committed
test
1 parent 861cd05 commit 0417ece

File tree

2 files changed

+13
-33
lines changed
  • spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload
  • spring-cloud-kubernetes-test-support/src/main/resources/config-watcher

2 files changed

+13
-33
lines changed

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/java/org/springframework/cloud/kubernetes/fabric8/client/reload/Fabric8ConfigMapConfigTreeIT.java

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.cloud.kubernetes.fabric8.client.reload;
1818

1919
import java.io.InputStream;
20+
import java.time.Duration;
2021
import java.util.HashMap;
2122
import java.util.Map;
2223
import java.util.Optional;
@@ -26,7 +27,6 @@
2627
import org.junit.jupiter.api.AfterAll;
2728
import org.junit.jupiter.api.BeforeAll;
2829
import org.junit.jupiter.api.Test;
29-
import org.testcontainers.containers.Container;
3030
import org.testcontainers.k3s.K3sContainer;
3131

3232
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
@@ -36,6 +36,7 @@
3636
import org.springframework.web.reactive.function.client.WebClient;
3737

3838
import static org.assertj.core.api.Assertions.assertThat;
39+
import static org.awaitility.Awaitility.await;
3940
import static org.springframework.cloud.kubernetes.fabric8.client.reload.TestAssertions.builder;
4041
import static org.springframework.cloud.kubernetes.fabric8.client.reload.TestAssertions.manifests;
4142
import static org.springframework.cloud.kubernetes.fabric8.client.reload.TestAssertions.retrySpec;
@@ -90,7 +91,7 @@ static void afterAll() {
9091
* </pre>
9192
*/
9293
@Test
93-
void test() throws Exception {
94+
void test() {
9495
WebClient webClient = builder().baseUrl("http://localhost/key").build();
9596
String result = webClient.method(HttpMethod.GET)
9697
.retrieve()
@@ -108,41 +109,20 @@ void test() throws Exception {
108109
configMapConfigTree.setData(Map.of("from.properties.key", "as-mount-changed"));
109110
// add label so that configuration-watcher picks this up
110111
Map<String, String> existingLabels = new HashMap<>(
111-
Optional.ofNullable(configMapConfigTree.getMetadata().getLabels()).orElse(Map.of()));
112+
Optional.ofNullable(configMapConfigTree.getMetadata().getLabels()).orElse(new HashMap<>()));
112113
existingLabels.put("spring.cloud.kubernetes.config", "true");
113114
configMapConfigTree.getMetadata().setLabels(existingLabels);
114115

115116
util.client().configMaps().resource(configMapConfigTree).createOrReplace();
116117

117-
// await().atMost(Duration.ofSeconds(180))
118-
// .pollInterval(Duration.ofSeconds(1))
119-
// .until(() -> webClient.method(HttpMethod.GET)
120-
// .retrieve()
121-
// .bodyToMono(String.class)
122-
// .retryWhen(retrySpec())
123-
// .block()
124-
// .equals("as-mount-changed"));
125-
126-
Thread.sleep(180_000);
127-
128-
System.out.println(logs());
129-
}
130-
131-
private String logs() {
132-
try {
133-
String appPodName = K3S
134-
.execInContainer("sh", "-c",
135-
"kubectl get pods -l app=" + CONFIGURATION_WATCHER_IMAGE_NAME
136-
+ " -o=name --no-headers | tr -d '\n'")
137-
.getStdout();
138-
139-
Container.ExecResult execResult = K3S.execInContainer("sh", "-c", "kubectl logs " + appPodName.trim());
140-
return execResult.getStdout();
141-
}
142-
catch (Exception e) {
143-
e.printStackTrace();
144-
throw new RuntimeException(e);
145-
}
118+
await().atMost(Duration.ofSeconds(180))
119+
.pollInterval(Duration.ofSeconds(1))
120+
.until(() -> webClient.method(HttpMethod.GET)
121+
.retrieve()
122+
.bodyToMono(String.class)
123+
.retryWhen(retrySpec())
124+
.block()
125+
.equals("as-mount-changed"));
146126
}
147127

148128
}

spring-cloud-kubernetes-test-support/src/main/resources/config-watcher/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ spec:
3434
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD
3535
value: DEBUG
3636
- name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY
37-
value: "30000"
37+
value: "120000"

0 commit comments

Comments
 (0)