diff --git a/.gitignore b/.gitignore index 7d7fa1209e5..93988501f56 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ bin/ .factorypath .gradle .history/ +*.iml \ No newline at end of file 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 4dc2ec79c0a..4e23eea93e4 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 8efd6f66b45..e53ab748098 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 aadb83f8aa2..bd791faf15c 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 a8023d1c74f..d367c69e917 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 a8023d1c74f..d367c69e917 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 645e8768d8d..0ee0d5c3071 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 a8023d1c74f..d367c69e917 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 ccbff60e4a8..f136f02b962 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 a8023d1c74f..d367c69e917 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/CloudFoundryClient.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/CloudFoundryClient.java index 75186dbd8cd..658589e3a8c 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.245.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 42449efe6c3..5fbc363e645 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; @@ -34,4 +36,10 @@ abstract class _ApplicationRelationships { @JsonProperty("space") abstract ToOneRelationship getSpace(); + /** + * 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 5332f4d7628..6829057fee6 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 00000000000..ef6e199d650 --- /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 5500d8339bb..9cad9ca22b9 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,13 @@ public abstract class Process extends Resource { @JsonProperty("health_check") public abstract HealthCheck getHealthCheck(); + /** + * The readiness health check + */ + @JsonProperty("readiness_health_check") + @Nullable + public abstract ReadinessHealthCheck getReadinessHealthCheck(); + /** * The instances */ diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ProcessStatistics.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ProcessStatistics.java index 29758cba1b5..4b5cd36fc52 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ProcessStatistics.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ProcessStatistics.java @@ -57,6 +57,7 @@ public abstract class ProcessStatistics { * The index */ @JsonProperty("index") + @Nullable public abstract Integer getIndex(); /** 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 00000000000..2d0a761fbcc --- /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 81ab913dc1d..67af40ec2b6 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/client/v3/processes/_ProcessUsage.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ProcessUsage.java index 5a6398f668d..ab0a13340ce 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ProcessUsage.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ProcessUsage.java @@ -63,7 +63,7 @@ abstract class _ProcessUsage { @Nullable abstract Double getCpuEntitlement(); - /** + /** * The current logging usage of the instance */ @JsonProperty("log_rate") 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 00000000000..25ae6e009f1 --- /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 4fe26b3665e..d00f2a2177f 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-client/src/main/java/org/cloudfoundry/uaa/identityzones/_UserConfig.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/uaa/identityzones/_UserConfig.java index bec318c83f2..e7b9eaefe4a 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(); + } 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 0dc40da21f5..757e54bada1 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,10 @@ void noName() { .id("test-id") .build()) .build()) + .currentDroplet( + ToOneRelationship.builder() + .data(Relationship.builder().build()) + .build()) .build()) .build(); }); @@ -63,6 +67,10 @@ 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 c875469dd1f..4515b31fdc1 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/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java index 8f2f4bcadd0..fb7dc2e1bf9 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 a39e55c66c1..0504676d8b9 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 */ diff --git a/integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java b/integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java index 5be7b4fe0e3..65d7a8e38ce 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 5b2f10bfb07..b5091147934 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,19 +27,8 @@ 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.GetProcessRequest; -import org.cloudfoundry.client.v3.processes.GetProcessResponse; -import org.cloudfoundry.client.v3.processes.GetProcessStatisticsRequest; -import org.cloudfoundry.client.v3.processes.GetProcessStatisticsResponse; -import org.cloudfoundry.client.v3.processes.HealthCheck; -import org.cloudfoundry.client.v3.processes.HealthCheckType; -import org.cloudfoundry.client.v3.processes.ListProcessesRequest; +import org.cloudfoundry.client.v3.processes.*; 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.ScaleProcessRequest; -import org.cloudfoundry.client.v3.processes.TerminateProcessInstanceRequest; -import org.cloudfoundry.client.v3.processes.UpdateProcessRequest; import org.cloudfoundry.operations.CloudFoundryOperations; import org.cloudfoundry.operations.applications.ApplicationDetail; import org.cloudfoundry.operations.applications.ApplicationHealthCheck; @@ -237,6 +226,47 @@ private static Mono createApplication( .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(); + + 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)); + } + private static Mono getApplicationId( CloudFoundryOperations cloudFoundryOperations, String applicationName) { return requestGetApplication(cloudFoundryOperations, applicationName) diff --git a/integration-test/src/test/java/org/cloudfoundry/operations/ApplicationsTest.java b/integration-test/src/test/java/org/cloudfoundry/operations/ApplicationsTest.java index 2a87f6c5880..e04c488b0ca 100644 --- a/integration-test/src/test/java/org/cloudfoundry/operations/ApplicationsTest.java +++ b/integration-test/src/test/java/org/cloudfoundry/operations/ApplicationsTest.java @@ -1526,6 +1526,30 @@ public void setHealthCheck() throws IOException { .verify(Duration.ofMinutes(5)); } + @Test + public void setReadinessHealthCheck() throws IOException { + String applicationName = this.nameFactory.getApplicationName(); + + createApplication( + this.cloudFoundryOperations, + new ClassPathResource("test-application.zip").getFile().toPath(), + applicationName, + false) + .then( + this.cloudFoundryOperations + .applications() + .setHealthCheck( + SetApplicationHealthCheckRequest.builder() + .name(applicationName) + .type(ApplicationHealthCheck.PROCESS) + .build())) + .then(requestGetHealthCheck(this.cloudFoundryOperations, applicationName)) + .as(StepVerifier::create) + .expectNext(ApplicationHealthCheck.PROCESS) + .expectComplete() + .verify(Duration.ofMinutes(5)); + } + @Test public void sshEnabled() throws IOException { String applicationName = this.nameFactory.getApplicationName(); 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 27852f13fcf..a562fa42232 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 @@ -37,6 +37,7 @@ 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 { @@ -110,11 +111,25 @@ public void delete() { routerGroupId) .build()) .build())) - .then(requestListTcpRoutes(this.routingClient)) - .flatMapIterable(ListTcpRoutesResponse::getTcpRoutes) - .filter(route -> backendIp.equals(route.getBackendIp())) - .filter(route -> backendPort.equals(route.getBackendPort())) - .filter(route -> port.equals(route.getPort())) + .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)); diff --git a/integration-test/src/test/resources/test-application 2/Staticfile b/integration-test/src/test/resources/test-application 2/Staticfile new file mode 100644 index 00000000000..e69de29bb2d diff --git a/integration-test/src/test/resources/test-application 2/index.html b/integration-test/src/test/resources/test-application 2/index.html new file mode 100644 index 00000000000..27310af2b48 --- /dev/null +++ b/integration-test/src/test/resources/test-application 2/index.html @@ -0,0 +1,10 @@ + + + + +Hello Web! + + +

Hello Web!

+ +