Skip to content

Commit a27bf65

Browse files
authored
Refactor fabric8 catalog watch integration tests (1) (#1755)
1 parent 7b62798 commit a27bf65

File tree

16 files changed

+617
-624
lines changed

16 files changed

+617
-624
lines changed

spring-cloud-kubernetes-integration-tests/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
</execution>
7878
</executions>
7979
<configuration>
80+
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
8081
<includes>
8182
<include>${testsToRun}</include>
8283
</includes>

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@
4242
<filtering>true</filtering>
4343
</resource>
4444
</resources>
45+
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
<executions>
51+
<execution>
52+
<id>build-image</id>
53+
<configuration>
54+
<skip>true</skip>
55+
</configuration>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
4561
</build>
4662

4763
</project>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright 2012-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.kubernetes.fabric8.catalog.watch;
18+
19+
import java.util.Map;
20+
import java.util.Set;
21+
22+
import io.fabric8.kubernetes.client.Config;
23+
import io.fabric8.kubernetes.client.KubernetesClient;
24+
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
25+
import org.junit.jupiter.api.BeforeAll;
26+
import org.junit.jupiter.api.extension.ExtendWith;
27+
import org.testcontainers.k3s.K3sContainer;
28+
29+
import org.springframework.boot.test.system.OutputCaptureExtension;
30+
import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties;
31+
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
32+
import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util;
33+
import org.springframework.test.context.TestPropertySource;
34+
35+
/**
36+
* @author wind57
37+
*/
38+
39+
@TestPropertySource(
40+
properties = { "spring.main.cloud-platform=kubernetes", "spring.cloud.config.import-check.enabled=false",
41+
"spring.cloud.kubernetes.discovery.catalogServicesWatchDelay=2000",
42+
"spring.cloud.kubernetes.client.namespace=default",
43+
"logging.level.org.springframework.cloud.kubernetes.fabric8.discovery=DEBUG" })
44+
@ExtendWith(OutputCaptureExtension.class)
45+
abstract class Fabric8CatalogWatchBase {
46+
47+
protected static final String NAMESPACE = "default";
48+
49+
protected static final String NAMESPACE_A = "a";
50+
51+
protected static final String NAMESPACE_B = "b";
52+
53+
protected static final K3sContainer K3S = Commons.container();
54+
55+
protected static Util util;
56+
57+
@BeforeAll
58+
protected static void beforeAll() {
59+
K3S.start();
60+
util = new Util(K3S);
61+
}
62+
63+
protected static KubernetesDiscoveryProperties discoveryProperties(boolean useEndpointSlices) {
64+
return new KubernetesDiscoveryProperties(true, false, Set.of(NAMESPACE, NAMESPACE_A), true, 60, false, null,
65+
Set.of(443, 8443), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, useEndpointSlices,
66+
false, null);
67+
}
68+
69+
protected static KubernetesClient client() {
70+
String kubeConfigYaml = K3S.getKubeConfigYaml();
71+
Config config = Config.fromKubeconfig(kubeConfigYaml);
72+
return new KubernetesClientBuilder().withConfig(config).build();
73+
}
74+
75+
}

spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-catalog-watcher/src/test/java/org/springframework/cloud/kubernetes/fabric8/catalog/watch/Fabric8CatalogWatchIT.java

Lines changed: 0 additions & 254 deletions
This file was deleted.

0 commit comments

Comments
 (0)