Search in sources :

Example 66 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class EvenFlowDistributorTest method getFlowLogs.

private List<FlowLog> getFlowLogs(int flowCount) {
    List<FlowLog> flows = new ArrayList<>();
    Random random = new SecureRandom();
    int flowId = random.nextInt(5000);
    long stackId = random.nextLong();
    for (int i = 0; i < flowCount; i++) {
        flows.add(new FlowLog(stackId + i, "" + flowId + i, "RUNNING", false, StateStatus.PENDING, OperationType.UNKNOWN));
    }
    return flows;
}
Also used : Random(java.util.Random) SecureRandom(java.security.SecureRandom) FlowLog(com.sequenceiq.flow.domain.FlowLog) ArrayList(java.util.ArrayList) SecureRandom(java.security.SecureRandom)

Example 67 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class FlowComponentTest method shouldTolerateWhenFlowLogTypeOrPayloadTypeClassIsNotOnClassPath.

@Test
public void shouldTolerateWhenFlowLogTypeOrPayloadTypeClassIsNotOnClassPath() {
    long resourceId = RESOURCE_ID_SEC.incrementAndGet();
    FlowLog flowLog = new FlowLog(resourceId, "test-flow-id", null, "userCrn", "NEXT_EVENT", "payload", ClassValue.ofUnknown("nope.NopePayload"), "variables", ClassValue.ofUnknown("nope.NopeFlowType"), "CURRENT_STATE");
    flowLog.setFinalized(true);
    flowLogRepository.save(flowLog);
    List<FlowLog> flowLogs = flowLogRepository.findAllByResourceIdOrderByCreatedDesc(resourceId);
    assertEquals(1, flowLogs.size());
    ClassValue flowType = flowLogs.get(0).getFlowType();
    ClassValue payloadType = flowLogs.get(0).getPayloadType();
    assertFalse(flowType.isOnClassPath());
    assertFalse(payloadType.isOnClassPath());
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) ClassValue(com.sequenceiq.flow.domain.ClassValue) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 68 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class FlowOperationStatisticsServiceTest method flowLogs.

private List<FlowLog> flowLogs() {
    List<FlowLog> result = new ArrayList<>();
    FlowLog fl1 = new FlowLog();
    fl1.setOperationType(OperationType.PROVISION);
    fl1.setFlowId("flowid");
    fl1.setResourceId(1L);
    fl1.setFlowType(ClassValue.of(flowConfiguration.getClass()));
    result.add(fl1);
    return result;
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) ArrayList(java.util.ArrayList)

Example 69 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class FlowCancelServiceTest method testCancelFlowSilentlyIgnoresException.

@Test
public void testCancelFlowSilentlyIgnoresException() throws TransactionExecutionException {
    doThrow(new TransactionExecutionException("asdf", new RuntimeException())).when(flow2Handler).cancelFlow(anyLong(), anyString());
    FlowLog flowLog = new FlowLog();
    flowLog.setFlowId("asdf");
    flowLog.setResourceId(1L);
    underTest.cancelFlowSilently(flowLog);
}
Also used : TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) FlowLog(com.sequenceiq.flow.domain.FlowLog) Test(org.junit.Test)

Example 70 with FlowLog

use of com.sequenceiq.flow.domain.FlowLog in project cloudbreak by hortonworks.

the class FlowRetryServiceTest method createFlowLog.

private FlowLog createFlowLog(String currentState, StateStatus stateStatus, long created, String name) {
    FlowLog flowLog = new FlowLog(STACK_ID, FLOW_ID, currentState, true, stateStatus, OperationType.UNKNOWN);
    flowLog.setCreated(created);
    flowLog.setFlowType(ClassValue.of(flowConfig.getClass()));
    flowLog.setNextEvent(name);
    return flowLog;
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog)

Aggregations

FlowLog (com.sequenceiq.flow.domain.FlowLog)92 Test (org.junit.jupiter.api.Test)25 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)21 List (java.util.List)13 FlowConfiguration (com.sequenceiq.flow.core.config.FlowConfiguration)12 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)11 Mockito.times (org.mockito.Mockito.times)11 Mockito.verify (org.mockito.Mockito.verify)11 Mockito.when (org.mockito.Mockito.when)11 HelloWorldFlowConfig (com.sequenceiq.flow.core.helloworld.config.HelloWorldFlowConfig)10 Map (java.util.Map)10 UUID (java.util.UUID)10 Collectors (java.util.stream.Collectors)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 Clock (com.sequenceiq.cloudbreak.common.service.Clock)9 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)9 FlowRegister (com.sequenceiq.flow.core.FlowRegister)9 SecureRandom (java.security.SecureRandom)9 Random (java.util.Random)9