Search in sources :

Example 6 with FlowLogResponse

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

the class CloudbreakFlowServiceTest method testSaveFlowChainIdWhenNoFlowIdentifierIsPresent.

@Test
public void testSaveFlowChainIdWhenNoFlowIdentifierIsPresent() {
    SdxCluster cluster = new SdxCluster();
    cluster.setLastCbFlowChainId(FLOW_CHAIN_ID);
    cluster.setInitiatorUserCrn(USER_CRN);
    cluster.setClusterName(CLUSTER_NAME);
    FlowLogResponse response = new FlowLogResponse();
    response.setStateStatus(StateStatus.SUCCESSFUL);
    response.setFinalized(true);
    response.setFlowChainId(FLOW_CHAIN_ID);
    when(flowEndpoint.getLastFlowByResourceName(any(), anyString())).thenReturn(response);
    when(sdxClusterRepository.save(any())).thenReturn(cluster);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.saveLastCloudbreakFlowChainId(cluster, null);
    verify(flowEndpoint).getLastFlowByResourceName(any(), anyString());
    verify(sdxClusterRepository).save(clusterCaptor.capture());
    assertEquals(FLOW_CHAIN_ID, clusterCaptor.getValue().getLastCbFlowChainId());
    assertNull(clusterCaptor.getValue().getLastCbFlowId());
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse) Test(org.junit.jupiter.api.Test)

Example 7 with FlowLogResponse

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

the class CloudbreakFlowServiceTest method testSaveFlowChainIdWhenNoFlowIdentifierIsPresentAndBothFlowIdAndFlowChainIdIsPresentInFlowLog.

@Test
public void testSaveFlowChainIdWhenNoFlowIdentifierIsPresentAndBothFlowIdAndFlowChainIdIsPresentInFlowLog() {
    SdxCluster cluster = new SdxCluster();
    cluster.setLastCbFlowChainId(FLOW_CHAIN_ID);
    cluster.setInitiatorUserCrn(USER_CRN);
    cluster.setClusterName(CLUSTER_NAME);
    FlowLogResponse response = new FlowLogResponse();
    response.setStateStatus(StateStatus.SUCCESSFUL);
    response.setFinalized(true);
    response.setFlowId(FLOW_ID);
    response.setFlowChainId(FLOW_CHAIN_ID);
    when(flowEndpoint.getLastFlowByResourceName(any(), anyString())).thenReturn(response);
    when(sdxClusterRepository.save(any())).thenReturn(cluster);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:freeipa:us-west-1:altus:user:__internal__actor__");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.saveLastCloudbreakFlowChainId(cluster, null);
    verify(flowEndpoint).getLastFlowByResourceName(any(), anyString());
    verify(sdxClusterRepository).save(clusterCaptor.capture());
    assertEquals(FLOW_CHAIN_ID, clusterCaptor.getValue().getLastCbFlowChainId());
    assertNull(clusterCaptor.getValue().getLastCbFlowId());
}
Also used : SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse) Test(org.junit.jupiter.api.Test)

Example 8 with FlowLogResponse

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

the class SdxUpgradeValidationResultProvider method isValidationFailed.

public boolean isValidationFailed(SdxCluster sdxCluster) {
    FlowLogResponse lastCloudbreakFlowChainId = cloudbreakFlowService.getLastCloudbreakFlowChainId(sdxCluster);
    List<FlowLogResponse> flowLogsByFlowId = cloudbreakFlowService.getFlowLogsByFlowId(lastCloudbreakFlowChainId.getFlowId());
    return flowLogsByFlowId.stream().anyMatch(containsValidationInitState()) && flowLogsByFlowId.stream().anyMatch(containsFailedState());
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse)

Example 9 with FlowLogResponse

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

the class CloudbreakFlowService method getLastCloudbreakFlowChainId.

public FlowLogResponse getLastCloudbreakFlowChainId(SdxCluster sdxCluster) {
    FlowLogResponse lastFlowByResourceName = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> flowEndpoint.getLastFlowByResourceCrn(sdxCluster.getStackCrn()));
    logFlowLogResponse(lastFlowByResourceName);
    return lastFlowByResourceName;
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse)

Example 10 with FlowLogResponse

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

the class SdxUpgradeValidationResultProviderTest method createFlowLog.

private FlowLogResponse createFlowLog(String currentState, StateStatus stateStatus) {
    FlowLogResponse flowLogResponse = new FlowLogResponse();
    flowLogResponse.setStateStatus(stateStatus);
    flowLogResponse.setCurrentState(currentState);
    return flowLogResponse;
}
Also used : FlowLogResponse(com.sequenceiq.flow.api.model.FlowLogResponse)

Aggregations

FlowLogResponse (com.sequenceiq.flow.api.model.FlowLogResponse)15 Test (org.junit.jupiter.api.Test)6 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 NotFoundException (javax.ws.rs.NotFoundException)1 Before (org.junit.Before)1