Skip to content

Commit c85a215

Browse files
committed
Fix Application Scaling
This commit adds an integration test for scaling. [resolves #1010] Signed-off-by: Paul Harris <[email protected]>
1 parent 2dbee10 commit c85a215

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

cloudfoundry-client-reactor/src/main/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.cloudfoundry.reactor.ConnectionContext;
6565
import org.cloudfoundry.reactor.TokenProvider;
6666
import org.cloudfoundry.reactor.client.v3.AbstractClientV3Operations;
67-
6867
import reactor.core.publisher.Mono;
6968

7069
import java.util.Map;

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ public void listTasks() {
12781278
public void scale() {
12791279
mockRequest(InteractionContext.builder()
12801280
.request(TestRequest.builder()
1281-
.method(PUT).path("/apps/test-application-id/processes/test-type/actions/scale")
1281+
.method(POST).path("/apps/test-application-id/processes/test-type/actions/scale")
12821282
.payload("fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_request.json")
12831283
.build())
12841284
.response(TestResponse.builder()

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import org.cloudfoundry.client.v3.applications.ApplicationRelationships;
2424
import org.cloudfoundry.client.v3.applications.CreateApplicationRequest;
2525
import org.cloudfoundry.client.v3.applications.CreateApplicationResponse;
26+
import org.cloudfoundry.client.v3.applications.GetApplicationProcessRequest;
27+
import org.cloudfoundry.client.v3.applications.GetApplicationProcessResponse;
2628
import org.cloudfoundry.client.v3.applications.ListApplicationRoutesRequest;
29+
import org.cloudfoundry.client.v3.applications.ScaleApplicationRequest;
2730
import org.cloudfoundry.client.v3.domains.CreateDomainRequest;
2831
import org.cloudfoundry.client.v3.domains.CreateDomainResponse;
2932
import org.cloudfoundry.client.v3.domains.DomainRelationships;
@@ -335,6 +338,28 @@ public void listApplicationRoutesBySpaceId() {
335338
.verify(Duration.ofMinutes(5));
336339
}
337340

341+
@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_9)
342+
@Test
343+
public void scale() {
344+
String applicationName = this.nameFactory.getApplicationName();
345+
346+
this.spaceId
347+
.flatMap(spaceId -> createApplicationId(this.cloudFoundryClient, applicationName, spaceId))
348+
.flatMap(applicationId -> this.cloudFoundryClient.applicationsV3()
349+
.scale(ScaleApplicationRequest.builder()
350+
.applicationId(applicationId)
351+
.diskInMb(404)
352+
.type("web")
353+
.build())
354+
.thenReturn(applicationId))
355+
.flatMap(applicationId -> requestApplicationProcess(this.cloudFoundryClient, applicationId))
356+
.map(GetApplicationProcessResponse::getDiskInMb)
357+
.as(StepVerifier::create)
358+
.expectNext(404)
359+
.expectComplete()
360+
.verify(Duration.ofMinutes(5));
361+
}
362+
338363
private static Mono<String> createApplicationId(CloudFoundryClient cloudFoundryClient, String applicationName, String spaceId) {
339364
return requestCreateApplication(cloudFoundryClient, applicationName, spaceId)
340365
.map(CreateApplicationResponse::getId);
@@ -365,6 +390,14 @@ private static Mono<String> createSpaceId(CloudFoundryClient cloudFoundryClient,
365390
.map(CreateSpaceResponse::getId);
366391
}
367392

393+
private static Mono<GetApplicationProcessResponse> requestApplicationProcess(CloudFoundryClient cloudFoundryClient, String applicationId) {
394+
return cloudFoundryClient.applicationsV3()
395+
.getProcess(GetApplicationProcessRequest.builder()
396+
.applicationId(applicationId)
397+
.type("web")
398+
.build());
399+
}
400+
368401
private static Mono<CreateApplicationResponse> requestCreateApplication(CloudFoundryClient cloudFoundryClient, String applicationName, String spaceId) {
369402
return cloudFoundryClient.applicationsV3()
370403
.create(CreateApplicationRequest.builder()

0 commit comments

Comments
 (0)