use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationServiceTest method testGetOperationProgressByResourceCrnWithFailedRemoteDbResponse.
@Test
public void testGetOperationProgressByResourceCrnWithFailedRemoteDbResponse() {
// GIVEN
given(flowService.getLastFlowOperationByResourceCrn(anyString())).willReturn(Optional.of(operationFlowsView));
given(operationFlowsView.getOperationType()).willReturn(OperationType.PROVISION);
given(operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.DATAHUB, EXPECTED_TYPE_LIST)).willReturn(new OperationView());
given(stackOperations.getStackByCrn(anyString())).willReturn(stack);
given(stack.getExternalDatabaseCreationType()).willReturn(DatabaseAvailabilityType.NON_HA);
given(databaseService.getRemoteDatabaseOperationProgress(any(), anyBoolean())).willThrow(new RuntimeException("my ex"));
// WHEN
OperationView result = underTest.getOperationProgressByResourceCrn(TEST_CLUSTER_CRN, true);
// THEN
assertNull(result.getSubOperations().get(OperationResource.REMOTEDB));
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationViewWithFailedState.
@Test
public void testCreateOperationViewWithFailedState() {
// GIVEN
Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("FAILED", true).get());
OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(MAX_PROGRESS, operationView.getProgress());
assertEquals(OperationProgressStatus.FAILED, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationViewWithPendingState.
@Test
public void testCreateOperationViewWithPendingState() {
// GIVEN
Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("SUCCESSFUL", false).get());
OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(IN_PROGRESS_FROM_HISTORY, operationView.getProgress());
assertEquals(OperationProgressStatus.RUNNING, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class FlowOperationService method getOperationProgressByEnvironmentCrn.
public OperationView getOperationProgressByEnvironmentCrn(String environmentCrn, boolean detailed) {
OperationView operationView = new OperationView();
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(environmentCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationResource operationResource = OperationResource.FREEIPA;
com.sequenceiq.flow.api.model.operation.OperationType operationType = operationFlowsView.getOperationType();
if (com.sequenceiq.flow.api.model.operation.OperationType.PROVISION.equals(operationType)) {
operationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource, List.of(StackProvisionFlowConfig.class, FreeIpaProvisionFlowConfig.class));
} else {
operationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource);
}
}
return operationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationService method getOperationProgressByResourceCrn.
public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
OperationView response = new OperationView();
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationType operationType = operationFlowsView.getOperationType();
response = operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
if (OperationType.PROVISION.equals(operationType)) {
if (detailed) {
handleProvisionOperation(resourceCrn, response, detailed);
} else {
LOGGER.debug("Skipping detailed environment provision operation response");
}
}
}
return response;
}
Aggregations