Search in sources :

Example 36 with FlowLog

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

the class FlowLogDBServiceTest method runUpdateLastFlowLogStatusTest.

private void runUpdateLastFlowLogStatusTest(boolean failureEvent, StateStatus successful) {
    FlowLog flowLog = new FlowLog();
    flowLog.setId(ID);
    underTest.updateLastFlowLogStatus(flowLog, failureEvent);
    verify(flowLogRepository, times(1)).updateLastLogStatusInFlow(ID, successful);
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog)

Example 37 with FlowLog

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

the class FlowProgressResponseConverterTest method setDefaults.

private void setDefaults(String flowId, FlowLog... flowLogs) {
    for (FlowLog fl : flowLogs) {
        fl.setFlowId(flowId);
        fl.setFinalized(true);
        fl.setFlowType(ClassValue.of(TestFlowConfig.class));
        fl.setStateStatus(StateStatus.SUCCESSFUL);
    }
}
Also used : TestFlowConfig(com.sequenceiq.flow.core.config.TestFlowConfig) FlowLog(com.sequenceiq.flow.domain.FlowLog)

Example 38 with FlowLog

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

the class FlowProgressResponseConverterTest method createFlowLogs.

private List<FlowLog> createFlowLogs(boolean multipleFlowIds) {
    List<FlowLog> flowLogs = new ArrayList<>();
    FlowLog flowLog1 = new FlowLog();
    flowLog1.setCreated(2L);
    flowLog1.setCurrentState("FINISHED");
    FlowLog flowLog2 = new FlowLog();
    flowLog2.setCreated(1L);
    flowLog2.setCurrentState("INIT_STATE");
    setDefaults("flow1", flowLog1, flowLog2);
    flowLogs.add(flowLog1);
    flowLogs.add(flowLog2);
    if (multipleFlowIds) {
        FlowLog flowLog3 = new FlowLog();
        flowLog3.setCreated(5L);
        flowLog3.setCurrentState("CANCELLED");
        FlowLog flowLog4 = new FlowLog();
        flowLog4.setCreated(3L);
        flowLog4.setCurrentState("INIT_STATE");
        flowLogs.add(flowLog3);
        flowLogs.add(flowLog4);
        setDefaults("flow2", flowLog3, flowLog4);
    }
    return flowLogs;
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) ArrayList(java.util.ArrayList)

Example 39 with FlowLog

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

the class UpgradeCcmFlowIntegrationTest method testCcmUpgradeWhenRegisterClusterProxyFail.

@Test
public void testCcmUpgradeWhenRegisterClusterProxyFail() throws CloudbreakOrchestratorException {
    doThrow(new BadRequestException()).when(upgradeCcmService).registerClusterProxy(STACK_ID);
    FlowIdentifier flowIdentifier = triggerFlow();
    letItFlow(flowIdentifier);
    ArgumentCaptor<FlowLog> flowLog = ArgumentCaptor.forClass(FlowLog.class);
    verify(flowLogRepository, times(2)).save(flowLog.capture());
    Assertions.assertTrue(flowLog.getAllValues().stream().anyMatch(FlowLog::getFinalized), "flow has not finalized");
    InOrder inOrder = Mockito.inOrder(upgradeCcmService);
    inOrder.verify(upgradeCcmService, times(1)).updateTunnel(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).pushSaltState(STACK_ID, CLUSTER_ID);
    inOrder.verify(upgradeCcmService, times(1)).reconfigureNginx(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).registerClusterProxy(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).ccmUpgradeFailed(STACK_ID, CLUSTER_ID, Tunnel.CCM);
    verify(upgradeCcmService, never()).healthCheckState(STACK_ID);
    verify(upgradeCcmService, never()).deregisterAgent(STACK_ID, Tunnel.CCM);
    verify(upgradeCcmService, never()).removeAgent(STACK_ID, Tunnel.CCM);
}
Also used : InOrder(org.mockito.InOrder) FlowLog(com.sequenceiq.flow.domain.FlowLog) BadRequestException(javax.ws.rs.BadRequestException) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test)

Example 40 with FlowLog

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

the class UpgradeCcmFlowIntegrationTest method testCcmUpgradeWhenSuccessful.

@Test
public void testCcmUpgradeWhenSuccessful() throws CloudbreakOrchestratorException {
    FlowIdentifier flowIdentifier = triggerFlow();
    letItFlow(flowIdentifier);
    ArgumentCaptor<FlowLog> flowLog = ArgumentCaptor.forClass(FlowLog.class);
    verify(flowLogRepository, times(2)).save(flowLog.capture());
    Assertions.assertTrue(flowLog.getAllValues().stream().anyMatch(FlowLog::getFinalized), "flow has not finalized");
    InOrder inOrder = Mockito.inOrder(upgradeCcmService);
    inOrder.verify(upgradeCcmService, times(1)).updateTunnel(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).pushSaltState(STACK_ID, CLUSTER_ID);
    inOrder.verify(upgradeCcmService, times(1)).reconfigureNginx(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).registerClusterProxy(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).healthCheck(STACK_ID);
    inOrder.verify(upgradeCcmService, times(1)).removeAgent(STACK_ID, Tunnel.CCM);
    inOrder.verify(upgradeCcmService, times(1)).deregisterAgent(STACK_ID, Tunnel.CCM);
    verify(upgradeCcmService, never()).ccmUpgradeFailed(STACK_ID, CLUSTER_ID, Tunnel.CCM);
}
Also used : InOrder(org.mockito.InOrder) FlowLog(com.sequenceiq.flow.domain.FlowLog) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test)

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