Skip to content

Commit 0f1ad2b

Browse files
author
David O'Sullivan
committed
healthcheck polishing
1 parent 8a6deeb commit 0f1ad2b

File tree

9 files changed

+103
-30
lines changed

9 files changed

+103
-30
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: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -237,38 +237,48 @@ private static Mono<Void> createApplication(
237237
.name(name)
238238
.path(path)
239239
.noStart(false)
240+
.build());
240241
}
241242

242243
@Test
244+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_4_v2)
243245
public void updateReadinessHealthCheckType() throws IOException {
244246
String applicationName = this.nameFactory.getApplicationName();
245-
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
247+
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
246248

247249
createApplication(this.cloudFoundryOperations, applicationName, path)
248-
.then(getApplicationId(this.cloudFoundryOperations, applicationName))
249-
.flatMap(applicationId -> getProcessId(this.cloudFoundryClient, applicationId))
250-
.flatMap(processId -> this.cloudFoundryClient.processes()
251-
.update(UpdateProcessRequest.builder()
252-
.readinessHealthCheck(ReadinessHealthCheck
253-
.builder()
254-
.data(Data
255-
.builder()
256-
.endpoint("/test_endpoint")
257-
.invocationTimeout(1)
258-
.interval(2)
259-
.build())
260-
.type(ReadinessHealthCheckType.PORT)
261-
.build())
262-
.processId(processId)
263-
.build())
264-
.then(Mono.just(processId)))
265-
.flatMap(processId -> requestGetProcess(this.cloudFoundryClient, processId))
266-
.map(GetProcessResponse::getReadinessHealthCheck)
267-
.map(ReadinessHealthCheck::getType)
268-
.as(StepVerifier::create)
269-
.expectNext(ReadinessHealthCheckType.PORT)
270-
.expectComplete()
271-
.verify(Duration.ofMinutes(5));
250+
.then(getApplicationId(this.cloudFoundryOperations, applicationName))
251+
.flatMap(applicationId -> getProcessId(this.cloudFoundryClient, applicationId))
252+
.flatMap(
253+
processId ->
254+
this.cloudFoundryClient
255+
.processes()
256+
.update(
257+
UpdateProcessRequest.builder()
258+
.readinessHealthCheck(
259+
ReadinessHealthCheck.builder()
260+
.data(
261+
Data.builder()
262+
.endpoint(
263+
"/test_endpoint")
264+
.invocationTimeout(
265+
1)
266+
.interval(2)
267+
.build())
268+
.type(
269+
ReadinessHealthCheckType
270+
.PORT)
271+
.build())
272+
.processId(processId)
273+
.build())
274+
.then(Mono.just(processId)))
275+
.flatMap(processId -> requestGetProcess(this.cloudFoundryClient, processId))
276+
.map(GetProcessResponse::getReadinessHealthCheck)
277+
.map(ReadinessHealthCheck::getType)
278+
.as(StepVerifier::create)
279+
.expectNext(ReadinessHealthCheckType.PORT)
280+
.expectComplete()
281+
.verify(Duration.ofMinutes(5));
272282
}
273283

274284
private static Mono<String> getApplicationId(

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)