Skip to content

Commit

Permalink
Merge pull request #1138 from cloudfoundry/tas_2_11
Browse files Browse the repository at this point in the history
CC API version 2.171.0
  • Loading branch information
pivotal-david-osullivan authored Feb 23, 2022
2 parents e611cd2 + c329221 commit dd88827
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public interface CloudFoundryClient {
/**
* The currently supported Cloud Controller API version
*/
String SUPPORTED_API_VERSION = "2.150.0";
String SUPPORTED_API_VERSION = "2.171.0";

/**
* Main entry point to the Cloud Foundry Application Usage Events Client API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public enum CloudFoundryVersion {

PCF_2_11(Version.forIntegers(2, 164, 0)),

PCF_2_12(Version.forIntegers(2, 171, 0)),

UNSPECIFIED(Version.forIntegers(0));

private final Version version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.cloudfoundry.client.v3.deployments.DeploymentRelationships;
import org.cloudfoundry.client.v3.deployments.DeploymentResource;
import org.cloudfoundry.client.v3.deployments.DeploymentState;
import org.cloudfoundry.client.v3.deployments.DeploymentStatusReason;
import org.cloudfoundry.client.v3.deployments.DeploymentStatusValue;
import org.cloudfoundry.client.v3.deployments.GetDeploymentRequest;
import org.cloudfoundry.client.v3.deployments.ListDeploymentsRequest;
Expand Down Expand Up @@ -60,8 +61,35 @@ public final class DeploymentsTest extends AbstractIntegrationTest {
@Autowired
private CloudFoundryOperations cloudFoundryOperations;

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_11)
public void cancel_2_11() throws Exception {
String name = this.nameFactory.getApplicationName();
Path path = new ClassPathResource("test-application.zip").getFile().toPath();

createApplicationId(this.cloudFoundryOperations, name, path)
.flatMap(applicationId -> Mono.zip(
Mono.just(applicationId),
getDropletId(this.cloudFoundryClient, applicationId)
))
.flatMap(function((applicationId, dropletId) -> Mono.zip(
Mono.just(applicationId),
createDeploymentId(this.cloudFoundryClient, applicationId, dropletId)
)))
.flatMap(function((applicationId, deploymentId) -> this.cloudFoundryClient.deploymentsV3()
.cancel(CancelDeploymentRequest.builder()
.deploymentId(deploymentId)
.build())
.then(Mono.just(applicationId))))
.flatMapMany(applicationId -> requestListDeployments(this.cloudFoundryClient, applicationId))
.as(StepVerifier::create)
.consumeNextWith(deploymentResource -> assertThat(deploymentResource.getStatus().getReason()).isIn(DeploymentStatusReason.CANCELED, DeploymentStatusReason.CANCELING))
.expectComplete()
.verify(Duration.ofMinutes(5));
}

@SuppressWarnings("deprecation")
@Test
@IfCloudFoundryVersion(lessThanOrEqualTo = CloudFoundryVersion.PCF_2_10)
public void cancel() throws Exception {
String name = this.nameFactory.getApplicationName();
Path path = new ClassPathResource("test-application.zip").getFile().toPath();
Expand All @@ -81,9 +109,8 @@ public void cancel() throws Exception {
.build())
.then(Mono.just(applicationId))))
.flatMapMany(applicationId -> requestListDeployments(this.cloudFoundryClient, applicationId))
.map(DeploymentResource::getState)
.as(StepVerifier::create)
.consumeNextWith(isCancel())
.consumeNextWith(deploymentResource -> assertThat(deploymentResource.getState()).isIn(DeploymentState.CANCELING, DeploymentState.CANCELED))
.expectComplete()
.verify(Duration.ofMinutes(5));
}
Expand Down Expand Up @@ -255,10 +282,6 @@ private static Mono<String> getDropletId(CloudFoundryClient cloudFoundryClient,
.map(GetApplicationCurrentDropletResponse::getId);
}

private static Consumer<DeploymentState> isCancel() {
return state -> assertThat(state).isIn(DeploymentState.CANCELING, DeploymentState.CANCELED);
}

private static Mono<Void> requestCreateApplication(CloudFoundryOperations cloudFoundryOperations, String name, Path path) {
return cloudFoundryOperations.applications()
.push(PushApplicationRequest.builder()
Expand Down

0 comments on commit dd88827

Please sign in to comment.