Search in sources :

Example 6 with OperationView

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));
}
Also used : OperationView(com.sequenceiq.flow.api.model.operation.OperationView) Test(org.junit.jupiter.api.Test)

Example 7 with OperationView

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());
}
Also used : FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) HashMap(java.util.HashMap) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) Test(org.junit.jupiter.api.Test)

Example 8 with OperationView

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());
}
Also used : FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) HashMap(java.util.HashMap) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) Test(org.junit.jupiter.api.Test)

Example 9 with OperationView

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;
}
Also used : OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) OperationResource(com.sequenceiq.flow.api.model.operation.OperationResource)

Example 10 with 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;
}
Also used : OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationFlowsView(com.sequenceiq.flow.api.model.operation.OperationFlowsView) OperationType(com.sequenceiq.flow.api.model.operation.OperationType)

Aggregations

OperationView (com.sequenceiq.flow.api.model.operation.OperationView)20 OperationFlowsView (com.sequenceiq.flow.api.model.operation.OperationFlowsView)10 Test (org.junit.jupiter.api.Test)8 FlowProgressResponse (com.sequenceiq.flow.api.model.FlowProgressResponse)5 OperationResource (com.sequenceiq.flow.api.model.operation.OperationResource)5 HashMap (java.util.HashMap)5 OperationType (com.sequenceiq.flow.api.model.operation.OperationType)3 OperationCondition (com.sequenceiq.flow.api.model.operation.OperationCondition)2 OperationProgressStatus (com.sequenceiq.flow.api.model.operation.OperationProgressStatus)2 FlowTriggerEventQueue (com.sequenceiq.flow.core.chain.config.FlowTriggerEventQueue)2 ArrayList (java.util.ArrayList)2 Optional (java.util.Optional)2 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)1 ProvisionFlowEventChainFactory (com.sequenceiq.cloudbreak.core.flow2.chain.ProvisionFlowEventChainFactory)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 StackEvent (com.sequenceiq.cloudbreak.reactor.api.event.StackEvent)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 FlowStateTransitionResponse (com.sequenceiq.flow.api.model.FlowStateTransitionResponse)1