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());
}
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());
}
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());
}
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;
}
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;
}
Aggregations