Skip to content

Commit

Permalink
Merge branch '3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
twoseat committed Jun 18, 2020
2 parents 0049f61 + 097eb72 commit 0b299d2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.cloudfoundry.operations.services;

import org.cloudfoundry.Nullable;
import org.cloudfoundry.client.v2.MaintenanceInfo;

import java.util.List;

Expand All @@ -41,6 +42,12 @@ public abstract class AbstractServiceInstanceSummary {
@Nullable
abstract String getLastOperation();

/**
* The maintenance info
*/
@Nullable
abstract MaintenanceInfo getMaintenanceInfo();

/**
* The service instance name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ private static Mono<UpdateServiceInstanceResponse> requestUpdateServiceInstance(
.update(org.cloudfoundry.client.v2.serviceinstances
.UpdateServiceInstanceRequest.builder()
.acceptsIncomplete(true)
.maintenanceInfo(request.getMaintenanceInfo())
.parameters(request.getParameters())
.serviceInstanceId(serviceInstanceId)
.servicePlanId(servicePlanId)
Expand Down Expand Up @@ -958,6 +959,7 @@ private static ServiceInstance toServiceInstance(UnionServiceInstanceResource re
.documentationUrl(documentationUrl.orElse(null))
.id(ResourceUtils.getId(resource))
.lastOperation(lastOperation.getType())
.maintenanceInfo(serviceInstanceEntity.getMaintenanceInfo())
.message(lastOperation.getDescription())
.name(serviceInstanceEntity.getName())
.plan(plan.orElse(null))
Expand Down Expand Up @@ -989,6 +991,7 @@ private static Flux<ServiceInstanceSummary> toServiceInstanceSummary(GetSpaceSum
.applications(Optional.ofNullable(applicationBindings.get(service.getName())).orElse(Collections.emptyList()))
.id(service.getId())
.lastOperation(service.getLastOperation() == null ? null : service.getLastOperation().getDescription())
.maintenanceInfo(service.getMaintenanceInfo())
.name(service.getName())
.plan(service.getServicePlan() == null ? null : service.getServicePlan().getName())
.service(service.getServicePlan() == null ? null : service.getServicePlan().getService().getLabel())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.cloudfoundry.AllowNulls;
import org.cloudfoundry.Nullable;
import org.cloudfoundry.client.v2.MaintenanceInfo;
import org.immutables.value.Value;

import java.time.Duration;
Expand All @@ -38,6 +39,12 @@ Duration getCompletionTimeout() {
return Duration.ofMinutes(5);
}

/**
* The maintenance info to upgrade to
*/
@Nullable
abstract MaintenanceInfo getMaintenanceInfo();

/**
* The parameters of the service instance
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.cloudfoundry.client.CloudFoundryClient;
import org.cloudfoundry.client.v2.ClientV2Exception;
import org.cloudfoundry.client.v2.MaintenanceInfo;
import org.cloudfoundry.client.v2.Metadata;
import org.cloudfoundry.client.v2.applications.ApplicationEntity;
import org.cloudfoundry.client.v2.applications.ApplicationResource;
Expand Down Expand Up @@ -480,6 +481,10 @@ public void getServiceInstanceManaged() {
.documentationUrl("test-documentation-url")
.id("test-service-instance-id")
.lastOperation("test-type")
.maintenanceInfo(MaintenanceInfo.builder()
.description("test-description")
.version("test-version")
.build())
.name("test-service-instance-name")
.plan("test-service-plan")
.tag("test-tag")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.cloudfoundry.client.v2;

import org.cloudfoundry.AbstractIntegrationTest;
import org.cloudfoundry.CloudFoundryVersion;
import org.cloudfoundry.IfCloudFoundryVersion;
import org.cloudfoundry.client.CloudFoundryClient;
import org.cloudfoundry.client.v2.applications.CreateApplicationRequest;
import org.cloudfoundry.client.v2.applications.CreateApplicationResponse;
Expand Down Expand Up @@ -778,6 +780,29 @@ public void updateEmptyCollections() {
.verify(Duration.ofMinutes(5));
}

@IfCloudFoundryVersion(greaterThanOrEqualTo = CloudFoundryVersion.PCF_2_7)
@Test
public void upgrade() {
String serviceInstanceName = this.nameFactory.getServiceInstanceName();

this.spaceId
.flatMap(spaceId -> createServiceInstanceId(this.cloudFoundryClient, this.serviceBrokerId, serviceInstanceName, this.serviceName, spaceId))
.flatMap(serviceInstanceId -> this.cloudFoundryClient.serviceInstances()
.update(UpdateServiceInstanceRequest.builder()
.maintenanceInfo(MaintenanceInfo.builder()
.description("test-update")
.version("9.9")
.build())
.serviceInstanceId(serviceInstanceId)
.build()))
.thenMany(requestListServiceInstances(this.cloudFoundryClient, serviceInstanceName))
.map(resource -> ResourceUtils.getEntity(resource).getMaintenanceInfo().getVersion())
.as(StepVerifier::create)
.consumeErrorWith(t -> assertThat(t).isInstanceOf(ClientV2Exception.class).hasMessageMatching("CF-MaintenanceInfoNotSupported\\([0-9]+\\): The service broker does not support upgrades " +
"for service instances created from this plan."))
.verify(Duration.ofMinutes(5));
}

private static Mono<BindServiceInstanceRouteResponse> createAndBindRoute(CloudFoundryClient cloudFoundryClient, String domainName, String organizationId, String spaceId, String
serviceInstanceId) {
return createPrivateDomainId(cloudFoundryClient, domainName, organizationId)
Expand Down

0 comments on commit 0b299d2

Please sign in to comment.