From 032014e7b841bb3346f2a9a097fe9bd5983a30e9 Mon Sep 17 00:00:00 2001 From: wind57 Date: Sat, 4 Dec 2021 07:59:07 -0800 Subject: [PATCH 01/11] 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 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 6efb5e2415456f7f8a170b117d5f28c44f7094c6 Mon Sep 17 00:00:00 2001 From: wind57 Date: Mon, 4 Dec 2023 22:16:51 +0200 Subject: [PATCH 07/11] first commit --- .../discovery/KubernetesDiscoveryClient.java | 11 -- ...netesDiscoveryClientAutoConfiguration.java | 120 ------------------ .../KubernetesDiscoveryClientProperties.java | 67 ---------- .../KubernetesReactiveDiscoveryClient.java | 9 -- ...ubernetesReactiveDiscoveryClientTests.java | 16 ++- 5 files changed, 10 insertions(+), 213 deletions(-) delete mode 100644 spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java delete mode 100644 spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java index 7dceae2c69..9d7fc62844 100644 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java +++ b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClient.java @@ -40,17 +40,6 @@ public class KubernetesDiscoveryClient implements DiscoveryClient { private final String discoveryServerUrl; - @Deprecated(forRemoval = true) - public KubernetesDiscoveryClient(RestTemplate rest, KubernetesDiscoveryClientProperties properties) { - if (!StringUtils.hasText(properties.getDiscoveryServerUrl())) { - throw new DiscoveryServerUrlInvalidException(); - } - this.rest = rest; - this.emptyNamespaces = properties.getNamespaces().isEmpty(); - this.namespaces = properties.getNamespaces(); - this.discoveryServerUrl = properties.getDiscoveryServerUrl(); - } - KubernetesDiscoveryClient(RestTemplate rest, KubernetesDiscoveryProperties kubernetesDiscoveryProperties) { if (!StringUtils.hasText(kubernetesDiscoveryProperties.discoveryServerUrl())) { throw new DiscoveryServerUrlInvalidException(); diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java deleted file mode 100644 index a6b2aa73d7..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013-2021 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.discovery; - -import org.springframework.beans.factory.InitializingBean; -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; -import org.springframework.boot.cloud.CloudPlatform; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.cloud.client.ConditionalOnDiscoveryEnabled; -import org.springframework.cloud.client.ConditionalOnDiscoveryHealthIndicatorEnabled; -import org.springframework.cloud.client.ConditionalOnReactiveDiscoveryEnabled; -import org.springframework.cloud.client.discovery.DiscoveryClient; -import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; -import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent; -import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicatorProperties; -import org.springframework.cloud.client.discovery.health.reactive.ReactiveDiscoveryClientHealthIndicator; -import org.springframework.cloud.kubernetes.commons.discovery.ConditionalOnKubernetesDiscoveryEnabled; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author Ryan Baxter - * @deprecated in favor of {@link KubernetesDiscoveryClientBlockingAutoConfiguration} and - * {@link KubernetesDiscoveryClientReactiveAutoConfiguration} - */ -@Configuration(proxyBeanMethods = false) -@ConditionalOnDiscoveryEnabled -@ConditionalOnCloudPlatform(CloudPlatform.KUBERNETES) -@ConditionalOnKubernetesDiscoveryEnabled -@EnableConfigurationProperties({ DiscoveryClientHealthIndicatorProperties.class, - KubernetesDiscoveryClientProperties.class }) -@Deprecated(forRemoval = true) -public class KubernetesDiscoveryClientAutoConfiguration { - - @Configuration(proxyBeanMethods = false) - public static class Servlet { - - @Bean - @ConditionalOnMissingClass("org.springframework.web.reactive.function.client.WebClient") - @ConditionalOnMissingBean(RestTemplate.class) - public RestTemplate restTemplate() { - return new RestTemplateBuilder().build(); - } - - @Bean - @ConditionalOnMissingClass("org.springframework.web.reactive.function.client.WebClient") - public DiscoveryClient kubernetesDiscoveryClient(RestTemplate restTemplate, - KubernetesDiscoveryClientProperties properties) { - return new KubernetesDiscoveryClient(restTemplate, properties); - } - - @Bean - @ConditionalOnClass({ HealthIndicator.class }) - @ConditionalOnDiscoveryHealthIndicatorEnabled - public InitializingBean indicatorInitializer(ApplicationEventPublisher applicationEventPublisher, - ApplicationContext applicationContext) { - return () -> applicationEventPublisher - .publishEvent(new InstanceRegisteredEvent<>(applicationContext.getId(), null)); - - } - - } - - @Configuration(proxyBeanMethods = false) - @ConditionalOnReactiveDiscoveryEnabled - public static class Reactive { - - @Bean - @ConditionalOnClass(name = { "org.springframework.web.reactive.function.client.WebClient" }) - @ConditionalOnMissingBean(WebClient.Builder.class) - public WebClient.Builder webClientBuilder() { - return WebClient.builder(); - } - - @Bean - @ConditionalOnClass(name = { "org.springframework.web.reactive.function.client.WebClient" }) - public ReactiveDiscoveryClient kubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, - KubernetesDiscoveryClientProperties properties) { - return new KubernetesReactiveDiscoveryClient(webClientBuilder, properties); - } - - @Bean - @ConditionalOnClass(name = "org.springframework.boot.actuate.health.ReactiveHealthIndicator") - @ConditionalOnDiscoveryHealthIndicatorEnabled - public ReactiveDiscoveryClientHealthIndicator kubernetesReactiveDiscoveryClientHealthIndicator( - KubernetesReactiveDiscoveryClient client, DiscoveryClientHealthIndicatorProperties properties, - ApplicationContext applicationContext) { - ReactiveDiscoveryClientHealthIndicator healthIndicator = new ReactiveDiscoveryClientHealthIndicator(client, - properties); - InstanceRegisteredEvent event = new InstanceRegisteredEvent(applicationContext.getId(), null); - healthIndicator.onApplicationEvent(event); - return healthIndicator; - } - - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java deleted file mode 100644 index c93de0d1e9..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientProperties.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2013-2021 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.discovery; - -import java.util.Set; - -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * @author Ryan Baxter - * @deprecated use - * {@link org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties} - * instead. - */ -@Deprecated(forRemoval = true) -@ConfigurationProperties("spring.cloud.kubernetes.discovery") -public class KubernetesDiscoveryClientProperties { - - private String discoveryServerUrl; - - private boolean enabled = true; - - /** - * If set then only the services and endpoints matching these namespaces will be - * fetched from the Kubernetes API server. - */ - private Set namespaces = Set.of(); - - public String getDiscoveryServerUrl() { - return discoveryServerUrl; - } - - public void setDiscoveryServerUrl(String discoveryServerUrl) { - this.discoveryServerUrl = discoveryServerUrl; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - Set getNamespaces() { - return namespaces; - } - - void setNamespaces(Set namespaces) { - this.namespaces = namespaces; - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java index f61db9744e..228507e95d 100644 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java +++ b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClient.java @@ -32,15 +32,6 @@ public class KubernetesReactiveDiscoveryClient implements ReactiveDiscoveryClien private final WebClient webClient; - @Deprecated(forRemoval = true) - public KubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, - KubernetesDiscoveryClientProperties properties) { - if (!StringUtils.hasText(properties.getDiscoveryServerUrl())) { - throw new DiscoveryServerUrlInvalidException(); - } - this.webClient = webClientBuilder.baseUrl(properties.getDiscoveryServerUrl()).build(); - } - KubernetesReactiveDiscoveryClient(WebClient.Builder webClientBuilder, KubernetesDiscoveryProperties properties) { if (!StringUtils.hasText(properties.discoveryServerUrl())) { throw new DiscoveryServerUrlInvalidException(); diff --git a/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java b/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java index 376ff2d422..8b8c56ca13 100644 --- a/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java +++ b/spring-cloud-kubernetes-discovery/src/test/java/org/springframework/cloud/kubernetes/discovery/KubernetesReactiveDiscoveryClientTests.java @@ -19,11 +19,13 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; +import java.util.Set; import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.client.WireMock; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.springframework.cloud.kubernetes.commons.discovery.KubernetesDiscoveryProperties; import reactor.test.StepVerifier; import org.springframework.web.reactive.function.client.WebClient; @@ -105,19 +107,21 @@ static void beforeAll() { @Test void getInstances() { - KubernetesDiscoveryClientProperties properties = new KubernetesDiscoveryClientProperties(); - properties.setDiscoveryServerUrl(wireMockServer.baseUrl()); + KubernetesDiscoveryProperties discoveryProperties = new KubernetesDiscoveryProperties(true, true, Set.of(), + true, 60, false, null, Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, + false, false, wireMockServer.baseUrl()); KubernetesReactiveDiscoveryClient discoveryClient = new KubernetesReactiveDiscoveryClient(WebClient.builder(), - properties); + discoveryProperties); StepVerifier.create(discoveryClient.getServices()).expectNext("test-svc-1", "test-svc-3").verifyComplete(); } @Test void getServices() { - KubernetesDiscoveryClientProperties properties = new KubernetesDiscoveryClientProperties(); - properties.setDiscoveryServerUrl(wireMockServer.baseUrl()); + KubernetesDiscoveryProperties discoveryProperties = new KubernetesDiscoveryProperties(true, true, Set.of(), + true, 60, false, null, Set.of(), Map.of(), null, KubernetesDiscoveryProperties.Metadata.DEFAULT, 0, + false, false, wireMockServer.baseUrl()); KubernetesReactiveDiscoveryClient discoveryClient = new KubernetesReactiveDiscoveryClient(WebClient.builder(), - properties); + discoveryProperties); Map metadata = new HashMap<>(); metadata.put("spring", "true"); metadata.put("http", "8080"); From 6f676a084fb86f22002e802f3d9c5b16a3c57d53 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 19 Dec 2023 22:14:17 +0200 Subject: [PATCH 08/11] merge main --- .../pom.xml | 105 ---------------- .../kubernetes/fabric8/core/SimpleCoreIT.java | 116 ------------------ 2 files changed, 221 deletions(-) delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/pom.xml delete mode 100644 spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/src/test/java/org/springframework/cloud/kubernetes/fabric8/core/SimpleCoreIT.java diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/pom.xml b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/pom.xml deleted file mode 100644 index 0831f2928c..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - org.springframework.cloud - spring-cloud-kubernetes-integration-tests - 3.1.1-SNAPSHOT - - 4.0.0 - - spring-cloud-kubernetes-fabric8-client-simple-core - - - - org.springframework.cloud - spring-cloud-starter-kubernetes-fabric8-all - - - org.springframework.boot - spring-boot-starter-webflux - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.cloud - spring-cloud-kubernetes-test-support - - - - - - - ../src/main/resources - true - - - src/main/resources - true - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - docker.io/springcloud/${project.artifactId}:${project.version} - - - - build-image - - ${skip.build.image} - - package - - build-image - - - - repackage - package - - repackage - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - - - - - - ${testsToRun} - - - - - - - diff --git a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/src/test/java/org/springframework/cloud/kubernetes/fabric8/core/SimpleCoreIT.java b/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/src/test/java/org/springframework/cloud/kubernetes/fabric8/core/SimpleCoreIT.java deleted file mode 100644 index 7a810b3b2a..0000000000 --- a/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-client-simple-core/src/test/java/org/springframework/cloud/kubernetes/fabric8/core/SimpleCoreIT.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2013-2021 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.core; - -import java.io.InputStream; -import java.time.Duration; -import java.util.Objects; - -import io.fabric8.kubernetes.api.model.Service; -import io.fabric8.kubernetes.api.model.apps.Deployment; -import io.fabric8.kubernetes.api.model.networking.v1.Ingress; -import io.fabric8.kubernetes.client.KubernetesClient; -import io.fabric8.kubernetes.client.utils.Serialization; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -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.fabric8_client.Util; -import org.springframework.http.HttpMethod; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.web.reactive.function.client.WebClient; - -/** - * @author wind57 - */ -class SimpleCoreIT { - - private static final String NAMESPACE = "default"; - - private static final String IMAGE_NAME = "spring-cloud-kubernetes-fabric8-client-simple-core"; - - private static KubernetesClient client; - - private static Util util; - - private static final K3sContainer K3S = Commons.container(); - - @BeforeAll - static void beforeAll() throws Exception { - K3S.start(); - Commons.validateImage(IMAGE_NAME, K3S); - Commons.loadSpringCloudKubernetesImage(IMAGE_NAME, K3S); - - util = new Util(K3S); - client = util.client(); - util.setUp(NAMESPACE); - - manifests(Phase.CREATE); - } - - @AfterAll - static void after() throws Exception { - manifests(Phase.DELETE); - Commons.cleanUp(IMAGE_NAME, K3S); - Commons.systemPrune(); - } - - @Test - void test() { - WebClient client = builder().baseUrl("http://localhost/message").build(); - - String result = client.method(HttpMethod.GET).retrieve().bodyToMono(String.class).retryWhen(retrySpec()) - .block(); - - // value must come from application-kubernetes.yml - Assertions.assertEquals("Hello from k8s profile", result); - } - - private static void manifests(Phase phase) { - - InputStream deploymentStream = util.inputStream("simple-core-deployment.yaml"); - InputStream serviceStream = util.inputStream("simple-core-service.yaml"); - InputStream ingressStream = util.inputStream("simple-core-ingress.yaml"); - Deployment deployment = Serialization.unmarshal(deploymentStream, Deployment.class); - Service service = Serialization.unmarshal(serviceStream, Service.class); - Ingress ingress = Serialization.unmarshal(ingressStream, Ingress.class); - - if (phase.equals(Phase.CREATE)) { - util.createAndWait(NAMESPACE, null, deployment, service, ingress, true); - } - else { - 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); - } - -} From 783446a18d8a3480a23ed6331499a7bfb753a630 Mon Sep 17 00:00:00 2001 From: wind57 Date: Tue, 19 Dec 2023 22:17:41 +0200 Subject: [PATCH 09/11] removed deprecated --- .../discovery/KubernetesServiceInstance.java | 167 ------------------ .../cloud/kubernetes/discovery/Service.java | 50 ------ 2 files changed, 217 deletions(-) delete mode 100644 spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java delete mode 100644 spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java deleted file mode 100644 index 370d8c0210..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/KubernetesServiceInstance.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2013-2021 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.discovery; - -import java.net.URI; -import java.util.Map; -import java.util.Objects; - -import org.springframework.cloud.client.ServiceInstance; - -/** - * @author Ryan Baxter - */ -@Deprecated(forRemoval = true) -public class KubernetesServiceInstance implements ServiceInstance { - - private String instanceId; - - private String serviceId; - - private String host; - - private int port; - - private boolean secure; - - private URI uri; - - private Map metadata; - - private String scheme; - - private String namespace; - - public KubernetesServiceInstance() { - } - - public KubernetesServiceInstance(String instanceId, String serviceId, String host, int port, boolean secure, - URI uri, Map metadata, String scheme, String namespace) { - this.instanceId = instanceId; - this.serviceId = serviceId; - this.host = host; - this.port = port; - this.secure = secure; - this.uri = uri; - this.metadata = metadata; - this.scheme = scheme; - this.namespace = namespace; - } - - @Override - public String getInstanceId() { - return instanceId; - } - - @Override - public String getServiceId() { - return serviceId; - } - - @Override - public String getHost() { - return host; - } - - @Override - public int getPort() { - return port; - } - - @Override - public boolean isSecure() { - return secure; - } - - @Override - public URI getUri() { - return uri; - } - - @Override - public Map getMetadata() { - return metadata; - } - - public void setInstanceId(String instanceId) { - this.instanceId = instanceId; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public void setHost(String host) { - this.host = host; - } - - public void setPort(int port) { - this.port = port; - } - - public void setSecure(boolean secure) { - this.secure = secure; - } - - public void setUri(URI uri) { - this.uri = uri; - } - - public void setMetadata(Map metadata) { - this.metadata = metadata; - } - - public void setScheme(String scheme) { - this.scheme = scheme; - } - - public String getNamespace() { - return namespace; - } - - public void setNamespace(String namespace) { - this.namespace = namespace; - } - - @Override - public String getScheme() { - return scheme; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - KubernetesServiceInstance that = (KubernetesServiceInstance) o; - return getPort() == that.getPort() && isSecure() == that.isSecure() - && Objects.equals(getInstanceId(), that.getInstanceId()) - && Objects.equals(getServiceId(), that.getServiceId()) && Objects.equals(getHost(), that.getHost()) - && Objects.equals(getUri(), that.getUri()) && Objects.equals(getMetadata(), that.getMetadata()) - && Objects.equals(getScheme(), that.getScheme()) && Objects.equals(getNamespace(), that.getNamespace()); - } - - @Override - public int hashCode() { - return Objects.hash(getInstanceId(), getServiceId(), getHost(), getPort(), isSecure(), getUri(), getMetadata(), - getScheme(), getNamespace()); - } - -} diff --git a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java b/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java deleted file mode 100644 index 43c97c87f7..0000000000 --- a/spring-cloud-kubernetes-discovery/src/main/java/org/springframework/cloud/kubernetes/discovery/Service.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2013-2021 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.discovery; - -import java.util.List; - -/** - * @author Ryan Baxter - */ -@Deprecated(forRemoval = true) -public class Service { - - private String name; - - private List serviceInstances = List.of(); - - public Service() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getServiceInstances() { - return serviceInstances; - } - - public void setServiceInstances(List serviceInstances) { - this.serviceInstances = serviceInstances; - } - -} From eb31a371552c1f58c5b4b4b59e8cff2455345eee Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 6 Sep 2024 12:24:38 +0300 Subject: [PATCH 10/11] placeholder commit From 33a55554b12c861d3fabfd10c59fc98dd8fe0516 Mon Sep 17 00:00:00 2001 From: wind57 Date: Fri, 13 Sep 2024 18:09:55 +0300 Subject: [PATCH 11/11] placeholder commit