Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now returns GONE when last operation is missing #468

Merged
merged 1 commit into from
Jan 3, 2022
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 @@ -81,6 +81,15 @@ public boolean shouldSkipClass(Class<?> clazz) {

GetLastServiceOperationResponse getDeploymentExecStatus(Path secretsWorkDir, String serviceInstanceId, String jsonPipelineOperationState, GetLastServiceOperationRequest pollingRequest) {
PipelineOperationState pipelineOperationState = this.parseFromJson(jsonPipelineOperationState);
if (pipelineOperationState == null) {
logger.info("receiving /v2/service_instances/:instance_id/last_operation endpoint call without operation " +
"field, assuming coab issue #467 and returning GONE");
return GetLastServiceOperationResponse.builder()
.operationState(OperationState.SUCCEEDED)
.description("Unexpected null operation field, assuming issue #467")
.deleteOperation(true)
.build();
}

//Check if target manifest file is present, i.e. if nested broker bosh deployment completed successfully
boolean isTargetManifestFilePresent = secretsReader.isBoshDeploymentAvailable(secretsWorkDir, serviceInstanceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ public void returns_failed_state_if_provision_operation_state_is_timed_out() {
verify(osbProxy, never()).delegateProvision(any(), any(), any());
}

@Test
public void returns_gone_state_if_last_operation_state_is_null() {
//Given a missing operation state in the getLastOperation
String jsonPipelineOperationState = createNullOperationState();

//When
GetLastServiceOperationResponse response = tracker.getDeploymentExecStatus(workDir, SERVICE_INSTANCE_ID, jsonPipelineOperationState, pollingRequest);

//Then
assertThat(response.getState()).isEqualTo(OperationState.SUCCEEDED);
assertThat(response.isDeleteOperation()).isTrue();
assertThat(response.getDescription()).startsWith("Unexpected null operation field");
verify(osbProxy, never()).delegateProvision(any(), any(), any());
}

@Test
public void returns_succeeded_state_during_provision_if_manifest_is_present_regardless_of_elapsed_time()
throws IOException {
Expand Down Expand Up @@ -472,6 +487,10 @@ private String createOperationStateInThePast(ServiceBrokerRequest request) {
return tracker.formatAsJson(pipelineOperationState);
}

private String createNullOperationState() {
return tracker.formatAsJson(null);
}

@Test
public void operation_state_POJO_serializes_back_and_forth_to_json() {
//given
Expand Down