Skip to content

Commit 88ba338

Browse files
committed
fix test
1 parent 08350c7 commit 88ba338

File tree

8 files changed

+28
-49
lines changed

8 files changed

+28
-49
lines changed

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/java/org/springframework/cloud/kubernetes/fabric8/client/reload/ConfigMapProperties.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
* @author wind57
2323
*/
2424
@ConfigurationProperties("from.properties")
25-
class ConfigMapProperties {
25+
public class ConfigMapProperties {
2626

2727
private String key;
2828

29-
String getKey() {
29+
public String getKey() {
3030
return key;
3131
}
3232

33-
void setKey(String key1) {
34-
this.key = key1;
33+
public void setKey(String key) {
34+
this.key = key;
3535
}
3636

3737
}

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-configtree.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
spring:
22
application:
3-
name: poll-reload-mount
3+
name: poll-reload
44
config:
55
import: "kubernetes:,configtree:/tmp/"
66

77
management:
88
endpoint:
99
refresh:
10-
enabled: true
10+
access: unrestricted
1111
restart:
12-
enabled: true
12+
access: unrestricted
1313
endpoints:
1414
web:
1515
exposure:

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/main/resources/application-with-bootstrap.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@
4444
/**
4545
* @author wind57
4646
*/
47-
class ConfigMapMountPollingReloadDelegateIT {
47+
class Fabric8ConfigMapConfigTreeIT {
4848

4949
private static final String IMAGE_NAME = "spring-cloud-kubernetes-fabric8-client-reload";
5050

51+
private static final String CONFIGURATION_WATCHER_IMAGE_NAME = "spring-cloud-kubernetes-configuration-watcher";
52+
5153
private static final String NAMESPACE = "default";
5254

5355
private static final K3sContainer K3S = Commons.container();
@@ -60,14 +62,19 @@ static void beforeAll() throws Exception {
6062
Commons.validateImage(IMAGE_NAME, K3S);
6163
Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S);
6264

65+
Commons.validateImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S);
66+
Commons.loadSpringCloudKubernetesImage(CONFIGURATION_WATCHER_IMAGE_NAME, K3S);
67+
6368
util = new Util(K3S);
6469
util.setUp(NAMESPACE);
6570
manifests(Phase.CREATE, util, NAMESPACE);
71+
util.configWatcher(Phase.CREATE);
6672
}
6773

6874
@AfterAll
6975
static void afterAll() {
7076
manifests(Phase.DELETE, util, NAMESPACE);
77+
util.configWatcher(Phase.DELETE);
7178
}
7279

7380
/**
@@ -85,12 +92,6 @@ static void afterAll() {
8592
*/
8693
@Test
8794
void test() {
88-
// (1)
89-
Commons.waitForLogStatement("paths property sources : [/tmp/application.properties]", K3S, IMAGE_NAME);
90-
// (2)
91-
Commons.waitForLogStatement("will add file-based property source : /tmp/application.properties", K3S,
92-
IMAGE_NAME);
93-
// (3)
9495
WebClient webClient = builder().baseUrl("http://localhost/key").build();
9596
String result = webClient.method(HttpMethod.GET)
9697
.retrieve()
@@ -103,14 +104,16 @@ void test() {
103104

104105
// replace data in configmap and wait for k8s to pick it up
105106
// our polling will detect that and restart the app
106-
InputStream configMapMountStream = util.inputStream("configmap-configtree.yaml");
107-
ConfigMap configMapMount = Serialization.unmarshal(configMapMountStream, ConfigMap.class);
108-
configMapMount.setData(Map.of("from.properties", "as-mount-changed"));
107+
InputStream configMapConfigTreeStream = util.inputStream("manifests/configmap-configtree.yaml");
108+
ConfigMap configMapConfigTree = Serialization.unmarshal(configMapConfigTreeStream, ConfigMap.class);
109+
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(configMapMount.getMetadata().getLabels()).orElse(Map.of()));
112+
Optional.ofNullable(configMapConfigTree.getMetadata().getLabels()).orElse(Map.of()));
112113
existingLabels.put("spring.cloud.kubernetes.config", "true");
113-
configMapMount.getMetadata().setLabels(existingLabels);
114+
configMapConfigTree.getMetadata().setLabels(existingLabels);
115+
116+
util.client().configMaps().resource(configMapConfigTree).createOrReplace();
114117

115118
await().timeout(Duration.ofSeconds(180))
116119
.until(() -> webClient.method(HttpMethod.GET)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static void manifests(Phase phase, Util util, String namespace) {
9797
InputStream deploymentStream = util.inputStream("manifests/deployment.yaml");
9898
InputStream serviceStream = util.inputStream("manifests/service.yaml");
9999
InputStream ingressStream = util.inputStream("manifests/ingress.yaml");
100-
InputStream configMapAsStream = util.inputStream("manifests/configmap.yaml");
100+
InputStream configMapAsStream = util.inputStream("manifests/configmap-configtree.yaml");
101101

102102
Deployment deployment = Serialization.unmarshal(deploymentStream, Deployment.class);
103103

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ metadata:
44
name: poll-reload-configtree
55
namespace: default
66
data:
7-
from.properties: "as-mount-initial"
7+
from.properties.key: "as-mount-initial"

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-reload/src/test/resources/manifests/deployment.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ spec:
3030
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_FABRIC8_CONFIG_RELOAD
3131
value: "DEBUG"
3232
- name: SPRING_PROFILES_ACTIVE
33-
value: "with-bootstrap"
34-
- name: SPRING_CLOUD_BOOTSTRAP_ENABLED
35-
value: "TRUE"
33+
value: "configtree"
3634
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG
3735
value: "DEBUG"
3836

@@ -44,4 +42,4 @@ spec:
4442
- name: "config-map-volume"
4543
configMap:
4644
defaultMode: 420
47-
name: "poll-reload"
45+
name: "poll-reload-configtree"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ spec:
3333
value: DEBUG
3434
- name: LOGGING_LEVEL_ORG_SPRINGFRAMEWORK_CLOUD_KUBERNETES_COMMONS_CONFIG_RELOAD
3535
value: DEBUG
36-
# - name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY
37-
# value: "10000"
36+
- name: SPRING_CLOUD_KUBERNETES_CONFIGURATION_WATCHER_REFRESHDELAY
37+
value: "30000"

0 commit comments

Comments
 (0)