Skip to content

Commit b7db6c2

Browse files
David O'Sullivananthonydahanne
authored andcommitted
healthcheck polishing
1 parent e269dbd commit b7db6c2

File tree

9 files changed

+109
-5
lines changed

9 files changed

+109
-5
lines changed

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/applications/_ApplicationRelationships.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
22+
import org.cloudfoundry.Nullable;
2123
import org.cloudfoundry.client.v3.ToOneRelationship;
2224
import org.immutables.value.Value;
2325

@@ -38,6 +40,6 @@ abstract class _ApplicationRelationships {
3840
* The current droplet relationship
3941
*/
4042
@JsonProperty("current_droplet")
43+
@Nullable
4144
abstract ToOneRelationship getCurrentDroplet();
42-
4345
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/deployments/Deployment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,11 @@ public abstract class Deployment extends Resource {
9999
@JsonProperty("strategy")
100100
@Nullable
101101
public abstract DeploymentStrategy getStrategy();
102+
103+
/**
104+
* The options for the deployment
105+
*/
106+
@JsonProperty("options")
107+
@Nullable
108+
public abstract Options getOptions();
102109
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2013-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.cloudfoundry.client.v3.deployments;
18+
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.immutables.value.Value;
22+
23+
@JsonDeserialize
24+
@Value.Immutable
25+
abstract class _Options {
26+
27+
/**
28+
* The The maximum number of new instances to deploy simultaneously
29+
*/
30+
@JsonProperty("max_in_flight")
31+
abstract Integer getMaxInFlight();
32+
33+
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public abstract class Process extends Resource {
4848
* The readiness health check
4949
*/
5050
@JsonProperty("readiness_health_check")
51+
@Nullable
5152
public abstract ReadinessHealthCheck getReadinessHealthCheck();
5253

5354
/**

cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/CreateApplicationRequestTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ void noName() {
3939
.id("test-id")
4040
.build())
4141
.build())
42+
.currentDroplet(ToOneRelationship.builder()
43+
.data(Relationship.builder().build()).build())
4244
.build())
4345
.build();
4446
});
@@ -63,6 +65,8 @@ void valid() {
6365
ToOneRelationship.builder()
6466
.data(Relationship.builder().id("test-id").build())
6567
.build())
68+
.currentDroplet(ToOneRelationship.builder()
69+
.data(Relationship.builder().build()).build())
6670
.build())
6771
.build();
6872
}

cloudfoundry-client/src/test/java/org/cloudfoundry/client/v3/applications/RelationshipsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void valid() {
4040
ToOneRelationship.builder()
4141
.data(Relationship.builder().id("test-id").build())
4242
.build())
43+
.currentDroplet(ToOneRelationship.builder()
44+
.data(Relationship.builder().build()).build())
4345
.build();
4446
}
4547
}

integration-test/src/test/java/org/cloudfoundry/CloudFoundryVersion.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ public enum CloudFoundryVersion {
5555

5656
PCF_2_13(Version.forIntegers(2, 186, 0)),
5757

58-
PCF_3_0(Version.forIntegers(3, 0, 0)),
58+
PCF_4_v2(Version.forIntegers(2, 209, 0)),
59+
60+
PCF_4_v3(Version.forIntegers(3, 138, 0)),
5961

6062
UNSPECIFIED(Version.forIntegers(0));
6163

integration-test/src/test/java/org/cloudfoundry/client/v3/ProcessesTest.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,47 @@ private static Mono<Void> createApplication(
237237
.build());
238238
}
239239

240+
@Test
241+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_4_v2)
242+
public void updateReadinessHealthCheckType() throws IOException {
243+
String applicationName = this.nameFactory.getApplicationName();
244+
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
245+
246+
createApplication(this.cloudFoundryOperations, applicationName, path)
247+
.then(getApplicationId(this.cloudFoundryOperations, applicationName))
248+
.flatMap(applicationId -> getProcessId(this.cloudFoundryClient, applicationId))
249+
.flatMap(
250+
processId ->
251+
this.cloudFoundryClient
252+
.processes()
253+
.update(
254+
UpdateProcessRequest.builder()
255+
.readinessHealthCheck(
256+
ReadinessHealthCheck.builder()
257+
.data(
258+
Data.builder()
259+
.endpoint(
260+
"/test_endpoint")
261+
.invocationTimeout(
262+
1)
263+
.interval(2)
264+
.build())
265+
.type(
266+
ReadinessHealthCheckType
267+
.PORT)
268+
.build())
269+
.processId(processId)
270+
.build())
271+
.then(Mono.just(processId)))
272+
.flatMap(processId -> requestGetProcess(this.cloudFoundryClient, processId))
273+
.map(GetProcessResponse::getReadinessHealthCheck)
274+
.map(ReadinessHealthCheck::getType)
275+
.as(StepVerifier::create)
276+
.expectNext(ReadinessHealthCheckType.PORT)
277+
.expectComplete()
278+
.verify(Duration.ofMinutes(5));
279+
}
280+
240281
private static Mono<String> getApplicationId(
241282
CloudFoundryOperations cloudFoundryOperations, String applicationName) {
242283
return requestGetApplication(cloudFoundryOperations, applicationName)

integration-test/src/test/java/org/cloudfoundry/routing/v1/TcpRoutesTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
package org.cloudfoundry.routing.v1;
1818

19+
20+
import static org.cloudfoundry.util.DelayUtils.exponentialBackOff;
1921
import java.time.Duration;
22+
import java.util.List;
23+
2024
import org.cloudfoundry.AbstractIntegrationTest;
2125
import org.cloudfoundry.NameFactory;
2226
import org.cloudfoundry.routing.RoutingClient;
@@ -32,11 +36,14 @@
3236
import org.cloudfoundry.routing.v1.tcproutes.TcpRoute;
3337
import org.cloudfoundry.routing.v1.tcproutes.TcpRouteConfiguration;
3438
import org.cloudfoundry.routing.v1.tcproutes.TcpRouteDeletion;
39+
import org.cloudfoundry.routing.v1.tcproutes.TcpRoutes;
3540
import org.junit.jupiter.api.Test;
3641
import org.springframework.beans.factory.annotation.Autowired;
42+
3743
import reactor.core.publisher.Flux;
3844
import reactor.core.publisher.Mono;
3945
import reactor.test.StepVerifier;
46+
import reactor.util.retry.Retry;
4047

4148
public final class TcpRoutesTest extends AbstractIntegrationTest {
4249

@@ -96,7 +103,7 @@ public void delete() {
96103
port,
97104
routerGroupId))
98105
.flatMap(
99-
routerGroupId ->
106+
routerGroupId ->
100107
this.routingClient
101108
.tcpRoutes()
102109
.delete(
@@ -109,12 +116,17 @@ public void delete() {
109116
.routerGroupId(
110117
routerGroupId)
111118
.build())
112-
.build()))
113-
.then(requestListTcpRoutes(this.routingClient))
119+
.build())
120+
)
121+
.thenMany(requestListTcpRoutes(this.routingClient)
114122
.flatMapIterable(ListTcpRoutesResponse::getTcpRoutes)
115123
.filter(route -> backendIp.equals(route.getBackendIp()))
116124
.filter(route -> backendPort.equals(route.getBackendPort()))
117125
.filter(route -> port.equals(route.getPort()))
126+
.flatMap(e -> !"".equals(e.getBackendIp()) ? Flux.error(new RuntimeException("route still found")) : Flux.just(e)
127+
)
128+
.retryWhen(Retry.indefinitely().filter(e -> "route still found".equals(e.getMessage())))
129+
)
118130
.as(StepVerifier::create)
119131
.expectComplete()
120132
.verify(Duration.ofMinutes(5));

0 commit comments

Comments
 (0)