From 5ff0449cea32708860ce297c31239775b29b924f Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Wed, 13 Nov 2024 09:50:43 +0000 Subject: [PATCH 1/7] adds missing v3 fields & supported version --- .../java/org/cloudfoundry/client/CloudFoundryClient.java | 2 +- .../client/v3/applications/_ApplicationRelationships.java | 6 ++++++ .../java/org/cloudfoundry/client/v3/processes/_Data.java | 7 +++++++ .../org/cloudfoundry/uaa/identityzones/_UserConfig.java | 7 +++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java index 75186dbd8c..2182f77b94 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java @@ -81,7 +81,7 @@ public interface CloudFoundryClient { /** * The currently supported Cloud Controller API version */ - String SUPPORTED_API_VERSION = "2.233.0"; + String SUPPORTED_API_VERSION = "2.243.0"; /** * Main entry point to the Cloud Foundry Application Usage Events Client API diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java index 42449efe6c..760e5ee22a 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java @@ -34,4 +34,10 @@ abstract class _ApplicationRelationships { @JsonProperty("space") abstract ToOneRelationship getSpace(); + /** + * The current droplet relationship + */ + @JsonProperty("current_droplet") + abstract ToOneRelationship getCurrentDroplet(); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java index 81ab913dc1..67af40ec2b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java @@ -46,4 +46,11 @@ abstract class _Data { @Nullable abstract Integer getTimeout(); + /** + * The interval in seconds between health check requests + */ + @JsonProperty("interval") + @Nullable + abstract Integer getInterval(); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/uaa/identityzones/_UserConfig.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/uaa/identityzones/_UserConfig.java index bec318c83f..e7b9eaefe4 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/uaa/identityzones/_UserConfig.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/uaa/identityzones/_UserConfig.java @@ -60,5 +60,12 @@ abstract class _UserConfig { @Nullable abstract Boolean getcheckOriginEnabled(); + /** + * Flag for switching off the loop over all origins in a zone (defaults to true) + */ + @JsonProperty("allowOriginLoop") + @Nullable + abstract Boolean getAllowOriginLoop(); + } From 6f1579a53044d22db77105f4da3a51d9f0b859ec Mon Sep 17 00:00:00 2001 From: Yavor16 Date: Wed, 7 Feb 2024 09:15:44 +0200 Subject: [PATCH 2/7] add readiness health check support in client --- .../ReactorApplicationsV3Test.java | 42 +++++++++++ .../v3/processes/ReactorProcessesTest.java | 52 ++++++++++++++ .../v3/apps/GET_{id}_processes_response.json | 16 +++++ .../GET_{id}_processes_{type}_response.json | 8 +++ ...ocesses_{type}_actions_scale_response.json | 8 +++ .../client/v3/processes/GET_response.json | 16 +++++ .../v3/processes/GET_{id}_response.json | 8 +++ .../v3/processes/PATCH_{id}_response.json | 8 +++ .../POST_{id}_actions_scale_response.json | 8 +++ .../client/v3/processes/Process.java | 6 ++ .../processes/ReadinessHealthCheckType.java | 69 +++++++++++++++++++ .../client/v3/processes/_Data.java | 4 +- .../v3/processes/_ReadinessHealthCheck.java | 43 ++++++++++++ .../v3/processes/_UpdateProcessRequest.java | 7 ++ .../ApplicationManifestUtilsV3.java | 33 +++++++++ .../applications/_ManifestV3Process.java | 25 +++++++ 16 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java index 4dc2ec79c0..4e23eea93e 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java @@ -117,6 +117,8 @@ import org.cloudfoundry.client.v3.processes.ProcessState; import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; import org.cloudfoundry.client.v3.processes.ProcessUsage; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.cloudfoundry.client.v3.routes.Application; import org.cloudfoundry.client.v3.routes.Destination; import org.cloudfoundry.client.v3.routes.Process; @@ -807,6 +809,16 @@ void getProcess() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -1627,6 +1639,16 @@ void listProcesses() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -1685,6 +1707,16 @@ void listProcesses() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -2052,6 +2084,16 @@ void scale() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java index 8efd6f66b4..e53ab74809 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java @@ -43,6 +43,8 @@ import org.cloudfoundry.client.v3.processes.ProcessState; import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; import org.cloudfoundry.client.v3.processes.ProcessUsage; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.cloudfoundry.client.v3.processes.ScaleProcessRequest; import org.cloudfoundry.client.v3.processes.ScaleProcessResponse; import org.cloudfoundry.client.v3.processes.TerminateProcessInstanceRequest; @@ -121,6 +123,16 @@ void get() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -309,6 +321,16 @@ void list() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -367,6 +389,16 @@ void list() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -458,6 +490,16 @@ void scale() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -545,6 +587,16 @@ void update() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json index aadb83f8aa..bd791faf15 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json @@ -28,6 +28,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} @@ -68,6 +76,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json index a8023d1c74..d367c69e91 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json index a8023d1c74..d367c69e91 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json index 645e8768d8..0ee0d5c307 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json @@ -28,6 +28,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} @@ -68,6 +76,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json index a8023d1c74..d367c69e91 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json index ccbff60e4a..f136f02b96 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json index a8023d1c74..d367c69e91 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java index 5500d8339b..f1a66fe8eb 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java @@ -44,6 +44,12 @@ public abstract class Process extends Resource { @JsonProperty("health_check") public abstract HealthCheck getHealthCheck(); + /** + * The readiness health check + */ + @JsonProperty("readiness_health_check") + public abstract ReadinessHealthCheck getReadinessHealthCheck(); + /** * The instances */ diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java new file mode 100644 index 0000000000..2d0a761fbc --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java @@ -0,0 +1,69 @@ +/* + * Copyright 2013-2024 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 + * + * http://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.cloudfoundry.client.v3.processes; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ReadinessHealthCheckType { + + /** + * An http health check + */ + HTTP("http"), + + /** + * A port health check + */ + PORT("port"), + + /** + * A process health check + */ + PROCESS("process"); + + private final String value; + + ReadinessHealthCheckType(String value) { + this.value = value; + } + + @JsonCreator + public static ReadinessHealthCheckType from(String s) { + switch (s.toLowerCase()) { + case "http": + return HTTP; + case "port": + return PORT; + case "process": + return PROCESS; + default: + throw new IllegalArgumentException( + String.format("Unknown health check type: %s", s)); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + @Override + public String toString() { + return getValue(); + } +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java index 67af40ec2b..061b3eef02 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java @@ -47,8 +47,8 @@ abstract class _Data { abstract Integer getTimeout(); /** - * The interval in seconds between health check requests - */ + * The interval + */ @JsonProperty("interval") @Nullable abstract Integer getInterval(); diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java new file mode 100644 index 0000000000..25ae6e009f --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java @@ -0,0 +1,43 @@ +/* + * Copyright 2013-2024 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 + * + * http://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.cloudfoundry.client.v3.processes; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * The health check + */ +@JsonDeserialize +@Value.Immutable +abstract class _ReadinessHealthCheck { + + /** + * The data + */ + @JsonProperty("data") + @Nullable + abstract Data getData(); + + /** + * The type + */ + @JsonProperty("type") + abstract ReadinessHealthCheckType getType(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java index 4fe26b3665..d00f2a2177 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java @@ -43,6 +43,13 @@ abstract class _UpdateProcessRequest { @Nullable abstract HealthCheck getHealthCheck(); + /** + * The readiness health check + */ + @JsonProperty("readiness_health_check") + @Nullable + abstract ReadinessHealthCheck getReadinessHealthCheck(); + /** * The process id */ diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java index 8f2f4bcadd..fb7dc2e1bf 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; import java.util.stream.Stream; import org.cloudfoundry.client.v3.processes.HealthCheckType; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import reactor.core.Exceptions; @@ -209,6 +210,27 @@ private static ManifestV3Process getProcess( variables, s -> HealthCheckType.from((String) s), builder::healthCheckType); + asString( + raw, + "readiness-health-check-http-endpoint", + variables, + builder::readinessHealthCheckHttpEndpoint); + asInteger( + raw, + "readiness-health-check-invocation-timeout", + variables, + builder::readinessHealthCheckInvocationTimeout); + asInteger( + raw, + "readiness-health-check-interval", + variables, + builder::readinessHealthCheckInterval); + as( + raw, + "readiness-health-check-type", + variables, + s -> ReadinessHealthCheckType.from((String) s), + builder::readinessHealthCheckType); asInteger(raw, "instances", variables, builder::instances); asString(raw, "memory", variables, builder::memory); asInteger(raw, "timeout", variables, builder::timeout); @@ -294,6 +316,17 @@ private static Map toProcessYaml(ManifestV3Process process) { putIfPresent( yaml, "health-check-invocation-timeout", process.getHealthCheckInvocationTimeout()); putIfPresent(yaml, "health-check-type", process.getHealthCheckType().getValue()); + putIfPresent(yaml, "readiness-health-check-type", process.getReadinessHealthCheckType()); + putIfPresent( + yaml, + "readiness-health-check-http-endpoint", + process.getReadinessHealthCheckHttpEndpoint()); + putIfPresent( + yaml, + "readiness-health-check-invocation-timeout", + process.getReadinessHealthCheckInvocationTimeout()); + putIfPresent( + yaml, "readiness-health-check-interval", process.getReadinessHealthCheckInterval()); putIfPresent(yaml, "instances", process.getInstances()); putIfPresent(yaml, "memory", process.getMemory()); putIfPresent(yaml, "timeout", process.getTimeout()); diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java index a39e55c66c..0504676d8b 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java @@ -19,6 +19,7 @@ import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.processes.HealthCheckType; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.immutables.value.Value; @Value.Immutable @@ -54,6 +55,30 @@ abstract class _ManifestV3Process { @Nullable abstract HealthCheckType getHealthCheckType(); + /** + * Type of rediness health check to perform + */ + @Nullable + abstract ReadinessHealthCheckType getReadinessHealthCheckType(); + + /** + * The HTTP rediness health check endpoint + */ + @Nullable + abstract String getReadinessHealthCheckHttpEndpoint(); + + /** + * The timeout in seconds for individual rediness health check requests for http and port health checks + */ + @Nullable + abstract Integer getReadinessHealthCheckInvocationTimeout(); + + /** + * The timeout in seconds for individual rediness health check requests for http and port health checks + */ + @Nullable + abstract Integer getReadinessHealthCheckInterval(); + /** * The number of instances of this process */ From 25c7ecb8f41dd0f344d450c53ad15bee6cdb4047 Mon Sep 17 00:00:00 2001 From: Yavor16 Date: Mon, 19 Feb 2024 17:44:00 +0200 Subject: [PATCH 3/7] add integration test --- .../cloudfoundry/client/v3/ProcessesTest.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java index 5b2f10bfb0..b7f8cb5575 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java @@ -27,6 +27,7 @@ import org.cloudfoundry.client.CloudFoundryClient; import org.cloudfoundry.client.v3.applications.GetApplicationProcessRequest; import org.cloudfoundry.client.v3.applications.GetApplicationProcessResponse; +import org.cloudfoundry.client.v3.processes.Data; import org.cloudfoundry.client.v3.processes.GetProcessRequest; import org.cloudfoundry.client.v3.processes.GetProcessResponse; import org.cloudfoundry.client.v3.processes.GetProcessStatisticsRequest; @@ -37,6 +38,8 @@ import org.cloudfoundry.client.v3.processes.Process; import org.cloudfoundry.client.v3.processes.ProcessResource; import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.cloudfoundry.client.v3.processes.ScaleProcessRequest; import org.cloudfoundry.client.v3.processes.TerminateProcessInstanceRequest; import org.cloudfoundry.client.v3.processes.UpdateProcessRequest; @@ -234,7 +237,38 @@ private static Mono createApplication( .name(name) .path(path) .noStart(false) - .build()); + } + + @Test + public void updateReadinessHealthCheckType() throws IOException { + String applicationName = this.nameFactory.getApplicationName(); + Path path = new ClassPathResource("test-application.zip").getFile().toPath(); + + createApplication(this.cloudFoundryOperations, applicationName, path) + .then(getApplicationId(this.cloudFoundryOperations, applicationName)) + .flatMap(applicationId -> getProcessId(this.cloudFoundryClient, applicationId)) + .flatMap(processId -> this.cloudFoundryClient.processes() + .update(UpdateProcessRequest.builder() + .readinessHealthCheck(ReadinessHealthCheck + .builder() + .data(Data + .builder() + .endpoint("/test") + .invocationTimeout(1) + .interval(2) + .build()) + .type(ReadinessHealthCheckType.PORT) + .build()) + .processId(processId) + .build()) + .then(Mono.just(processId))) + .flatMap(processId -> requestGetProcess(this.cloudFoundryClient, processId)) + .map(GetProcessResponse::getReadinessHealthCheck) + .map(ReadinessHealthCheck::getType) + .as(StepVerifier::create) + .expectNext(ReadinessHealthCheckType.PORT) + .expectComplete() + .verify(Duration.ofMinutes(5)); } private static Mono getApplicationId( From 8a6deeb19882d71e2ffef8128a5dbe8924c6eb3d Mon Sep 17 00:00:00 2001 From: Yavor16 Date: Tue, 20 Feb 2024 11:35:13 +0200 Subject: [PATCH 4/7] fix formatting --- .../src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java index b7f8cb5575..933b8ba9c3 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java @@ -253,7 +253,7 @@ public void updateReadinessHealthCheckType() throws IOException { .builder() .data(Data .builder() - .endpoint("/test") + .endpoint("/test_endpoint") .invocationTimeout(1) .interval(2) .build()) From 0f1ad2ba313ffb9e5d8602511adddf0052b0723e Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Thu, 14 Nov 2024 12:06:53 +0000 Subject: [PATCH 5/7] healthcheck polishing --- .../_ApplicationRelationships.java | 4 +- .../client/v3/deployments/Deployment.java | 7 +++ .../client/v3/deployments/_Options.java | 33 ++++++++++ .../client/v3/processes/Process.java | 1 + .../CreateApplicationRequestTest.java | 4 ++ .../v3/applications/RelationshipsTest.java | 2 + .../org/cloudfoundry/CloudFoundryVersion.java | 4 +- .../cloudfoundry/client/v3/ProcessesTest.java | 60 +++++++++++-------- .../routing/v1/TcpRoutesTest.java | 18 +++++- 9 files changed, 103 insertions(+), 30 deletions(-) create mode 100644 cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/_Options.java diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java index 760e5ee22a..5fbc363e64 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.ToOneRelationship; import org.immutables.value.Value; @@ -38,6 +40,6 @@ abstract class _ApplicationRelationships { * The current droplet relationship */ @JsonProperty("current_droplet") + @Nullable abstract ToOneRelationship getCurrentDroplet(); - } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java index 5332f4d762..3fa990a335 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java @@ -99,4 +99,11 @@ public abstract class Deployment extends Resource { @JsonProperty("strategy") @Nullable public abstract DeploymentStrategy getStrategy(); + + /** + * The options for the deployment + */ + @JsonProperty("options") + @Nullable + public abstract Options getOptions(); } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/_Options.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/_Options.java new file mode 100644 index 0000000000..ef6e199d65 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/_Options.java @@ -0,0 +1,33 @@ +/* + * 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 + * + * http://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.cloudfoundry.client.v3.deployments; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.immutables.value.Value; + +@JsonDeserialize +@Value.Immutable +abstract class _Options { + + /** + * The The maximum number of new instances to deploy simultaneously + */ + @JsonProperty("max_in_flight") + abstract Integer getMaxInFlight(); + +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java index f1a66fe8eb..9cad9ca22b 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java @@ -48,6 +48,7 @@ public abstract class Process extends Resource { * The readiness health check */ @JsonProperty("readiness_health_check") + @Nullable public abstract ReadinessHealthCheck getReadinessHealthCheck(); /** diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java index 0dc40da21f..45070789c6 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java @@ -39,6 +39,8 @@ void noName() { .id("test-id") .build()) .build()) + .currentDroplet(ToOneRelationship.builder() + .data(Relationship.builder().build()).build()) .build()) .build(); }); @@ -63,6 +65,8 @@ void valid() { ToOneRelationship.builder() .data(Relationship.builder().id("test-id").build()) .build()) + .currentDroplet(ToOneRelationship.builder() + .data(Relationship.builder().build()).build()) .build()) .build(); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java index c875469dd1..87305633ed 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java @@ -40,6 +40,8 @@ void valid() { ToOneRelationship.builder() .data(Relationship.builder().id("test-id").build()) .build()) + .currentDroplet(ToOneRelationship.builder() + .data(Relationship.builder().build()).build()) .build(); } } diff --git a/integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java b/integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java index 5be7b4fe0e..65d7a8e38c 100644 --- a/integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java +++ b/integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java @@ -55,7 +55,9 @@ public enum CloudFoundryVersion { PCF_2_13(Version.forIntegers(2, 186, 0)), - PCF_3_0(Version.forIntegers(3, 0, 0)), + PCF_4_v2(Version.forIntegers(2, 209, 0)), + + PCF_4_v3(Version.forIntegers(3, 138, 0)), UNSPECIFIED(Version.forIntegers(0)); diff --git a/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java b/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java index 933b8ba9c3..aa7038fc88 100644 --- a/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java @@ -237,38 +237,48 @@ private static Mono createApplication( .name(name) .path(path) .noStart(false) + .build()); } @Test + @IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_4_v2) public void updateReadinessHealthCheckType() throws IOException { String applicationName = this.nameFactory.getApplicationName(); - Path path = new ClassPathResource("test-application.zip").getFile().toPath(); + Path path = new ClassPathResource("test-application.zip").getFile().toPath(); createApplication(this.cloudFoundryOperations, applicationName, path) - .then(getApplicationId(this.cloudFoundryOperations, applicationName)) - .flatMap(applicationId -> getProcessId(this.cloudFoundryClient, applicationId)) - .flatMap(processId -> this.cloudFoundryClient.processes() - .update(UpdateProcessRequest.builder() - .readinessHealthCheck(ReadinessHealthCheck - .builder() - .data(Data - .builder() - .endpoint("/test_endpoint") - .invocationTimeout(1) - .interval(2) - .build()) - .type(ReadinessHealthCheckType.PORT) - .build()) - .processId(processId) - .build()) - .then(Mono.just(processId))) - .flatMap(processId -> requestGetProcess(this.cloudFoundryClient, processId)) - .map(GetProcessResponse::getReadinessHealthCheck) - .map(ReadinessHealthCheck::getType) - .as(StepVerifier::create) - .expectNext(ReadinessHealthCheckType.PORT) - .expectComplete() - .verify(Duration.ofMinutes(5)); + .then(getApplicationId(this.cloudFoundryOperations, applicationName)) + .flatMap(applicationId -> getProcessId(this.cloudFoundryClient, applicationId)) + .flatMap( + processId -> + this.cloudFoundryClient + .processes() + .update( + UpdateProcessRequest.builder() + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .data( + Data.builder() + .endpoint( + "/test_endpoint") + .invocationTimeout( + 1) + .interval(2) + .build()) + .type( + ReadinessHealthCheckType + .PORT) + .build()) + .processId(processId) + .build()) + .then(Mono.just(processId))) + .flatMap(processId -> requestGetProcess(this.cloudFoundryClient, processId)) + .map(GetProcessResponse::getReadinessHealthCheck) + .map(ReadinessHealthCheck::getType) + .as(StepVerifier::create) + .expectNext(ReadinessHealthCheckType.PORT) + .expectComplete() + .verify(Duration.ofMinutes(5)); } private static Mono getApplicationId( diff --git a/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java b/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java index 27852f13fc..17419490a0 100644 --- a/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java @@ -16,7 +16,11 @@ package org.cloudfoundry.routing.v1; + +import static org.cloudfoundry.util.DelayUtils.exponentialBackOff; import java.time.Duration; +import java.util.List; + import org.cloudfoundry.AbstractIntegrationTest; import org.cloudfoundry.NameFactory; import org.cloudfoundry.routing.RoutingClient; @@ -32,11 +36,14 @@ import org.cloudfoundry.routing.v1.tcproutes.TcpRoute; import org.cloudfoundry.routing.v1.tcproutes.TcpRouteConfiguration; import org.cloudfoundry.routing.v1.tcproutes.TcpRouteDeletion; +import org.cloudfoundry.routing.v1.tcproutes.TcpRoutes; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; + import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; +import reactor.util.retry.Retry; public final class TcpRoutesTest extends AbstractIntegrationTest { @@ -96,7 +103,7 @@ public void delete() { port, routerGroupId)) .flatMap( - routerGroupId -> + routerGroupId -> this.routingClient .tcpRoutes() .delete( @@ -109,12 +116,17 @@ public void delete() { .routerGroupId( routerGroupId) .build()) - .build())) - .then(requestListTcpRoutes(this.routingClient)) + .build()) + ) + .thenMany(requestListTcpRoutes(this.routingClient) .flatMapIterable(ListTcpRoutesResponse::getTcpRoutes) .filter(route -> backendIp.equals(route.getBackendIp())) .filter(route -> backendPort.equals(route.getBackendPort())) .filter(route -> port.equals(route.getPort())) + .flatMap(e -> !"".equals(e.getBackendIp()) ? Flux.error(new RuntimeException("route still found")) : Flux.just(e) + ) + .retryWhen(Retry.indefinitely().filter(e -> "route still found".equals(e.getMessage()))) + ) .as(StepVerifier::create) .expectComplete() .verify(Duration.ofMinutes(5)); From a3533e922c906c7783cbb3981a5fb497095aa2c5 Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Tue, 2 Apr 2024 15:38:59 +0100 Subject: [PATCH 6/7] bump supported API --- .../main/java/org/cloudfoundry/client/CloudFoundryClient.java | 2 +- .../test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java index 2182f77b94..658589e3a8 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java @@ -81,7 +81,7 @@ public interface CloudFoundryClient { /** * The currently supported Cloud Controller API version */ - String SUPPORTED_API_VERSION = "2.243.0"; + String SUPPORTED_API_VERSION = "2.245.0"; /** * Main entry point to the Cloud Foundry Application Usage Events Client API diff --git a/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java b/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java index 17419490a0..848d3d8644 100644 --- a/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java @@ -123,7 +123,9 @@ public void delete() { .filter(route -> backendIp.equals(route.getBackendIp())) .filter(route -> backendPort.equals(route.getBackendPort())) .filter(route -> port.equals(route.getPort())) - .flatMap(e -> !"".equals(e.getBackendIp()) ? Flux.error(new RuntimeException("route still found")) : Flux.just(e) + .flatMap(e -> !"".equals(e.getBackendIp()) ? + Flux.error(new RuntimeException("route still found")) : + Flux.just(e) ) .retryWhen(Retry.indefinitely().filter(e -> "route still found".equals(e.getMessage()))) ) From 527beabd0ec764cf283c70ded27eadd91292fbc3 Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Tue, 3 Dec 2024 15:39:05 +0000 Subject: [PATCH 7/7] spotless plugin changes --- .../client/v3/deployments/Deployment.java | 2 +- .../CreateApplicationRequestTest.java | 12 ++++-- .../v3/applications/RelationshipsTest.java | 4 +- .../routing/v1/TcpRoutesTest.java | 41 ++++++++++--------- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java index 3fa990a335..6829057fee 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java @@ -100,7 +100,7 @@ public abstract class Deployment extends Resource { @Nullable public abstract DeploymentStrategy getStrategy(); - /** + /** * The options for the deployment */ @JsonProperty("options") diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java index 45070789c6..757e54bada 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java @@ -39,8 +39,10 @@ void noName() { .id("test-id") .build()) .build()) - .currentDroplet(ToOneRelationship.builder() - .data(Relationship.builder().build()).build()) + .currentDroplet( + ToOneRelationship.builder() + .data(Relationship.builder().build()) + .build()) .build()) .build(); }); @@ -65,8 +67,10 @@ void valid() { ToOneRelationship.builder() .data(Relationship.builder().id("test-id").build()) .build()) - .currentDroplet(ToOneRelationship.builder() - .data(Relationship.builder().build()).build()) + .currentDroplet( + ToOneRelationship.builder() + .data(Relationship.builder().build()) + .build()) .build()) .build(); } diff --git a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java index 87305633ed..4515b31fdc 100644 --- a/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java +++ b/cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java @@ -40,8 +40,8 @@ void valid() { ToOneRelationship.builder() .data(Relationship.builder().id("test-id").build()) .build()) - .currentDroplet(ToOneRelationship.builder() - .data(Relationship.builder().build()).build()) + .currentDroplet( + ToOneRelationship.builder().data(Relationship.builder().build()).build()) .build(); } } diff --git a/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java b/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java index 848d3d8644..a562fa4223 100644 --- a/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java @@ -16,11 +16,7 @@ package org.cloudfoundry.routing.v1; - -import static org.cloudfoundry.util.DelayUtils.exponentialBackOff; import java.time.Duration; -import java.util.List; - import org.cloudfoundry.AbstractIntegrationTest; import org.cloudfoundry.NameFactory; import org.cloudfoundry.routing.RoutingClient; @@ -36,10 +32,8 @@ import org.cloudfoundry.routing.v1.tcproutes.TcpRoute; import org.cloudfoundry.routing.v1.tcproutes.TcpRouteConfiguration; import org.cloudfoundry.routing.v1.tcproutes.TcpRouteDeletion; -import org.cloudfoundry.routing.v1.tcproutes.TcpRoutes; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -103,7 +97,7 @@ public void delete() { port, routerGroupId)) .flatMap( - routerGroupId -> + routerGroupId -> this.routingClient .tcpRoutes() .delete( @@ -116,19 +110,26 @@ public void delete() { .routerGroupId( routerGroupId) .build()) - .build()) - ) - .thenMany(requestListTcpRoutes(this.routingClient) - .flatMapIterable(ListTcpRoutesResponse::getTcpRoutes) - .filter(route -> backendIp.equals(route.getBackendIp())) - .filter(route -> backendPort.equals(route.getBackendPort())) - .filter(route -> port.equals(route.getPort())) - .flatMap(e -> !"".equals(e.getBackendIp()) ? - Flux.error(new RuntimeException("route still found")) : - Flux.just(e) - ) - .retryWhen(Retry.indefinitely().filter(e -> "route still found".equals(e.getMessage()))) - ) + .build())) + .thenMany( + requestListTcpRoutes(this.routingClient) + .flatMapIterable(ListTcpRoutesResponse::getTcpRoutes) + .filter(route -> backendIp.equals(route.getBackendIp())) + .filter(route -> backendPort.equals(route.getBackendPort())) + .filter(route -> port.equals(route.getPort())) + .flatMap( + e -> + !"".equals(e.getBackendIp()) + ? Flux.error( + new RuntimeException( + "route still found")) + : Flux.just(e)) + .retryWhen( + Retry.indefinitely() + .filter( + e -> + "route still found" + .equals(e.getMessage())))) .as(StepVerifier::create) .expectComplete() .verify(Duration.ofMinutes(5));