Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -18,6 +18,7 @@

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;

Expand All @@ -32,6 +33,7 @@ abstract class _DeploymentRelationships {
* The app relationship
*/
@JsonProperty("app")
@Nullable
abstract ToOneRelationship getApp();

}
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