diff --git a/launch-locally-acceptance-tests.bash b/launch-locally-acceptance-tests.bash index 19aeb5d5..c8dbcdea 100755 --- a/launch-locally-acceptance-tests.bash +++ b/launch-locally-acceptance-tests.bash @@ -6,13 +6,14 @@ source ~/.osb-cmdb.env build() { ./gradlew ${gradle_proxy_config} clean assemble osb-cmdb:bootJar -x test +# ./gradlew ${gradle_proxy_config} assemble osb-cmdb:bootJar -x test } rename_jar_file_to_be_predicable() { #See inspiration from http://tldp.org/LDP/abs/html/globbingref.html #IFS="$(printf '\n\t')" # Remove space. - for file in ${PWD}/osb-cmdb/build/libs/osb-cmdb-*-SNAPSHOT.jar ; do # Use ./* ... NEVER bare * + for file in ${PWD}/osb-cmdb/build/libs/osb-cmdb-*.jar ; do # Use ./* ... NEVER bare * echo "copying $file into $PWD/osb-cmdb/build/libs/osb-cmdb.jar" diff --git a/osb-cmdb/build.gradle b/osb-cmdb/build.gradle index 29ee3460..b5e7f2db 100644 --- a/osb-cmdb/build.gradle +++ b/osb-cmdb/build.gradle @@ -26,6 +26,15 @@ java { } } +// Skip generation of osb-cmdb-plain.jar which may be picked by error +// Source - https://stackoverflow.com/questions/67663728/spring-boot-2-5-0-generates-plain-jar-file-can-i-remove-it +// Posted by Tien Do Nam +// Retrieved 11/5/2025, License - CC-BY-SA 4.0 +jar { + enabled = false +} + + // See https://docs.spring.io/spring-boot/gradle-plugin/packaging.html#packaging-executable.configuring.main-class springBoot { mainClass = 'com.orange.oss.osbcmdb.OsbCmdbApplication' diff --git a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/servicebinding/OsbCmdbServiceBinding.java b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/servicebinding/OsbCmdbServiceBinding.java index 5a989d53..5d927804 100644 --- a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/servicebinding/OsbCmdbServiceBinding.java +++ b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/servicebinding/OsbCmdbServiceBinding.java @@ -6,10 +6,9 @@ import java.time.Duration; import com.orange.oss.osbcmdb.AbstractOsbCmdbService; +import java.util.function.Function; import org.cloudfoundry.client.CloudFoundryClient; import org.cloudfoundry.client.v2.ClientV2Exception; -import org.cloudfoundry.client.v2.servicekeys.CreateServiceKeyRequest; -import org.cloudfoundry.client.v2.servicekeys.CreateServiceKeyResponse; import org.cloudfoundry.client.v3.Relationship; import org.cloudfoundry.client.v3.ToOneRelationship; import org.cloudfoundry.client.v3.jobs.GetJobRequest; @@ -23,15 +22,20 @@ import org.cloudfoundry.client.v3.servicebindings.ListServiceBindingsRequest; import org.cloudfoundry.client.v3.servicebindings.ListServiceBindingsResponse; import org.cloudfoundry.client.v3.servicebindings.ServiceBindingRelationships; +import org.cloudfoundry.client.v3.servicebindings.ServiceBindingResource; import org.cloudfoundry.client.v3.servicebindings.ServiceBindingType; import org.cloudfoundry.operations.CloudFoundryOperations; import org.cloudfoundry.operations.services.GetServiceKeyRequest; import org.cloudfoundry.operations.services.ServiceInstance; import org.cloudfoundry.operations.services.ServiceKey; +import org.cloudfoundry.util.JobUtils; +import org.cloudfoundry.util.PaginationUtils; +import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; import reactor.util.Logger; import reactor.util.Loggers; +import org.springframework.cloud.servicebroker.exception.ServiceBrokerException; import org.springframework.cloud.servicebroker.exception.ServiceBrokerInvalidParametersException; import org.springframework.cloud.servicebroker.exception.ServiceInstanceDoesNotExistException; import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceAppBindingResponse; @@ -66,7 +70,7 @@ public OsbCmdbServiceBinding(CloudFoundryClient cloudFoundryClient, String defau @Override public Mono createServiceInstanceBinding( - CreateServiceInstanceBindingRequest request) { + final CreateServiceInstanceBindingRequest request) { if (osbInterceptor != null && osbInterceptor.accept(request)) { return osbInterceptor.createServiceInstanceBinding(request); } @@ -82,47 +86,42 @@ public Mono createServiceInstanceBinding( if (existingSi == null) { LOG.warn("Asked to bind service instance id={} which does not exists in backing space associated with " + "service definition name={}", request.getServiceInstanceId(), request.getServiceDefinition().getName()); - throw new ServiceBrokerInvalidParametersException("instance_id path param: " + request.getServiceInstanceId() + " " + - "does not match service_id=" + request.getServiceDefinitionId() + " (possibly missing backing service " + - "instance guid associated with requested instance_id of type service_id))"); + throw new ServiceBrokerInvalidParametersException( + "instance_id path param: " + request.getServiceInstanceId() + " " + + "does not match service_id=" + request.getServiceDefinitionId() + " (possibly missing backing service " + + "instance guid associated with requested instance_id of type service_id))"); } - //Try to use the v2 api to request a synchronous service binding creation - try { - CreateServiceKeyResponse createServiceKeyResponse = client.serviceKeys() - .create(CreateServiceKeyRequest.builder() - .serviceInstanceId(existingSi.getId()) - .parameters(request.getParameters()) - .name(request.getBindingId()) - .build()) - .block(); - //If no error, assume async binding completed synchronously, and return success - assert createServiceKeyResponse != null; - assert createServiceKeyResponse.getEntity().getCredentials() != null; + return createServiceBindingCapiv3OBlocking(request, existingSi); - //Return 201 Created - return Mono.just(CreateServiceInstanceAppBindingResponse.builder() - .credentials(createServiceKeyResponse.getEntity().getCredentials()) - .async(false) - .build()); - } - catch (Exception originalException) { - //Only proceed when receiving async required exception - if (isExceptionReportingAsyncRequired(originalException)) { - LOG.info("Unable to create sync service binding, caught:" + originalException + " Trying async"); - } - else { - LOG.info("Unable to create service binding, caught:" + originalException); - throw redactExceptionAndWrapAsServiceBrokerException(originalException); - } - } + } + private static Mono requestSingleListServiceBindingsIdOrError( + CloudFoundryClient cloudFoundryClient, String serviceInstanceName, String serviceBindingName) { + return PaginationUtils.requestClientV3Resources( + page -> + cloudFoundryClient + .serviceBindingsV3() + .list( + ListServiceBindingsRequest.builder() + .page(page) + .serviceInstanceName(serviceInstanceName) + .name(serviceBindingName) + .build())) + .single() + .map(ServiceBindingResource::getId) + .switchIfEmpty(Mono.error(new ServiceBrokerException("Unable to list created service binding"))); + } + /** + * Currently blocked attempt to use capi v3 only calls: JobId is always returned + */ + @NotNull + private Mono createServiceBindingCapiv3OBlocking( + CreateServiceInstanceBindingRequest request, ServiceInstance existingSi) { try { - //Ask for async binding creation. No async opt-out is supported in CAPI v3, - // see http://v3-apidocs.cloudfoundry.org/version/3.203.0/index.html#asynchronous-operations - // > Unlike V2, clients cannot opt-in for asynchronous responses from endpoints. + String serviceBindingName = request.getBindingId(); CreateServiceBindingRequest createServiceBindingRequest = CreateServiceBindingRequest.builder() .relationships( ServiceBindingRelationships.builder() @@ -133,21 +132,61 @@ public Mono createServiceInstanceBinding( .build()) .type(ServiceBindingType.KEY) .parameters(request.getParameters()) - .name(request.getBindingId()) + .name(serviceBindingName) .build(); + //Ask for async binding creation. No async opt-out is supported in CAPI v3, + // see http://v3-apidocs.cloudfoundry.org/version/3.203.0/index.html#asynchronous-operations + // > Unlike V2, clients cannot opt-in for asynchronous responses from endpoints. CreateServiceBindingResponse createServiceBindingResponse = client.serviceBindingsV3() .create(createServiceBindingRequest).block(); + //Note: we block to save the resulting response jobId as it is needed in downstream pipeline assert createServiceBindingResponse != null; assert createServiceBindingResponse.getJobId().isPresent(); - String jobId = createServiceBindingResponse.getJobId().get(); + String asyncJobId = createServiceBindingResponse.getJobId().get(); - //Return 202 Accepted - return Mono.just(CreateServiceInstanceAppBindingResponse.builder() + //Preparing 202 Accepted response to return when attempts to fetch sync binding fail + CreateServiceInstanceAppBindingResponse async202AcceptedResponse = CreateServiceInstanceAppBindingResponse.builder() .async(true) - .operation(toJson(new CmdbOperationState(jobId, OsbOperation.CREATE))) - .build()); + .operation(toJson(new CmdbOperationState(asyncJobId, OsbOperation.CREATE))) + .build(); + + //Poll the async job shortly for sync bindings + try { + JobUtils.waitForCompletion(client, SYNC_COMPLETION_TIMEOUT, asyncJobId) + .block(); + //Note: we could avoid this block + } + catch (Exception e) { + LOG.info("CSK async job not complete after short polling, fallbacking to osb client-side async polling"); + // return 202 Accepted + return Mono.just(async202AcceptedResponse); + } + + //For completed sync bindings, fetch binding details + return + requestSingleListServiceBindingsIdOrError(client, existingSi.getName(), serviceBindingName) + .flatMap(requestServiceBindingDetails()) + .map(GetServiceBindingDetailsResponse::getCredentials) + .switchIfEmpty(Mono.error(new ServiceBrokerException("Missing credentials in returned " + + "backing service key"))) + .map(credentials -> + CreateServiceInstanceAppBindingResponse.builder() + .credentials(credentials) + .build()) + .cast(CreateServiceInstanceBindingResponse.class) + .doOnRequest(next -> { + LOG.info("Start sync CSK fetch details"); + }) + .doOnSuccess(next -> { + LOG.info("End sync CSK fetch details, returning {}", next); + }) + .onErrorResume(t -> { + LOG.info("sync CSK fetch details fails, fallbacking to osb client-side async polling. " + + "Error details:" + t); + return Mono.just(async202AcceptedResponse); + }); } catch (Exception originalException) { LOG.info("Unable to create async service binding, caught:" + originalException); @@ -155,14 +194,26 @@ public Mono createServiceInstanceBinding( } } + @NotNull + private Function> requestServiceBindingDetails() { + return serviceBindingId -> + client + .serviceBindingsV3() + .getDetails( + GetServiceBindingDetailsRequest.builder() + .serviceBindingId(serviceBindingId) + .build()) + .switchIfEmpty(Mono.error(new ServiceBrokerException("Unable to get service binding details"))); + } + private boolean isExceptionReportingAsyncRequired(Exception originalException) { - boolean asyncRequired=false; + boolean asyncRequired = false; if (originalException instanceof ClientV2Exception) { ClientV2Exception clientV2Exception = (ClientV2Exception) originalException; Integer clientV2ExceptionCode = clientV2Exception.getCode(); //OUT Caused by: org.cloudfoundry.client.v2.ClientV2Exception: CF-AsyncRequired(10001): This service plan requires client support for asynchronous service operations. if (clientV2ExceptionCode != null && clientV2ExceptionCode.equals(10001)) { - asyncRequired=true; + asyncRequired = true; } } return asyncRequired; @@ -192,7 +243,8 @@ public Mono getLastOperation( //CF API errors can be multiple and can change without notification // To avoid relying on exceptions thrown to make decisions, we try to diagnose and recover the exception // globally by inspecting the backing service instance state instead. - LOG.info("Unable to get async service binding last operation with operations " + request.getOperation() + originalException ); + LOG.info( + "Unable to get async service binding last operation with operations " + request.getOperation() + originalException); throw redactExceptionAndWrapAsServiceBrokerException(originalException); } } @@ -213,7 +265,8 @@ public Mono getServiceInstanceBinding(GetServ .block(); if (listServiceBindingsResponse == null || listServiceBindingsResponse.getResources().isEmpty()) { - throw new OsbCmdbServiceBrokerException("No service bindings found for bindingId=" + request.getBindingId()); + throw new OsbCmdbServiceBrokerException( + "No service bindings found for bindingId=" + request.getBindingId()); } assert listServiceBindingsResponse.getResources().size() == 1; String serviceBindingId = listServiceBindingsResponse.getResources().get(0).getId(); @@ -232,7 +285,8 @@ public Mono getServiceInstanceBinding(GetServ .build()); } catch (Exception originalException) { - LOG.info("Unable to get async service binding with id=" + request.getBindingId() + " caught:" + originalException ); + LOG.info( + "Unable to get async service binding with id=" + request.getBindingId() + " caught:" + originalException); throw redactExceptionAndWrapAsServiceBrokerException(originalException); } } @@ -270,7 +324,8 @@ public Mono deleteServiceInstanceBinding( // forged service instance guid CloudFoundryOperations spacedTargetedOperations = getSpaceScopedOperations( request.getServiceDefinition().getName()); - ServiceInstance backingServiceInstance = getCfServiceInstance(spacedTargetedOperations, request.getServiceInstanceId()); + ServiceInstance backingServiceInstance = getCfServiceInstance(spacedTargetedOperations, + request.getServiceInstanceId()); if (backingServiceInstance == null) { LOG.warn("No such service instance id={} to delete binding from, client error or attempt to delete " + @@ -297,7 +352,8 @@ public Mono deleteServiceInstanceBinding( catch (Exception e) { if (isExceptionReportingAsyncRequired(e)) { LOG.info("Unable to delete sync service binding, caught:" + e + " Trying async"); - } else { + } + else { LOG.info( "Unable to delete backing service key with name={} from backing service instance name={} Got {}", backingServiceKeyName, @@ -324,15 +380,15 @@ public Mono deleteServiceInstanceBinding( .async(true) .operation(toJson(new CmdbOperationState(jobId, OsbOperation.DELETE))) .build()); - } catch (Exception originalException) { - LOG.info("Unable to create async service binding, caught:" + originalException); - throw redactExceptionAndWrapAsServiceBrokerException(originalException); - } + } + catch (Exception originalException) { + LOG.info("Unable to create async service binding, caught:" + originalException); + throw redactExceptionAndWrapAsServiceBrokerException(originalException); + } } - protected CmdbOperationState fromJson(String operation) { try { return OBJECT_MAPPER.readValue(operation, CmdbOperationState.class); @@ -353,7 +409,7 @@ protected String toJson(CmdbOperationState cmdbOperationState) { } } - + protected enum OsbOperation { CREATE, DELETE @@ -409,5 +465,4 @@ public int hashCode() { } - } diff --git a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncOnlyBackingServiceBindingInterceptor.java b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncOnlyBackingServiceBindingInterceptor.java deleted file mode 100644 index aba05019..00000000 --- a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncOnlyBackingServiceBindingInterceptor.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.orange.oss.osbcmdb.testfixtures; - -import reactor.core.publisher.Mono; - -import org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException; -import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest; -import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse; - -/** - * Simulates a successful async binding backing service requested in backing space: - * - rejects sync binding create/delete requests, - * - create/delete async binding completes successfully - * - * Only accept OSB calls when space is a backing space, i.e. not the default space - */ -public class AsyncOnlyBackingServiceBindingInterceptor extends BackingServiceBindingInterceptor { - - public AsyncOnlyBackingServiceBindingInterceptor(String defaultSpaceName) { - super(defaultSpaceName); - } - - @Override - public Mono createServiceInstanceBinding( - CreateServiceInstanceBindingRequest request) { - if (! request.isAsyncAccepted()) { - throw new ServiceBrokerAsyncRequiredException("AsyncOnlyBackingServiceBindingInterceptor is " + - "expecting accept_incomplete=true (rejects osb-cmdb sync binding create requests"); - - } - return super.createServiceInstanceBinding(request); - } - -} diff --git a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncSuccessfulCreateBackingServiceBindingInterceptor.java b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncSuccessfulCreateBackingServiceBindingInterceptor.java index 9d4df629..0c8f7ae4 100644 --- a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncSuccessfulCreateBackingServiceBindingInterceptor.java +++ b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/AsyncSuccessfulCreateBackingServiceBindingInterceptor.java @@ -1,5 +1,7 @@ package com.orange.oss.osbcmdb.testfixtures; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import reactor.core.publisher.Mono; import org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException; @@ -10,6 +12,9 @@ import org.springframework.cloud.servicebroker.model.binding.DeleteServiceInstanceBindingResponse; import org.springframework.cloud.servicebroker.model.binding.GetLastServiceBindingOperationRequest; import org.springframework.cloud.servicebroker.model.binding.GetLastServiceBindingOperationResponse; +import org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceAppBindingResponse; +import org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingRequest; +import org.springframework.cloud.servicebroker.model.binding.GetServiceInstanceBindingResponse; import org.springframework.cloud.servicebroker.model.instance.OperationState; /** @@ -25,6 +30,9 @@ public class AsyncSuccessfulCreateBackingServiceBindingInterceptor extends Back public static final String DELETE = "delete"; + private static final Logger LOG = LoggerFactory.getLogger(AsyncSuccessfulCreateBackingServiceBindingInterceptor.class); + + public AsyncSuccessfulCreateBackingServiceBindingInterceptor(String defaultSpaceName) { super(defaultSpaceName); } @@ -37,10 +45,12 @@ public Mono createServiceInstanceBinding( "expecting accept_incomplete=true "); } provisionnedInstanceGuids.add(request.getServiceInstanceId()); - return Mono.just(CreateServiceInstanceAppBindingResponse.builder() + CreateServiceInstanceAppBindingResponse response = CreateServiceInstanceAppBindingResponse.builder() .async(true) .operation(CREATE) - .build()); + .build(); + LOG.info("Returning async response: CreateServiceInstanceAppBindingResponse={}", response); + return Mono.just(response); } @Override @@ -59,6 +69,11 @@ public Mono deleteServiceInstanceBinding( @Override public Mono getLastOperation( GetLastServiceBindingOperationRequest request) { + + if (DELETE.equals(request.getOperation())) { + //Clean up guid (although a leak has no impact for the interceptor just used once) + provisionnedInstanceGuids.remove(request.getServiceInstanceId()); + } return Mono.just(GetLastServiceBindingOperationResponse.builder() .description(this.getClass().getSimpleName()) .operationState(OperationState.SUCCEEDED) @@ -66,5 +81,10 @@ public Mono getLastOperation( .build()); } - + @Override + public Mono getServiceInstanceBinding(GetServiceInstanceBindingRequest request) { + return Mono.just(GetServiceInstanceAppBindingResponse.builder() + .credentials(CREDENTIALS) + .build()); + } } diff --git a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BackingServiceBindingInterceptor.java b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BackingServiceBindingInterceptor.java index f6a2fd89..de871078 100644 --- a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BackingServiceBindingInterceptor.java +++ b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BackingServiceBindingInterceptor.java @@ -8,6 +8,8 @@ import reactor.util.Logger; import reactor.util.Loggers; +import org.springframework.cloud.servicebroker.exception.ServiceBrokerAsyncRequiredException; +import org.springframework.cloud.servicebroker.exception.ServiceBrokerException; import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceAppBindingResponse; import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingRequest; import org.springframework.cloud.servicebroker.model.binding.CreateServiceInstanceBindingResponse; @@ -24,7 +26,7 @@ * Supports intercepting OSB service provisionning calls, mainly for acceptance test purposes. Reuses prototypes from * {@link org.springframework.cloud.servicebroker.service.ServiceInstanceBindingService} *

- * By default, behaves like noop + * By default, behaves like SYNC-ONLY noop */ public class BackingServiceBindingInterceptor extends BaseBackingSpaceInstanceInterceptor implements ServiceBindingInterceptor { @@ -40,22 +42,25 @@ public BackingServiceBindingInterceptor(String defaultSpaceName) { @Override public boolean accept(CreateServiceInstanceBindingRequest request) { - return isScabAcceptanceTest(request.getContext(), request.toString()); + return isScabAcceptanceTest(request.getContext(), request.toString(), request.getClass()); } @Override public boolean accept(GetLastServiceBindingOperationRequest request) { - return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString()); + return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString(), + request.getClass()); } @Override public boolean accept(GetServiceInstanceBindingRequest request) { - return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString()); + return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString(), + request.getClass()); } @Override public boolean accept(DeleteServiceInstanceBindingRequest request) { - return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString()); + return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString(), + request.getClass()); } @@ -63,30 +68,35 @@ public boolean accept(DeleteServiceInstanceBindingRequest request) { public Mono createServiceInstanceBinding( CreateServiceInstanceBindingRequest request) { provisionnedInstanceGuids.add(request.getServiceInstanceId()); - return Mono.just(CreateServiceInstanceAppBindingResponse.builder() + CreateServiceInstanceAppBindingResponse response = CreateServiceInstanceAppBindingResponse.builder() + .async(false) .credentials(CREDENTIALS) - .build()); + .build(); + LOG.info("Retuning {}", response); + return Mono.just(response); } @Override public Mono getLastOperation( GetLastServiceBindingOperationRequest request) { - return Mono.just(GetLastServiceBindingOperationResponse.builder() - .operationState(OperationState.SUCCEEDED) - .build()); + return Mono.error(new ServiceBrokerException("interceptor returnes sync responses, unexpected " + + "getLastOperation request")); } @Override public Mono getServiceInstanceBinding(GetServiceInstanceBindingRequest request) { - return Mono.just(GetServiceInstanceAppBindingResponse.builder() - .credentials(CREDENTIALS) - .build()); + return Mono.error(new ServiceBrokerException("interceptor returned sync binding, unexpected " + + "getServiceInstanceBinding request")); } @Override public Mono deleteServiceInstanceBinding( DeleteServiceInstanceBindingRequest request) { - return Mono.just(DeleteServiceInstanceBindingResponse.builder().build()); + DeleteServiceInstanceBindingResponse response = DeleteServiceInstanceBindingResponse.builder() + .async(false) + .build(); + LOG.info("Retuning {}", response); + return Mono.just(response); } } diff --git a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseBackingSpaceInstanceInterceptor.java b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseBackingSpaceInstanceInterceptor.java index 515f506c..69e6baae 100644 --- a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseBackingSpaceInstanceInterceptor.java +++ b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseBackingSpaceInstanceInterceptor.java @@ -38,7 +38,7 @@ public BaseBackingSpaceInstanceInterceptor( this.defaultSpaceName = defaultSpaceName; } - protected boolean isScabAcceptanceTest(Context context, String requestToString) { + protected boolean isScabAcceptanceTest(Context context, String requestToString, Class requestClass) { CloudFoundryContext cloudFoundryContext = (CloudFoundryContext) context; if (context == null) { LOG.info("No context specified in request, assuming not an acceptance test sending OSB request with a " + @@ -53,14 +53,21 @@ protected boolean isScabAcceptanceTest(Context context, String requestToString) } boolean isTest = ! spaceName.equals(defaultSpaceName); - LOG.debug("Accept: isTest={} for spaceName={} and request={}", isTest, spaceName, requestToString); + LOG.debug("Accept: isTest={} for interceptor={} spaceName={} requestClass={} request={}", + isTest, + this.getClass().getSimpleName(), + spaceName, + requestClass.getSimpleName(), + requestToString); return isTest; } - protected boolean isServiceGuidPreviousProvisionnedByUs(String serviceInstanceId, String requestToString) { + protected boolean isServiceGuidPreviousProvisionnedByUs(String serviceInstanceId, String requestToString, + Class requestClass) { boolean isGuidPreviouslyProvisionnedByUs = provisionnedInstanceGuids.contains(serviceInstanceId); - LOG.debug("Accept: isServiceGuidPreviousProvisionnedByUs={} for serviceInstanceId={} and request={}", - isGuidPreviouslyProvisionnedByUs, serviceInstanceId, requestToString); + LOG.debug("Accept: isServiceGuidPreviousProvisionnedByUs={} for serviceInstanceId={} and " + + "requestClass={} request={}", + isGuidPreviouslyProvisionnedByUs, serviceInstanceId, requestClass.getSimpleName(), requestToString); return isGuidPreviouslyProvisionnedByUs; } diff --git a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseServiceInstanceBackingSpaceInstanceInterceptor.java b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseServiceInstanceBackingSpaceInstanceInterceptor.java index 48d4dbe7..8d15a812 100644 --- a/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseServiceInstanceBackingSpaceInstanceInterceptor.java +++ b/osb-cmdb/src/main/java/com/orange/oss/osbcmdb/testfixtures/BaseServiceInstanceBackingSpaceInstanceInterceptor.java @@ -34,27 +34,30 @@ public BaseServiceInstanceBackingSpaceInstanceInterceptor( @Override public boolean accept(CreateServiceInstanceRequest request) { - return isScabAcceptanceTest(request.getContext(), request.toString()); + return isScabAcceptanceTest(request.getContext(), request.toString(), request.getClass()); } @Override public boolean accept(GetLastServiceOperationRequest request) { - return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString()); + return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString(), + request.getClass()); } @Override public boolean accept(GetServiceInstanceRequest request) { - return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString()); + return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString(), + request.getClass()); } @Override public boolean accept(DeleteServiceInstanceRequest request) { - return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString()); + return isServiceGuidPreviousProvisionnedByUs(request.getServiceInstanceId(), request.toString(), + request.getClass()); } @Override public boolean accept(UpdateServiceInstanceRequest request) { - return isScabAcceptanceTest(request.getContext(), request.toString()); + return isScabAcceptanceTest(request.getContext(), request.toString(), request.getClass()); } @Override diff --git a/spring-cloud-app-broker-acceptance-tests/build.gradle b/spring-cloud-app-broker-acceptance-tests/build.gradle index df4381a9..07e28330 100644 --- a/spring-cloud-app-broker-acceptance-tests/build.gradle +++ b/spring-cloud-app-broker-acceptance-tests/build.gradle @@ -97,6 +97,7 @@ test { filter { // includeTestsMatching("*CreateDeleteInstanceWithBackingServiceKeysAcceptanceTest") includeTestsMatching("*CreateDeleteAsyncInstanceWithAsyncBackingServiceKeysAcceptanceTest") + includeTestsMatching("*CreateDeleteAsyncInstanceWithSyncBackingServiceKeysAcceptanceTest") } testLogging { outputs.upToDateWhen {false} diff --git a/spring-cloud-app-broker-acceptance-tests/src/test/java/org/springframework/cloud/appbroker/acceptance/CloudFoundryAcceptanceTest.java b/spring-cloud-app-broker-acceptance-tests/src/test/java/org/springframework/cloud/appbroker/acceptance/CloudFoundryAcceptanceTest.java index b53917ed..d147407a 100644 --- a/spring-cloud-app-broker-acceptance-tests/src/test/java/org/springframework/cloud/appbroker/acceptance/CloudFoundryAcceptanceTest.java +++ b/spring-cloud-app-broker-acceptance-tests/src/test/java/org/springframework/cloud/appbroker/acceptance/CloudFoundryAcceptanceTest.java @@ -282,9 +282,9 @@ public Set