use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class SdxUpgradeRecoveryServiceTest method testValidateWithDataAndSuccessfulBackupShouldStartRecoveryFlow.
@Test
public void testValidateWithDataAndSuccessfulBackupShouldStartRecoveryFlow() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
String reason = "There is no successful backup taken yet for data lake cluster with runtime 7.2.2.";
RecoveryValidationV4Response recoveryV4Response = new RecoveryValidationV4Response(reason, RecoveryStatus.RECOVERABLE);
request.setType(SdxRecoveryType.RECOVER_WITH_DATA);
datalakeDRProto.DatalakeBackupInfo datalakeBackupInfo = datalakeDRProto.DatalakeBackupInfo.newBuilder().setRuntimeVersion(RUNTIME).setOverallState("SUCCESSFUL").build();
when(cluster.getRuntime()).thenReturn(RUNTIME);
when(stackV4Endpoint.getClusterRecoverableByNameInternal(WORKSPACE_ID, CLUSTER_NAME, USER_CRN)).thenReturn(recoveryV4Response);
when(datalakeDrClient.getLastSuccessfulBackup(CLUSTER_NAME, USER_CRN, Optional.of(RUNTIME))).thenReturn(datalakeBackupInfo);
when(sdxReactorFlowManager.triggerDatalakeRuntimeRecoveryFlow(cluster, SdxRecoveryType.RECOVER_WITH_DATA)).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
SdxRecoverableResponse sdxRecoverableResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateRecovery(cluster, request));
assertEquals(reason, sdxRecoverableResponse.getReason());
SdxRecoveryResponse response = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.triggerRecovery(cluster, request));
assertEquals(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"), response.getFlowIdentifier());
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class CertRotationServiceTest method testFlowTrigger.
@Test
public void testFlowTrigger() {
SdxCluster cluster = new SdxCluster();
cluster.setId(1L);
cluster.setClusterName("testclustername");
CertificatesRotationV4Request request = new CertificatesRotationV4Request();
ArgumentCaptor<SdxStartCertRotationEvent> eventArgumentCaptor = ArgumentCaptor.forClass(SdxStartCertRotationEvent.class);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, "pollid");
when(flowManager.triggerCertRotation(eventArgumentCaptor.capture(), anyString())).thenReturn(flowIdentifier);
FlowIdentifier result = ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.rotateAutoTlsCertificates(cluster, request));
assertEquals(flowIdentifier, result);
SdxStartCertRotationEvent event = eventArgumentCaptor.getValue();
assertEquals(request, event.getRequest());
assertEquals(1L, event.getResourceId());
assertEquals(TEST_USER_CRN, event.getUserId());
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class CloudbreakFlowServiceTest method testSaveFlowIdWhenFlowTypeIsFlow.
@Test
public void testSaveFlowIdWhenFlowTypeIsFlow() {
SdxCluster cluster = new SdxCluster();
cluster.setLastCbFlowChainId(FLOW_CHAIN_ID);
cluster.setInitiatorUserCrn(USER_CRN);
cluster.setClusterName(CLUSTER_NAME);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, FLOW_ID);
underTest.saveLastCloudbreakFlowChainId(cluster, flowIdentifier);
verify(sdxClusterRepository).save(clusterCaptor.capture());
assertEquals(FLOW_ID, clusterCaptor.getValue().getLastCbFlowId());
assertNull(clusterCaptor.getValue().getLastCbFlowChainId());
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class CloudbreakFlowServiceTest method testSaveFlowChainIdWhenFlowTypeIsFlowChain.
@Test
public void testSaveFlowChainIdWhenFlowTypeIsFlowChain() {
SdxCluster cluster = new SdxCluster();
cluster.setLastCbFlowChainId(FLOW_CHAIN_ID);
cluster.setInitiatorUserCrn(USER_CRN);
cluster.setClusterName(CLUSTER_NAME);
FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW_CHAIN, FLOW_CHAIN_ID);
underTest.saveLastCloudbreakFlowChainId(cluster, flowIdentifier);
verify(sdxClusterRepository).save(clusterCaptor.capture());
assertEquals(FLOW_CHAIN_ID, clusterCaptor.getValue().getLastCbFlowChainId());
assertNull(clusterCaptor.getValue().getLastCbFlowId());
}
use of com.sequenceiq.flow.api.model.FlowIdentifier in project cloudbreak by hortonworks.
the class LoadBalancerPollerServiceTest method testPollingSingleFailure.
@Test
public void testPollingSingleFailure() {
List<FlowIdentifier> flowIdentifiers = setupFlowIdentifiers(3);
Iterator<FlowIdentifier> iterator = flowIdentifiers.iterator();
FlowIdentifier failFlowId = iterator.next();
String successFlowId1 = iterator.next().getPollableId();
String successFlowId2 = iterator.next().getPollableId();
String expectedError = "Data Lake or Data Hub update flows failed: " + List.of(failFlowId);
setupDatalakeResponse();
setupDatahubResponse();
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
when(stackService.updateLoadBalancer(eq(Set.of(DL_NAME, DH_NAME1, DH_NAME2)))).thenReturn(flowIdentifiers);
when(flowEndpoint.hasFlowRunningByFlowId(anyString())).thenReturn(setupFinishedFlowCheckResponse());
when(flowEndpoint.getFlowLogsByFlowId(failFlowId.getPollableId())).thenReturn(List.of(setupFailFlowLogResponse()));
when(flowEndpoint.getFlowLogsByFlowId(successFlowId1)).thenReturn(List.of(setupSuccessFlowLogResponse()));
when(flowEndpoint.getFlowLogsByFlowId(successFlowId2)).thenReturn(List.of(setupSuccessFlowLogResponse()));
UpdateFailedException exception = assertThrows(UpdateFailedException.class, () -> underTest.updateStackWithLoadBalancer(ENV_ID, ENV_CRN, ENV_NAME, PublicEndpointAccessGateway.ENABLED));
verify(flowEndpoint, times(3)).hasFlowRunningByFlowId(anyString());
verify(flowEndpoint, times(3)).getFlowLogsByFlowId(anyString());
assertEquals(expectedError, exception.getMessage());
}
Aggregations