Search in sources :

Example 1 with FlowProgressResponse

use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.

the class FlowOperationStatisticsServiceTest method createFlowProgressResponse.

private FlowProgressResponse createFlowProgressResponse() {
    FlowProgressResponse response = new FlowProgressResponse();
    response.setProgress(DUMMY_PROGRESS);
    response.setFinalized(false);
    response.setFlowId("flowid");
    response.setCreated(new Date().getTime());
    return response;
}
Also used : FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) Date(java.util.Date)

Example 2 with FlowProgressResponse

use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.

the class FlowService method getLastFlowProgressByResourceCrnAndType.

public <T extends AbstractFlowConfiguration> Optional<FlowProgressResponse> getLastFlowProgressByResourceCrnAndType(String resourceCrn, ClassValue classValue) {
    checkState(Crn.isCrn(resourceCrn));
    LOGGER.info("Getting flow logs (progress) by resource crn {} and type {}", resourceCrn, classValue.getClassValue().getCanonicalName());
    List<FlowLog> flowLogs = flowLogDBService.getFlowLogsByCrnAndType(resourceCrn, classValue);
    FlowProgressResponse response = flowProgressResponseConverter.convert(flowLogs, resourceCrn);
    if (StringUtils.isBlank(response.getFlowId())) {
        LOGGER.debug("Not found any historical flow data for requested resource (crn: {})", resourceCrn);
        return Optional.empty();
    }
    return Optional.ofNullable(flowProgressResponseConverter.convert(flowLogs, resourceCrn));
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse)

Example 3 with FlowProgressResponse

use of com.sequenceiq.flow.api.model.FlowProgressResponse in project cloudbreak by hortonworks.

the class FlowProgressResponseConverterTest method testConvert.

@Test
public void testConvert() {
    // GIVEN
    given(flowProgressHolder.getProgressPercentageForState(TestFlowConfig.class.getCanonicalName(), "FINISHED")).willReturn(100);
    // WHEN
    FlowProgressResponse response = underTest.convert(createFlowLogs(false), DUMMY_CRN);
    // THEN
    assertEquals("flow1", response.getFlowId());
    assertEquals(2, response.getTransitions().size());
    assertEquals(0.001, response.getElapsedTimeInSeconds());
    assertEquals(100, response.getProgress());
}
Also used : TestFlowConfig(com.sequenceiq.flow.core.config.TestFlowConfig) FlowProgressResponse(com.sequenceiq.flow.api.model.FlowProgressResponse) Test(org.junit.jupiter.api.Test)

Example 4 with FlowProgressResponse

use of com.sequenceiq.flow.api.model.FlowProgressResponse 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 5 with FlowProgressResponse

use of com.sequenceiq.flow.api.model.FlowProgressResponse 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)

Aggregations

FlowProgressResponse (com.sequenceiq.flow.api.model.FlowProgressResponse)16 Test (org.junit.jupiter.api.Test)7 OperationFlowsView (com.sequenceiq.flow.api.model.operation.OperationFlowsView)5 OperationView (com.sequenceiq.flow.api.model.operation.OperationView)5 ArrayList (java.util.ArrayList)5 FlowStateTransitionResponse (com.sequenceiq.flow.api.model.FlowStateTransitionResponse)4 FlowLog (com.sequenceiq.flow.domain.FlowLog)4 HashMap (java.util.HashMap)4 Optional (java.util.Optional)4 Date (java.util.Date)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 CollectionUtils (org.apache.commons.collections4.CollectionUtils)3 Component (org.springframework.stereotype.Component)3 OperationProgressStatus (com.sequenceiq.flow.api.model.operation.OperationProgressStatus)2 TestFlowConfig (com.sequenceiq.flow.core.config.TestFlowConfig)2 DecimalFormat (java.text.DecimalFormat)2 Map (java.util.Map)2 Splitter (com.google.common.base.Splitter)1 EvictingQueue (com.google.common.collect.EvictingQueue)1