use of com.sequenceiq.sdx.api.model.SdxRecoveryResponse in project cloudbreak by hortonworks.
the class SdxRecoveryAction method action.
@Override
public SdxTestDto action(TestContext testContext, SdxTestDto testDto, SdxClient client) throws Exception {
SdxRecoveryRequest recoveryRequest = testDto.getSdxRecoveryRequest();
Log.when(LOGGER, " SDX endpoint: %s" + client.getDefaultClient().sdxEndpoint() + ", SDX's environment: " + testDto.getRequest().getEnvironment());
Log.whenJson(LOGGER, " SDX recovery request: ", recoveryRequest);
SdxRecoveryResponse recoveryResponse = client.getDefaultClient().sdxRecoveryEndpoint().recoverClusterByName(testDto.getName(), recoveryRequest);
testDto.setFlow("SDX recovery", recoveryResponse.getFlowIdentifier());
SdxClusterDetailResponse detailedResponse = client.getDefaultClient().sdxEndpoint().getDetail(testDto.getName(), Collections.emptySet());
testDto.setResponse(detailedResponse);
Log.whenJson(LOGGER, " SDX recovery response: ", detailedResponse);
return testDto;
}
use of com.sequenceiq.sdx.api.model.SdxRecoveryResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorServiceTest method testRecoveryServiceCanRecoverFromUpgradeFailureByClusterName.
@Test
public void testRecoveryServiceCanRecoverFromUpgradeFailureByClusterName() {
setUpgradeTest();
SdxRecoveryResponse response = new SdxRecoveryResponse();
when(mockSdxUpgradeRecoveryService.triggerRecovery(cluster, request)).thenReturn(response);
SdxRecoveryResponse result = sdxRecoverySelectorService.triggerRecovery(cluster, request);
// Basically, just check that we pass through
Mockito.verify(mockSdxUpgradeRecoveryService).validateRecovery(cluster, request);
Mockito.verify(mockSdxUpgradeRecoveryService).triggerRecovery(cluster, request);
Mockito.verify(mockResizeRecoveryService, never()).triggerRecovery(cluster, request);
assertNotNull(result);
assertEquals(response, result);
}
use of com.sequenceiq.sdx.api.model.SdxRecoveryResponse in project cloudbreak by hortonworks.
the class SdxUpgradeRecoveryServiceTest method testValidateStatusSuccessfulShouldStartRecoveryFlow.
@Test
public void testValidateStatusSuccessfulShouldStartRecoveryFlow() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
String reason = "Datalake upgrade recovery requested. Cluster will be terminated and re-launched with the original runtime.";
RecoveryValidationV4Response recoveryV4Response = new RecoveryValidationV4Response(reason, RecoveryStatus.RECOVERABLE);
when(stackV4Endpoint.getClusterRecoverableByNameInternal(WORKSPACE_ID, CLUSTER_NAME, USER_CRN)).thenReturn(recoveryV4Response);
when(sdxReactorFlowManager.triggerDatalakeRuntimeRecoveryFlow(cluster, SdxRecoveryType.RECOVER_WITHOUT_DATA)).thenReturn(new FlowIdentifier(FlowType.FLOW, "FLOW_ID"));
SdxRecoverableResponse sdxRecoverableResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateRecovery(cluster));
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.sdx.api.model.SdxRecoveryResponse 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.sdx.api.model.SdxRecoveryResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorServiceTest method testRecoveryServiceCanSwitchDespiteValidationError.
@Test
public void testRecoveryServiceCanSwitchDespiteValidationError() {
setUpgradeTest();
when(mockResizeRecoveryService.validateRecovery(cluster, request)).thenAnswer(invocation -> {
throw new Exception("Error!");
});
SdxRecoveryResponse response = new SdxRecoveryResponse();
when(mockSdxUpgradeRecoveryService.triggerRecovery(cluster, request)).thenReturn(response);
SdxRecoveryResponse result = sdxRecoverySelectorService.triggerRecovery(cluster, request);
// Basically, just check that we pass through to the Upgrade Recovery Service despite error during resize recovery validation.
Mockito.verify(mockResizeRecoveryService, never()).triggerRecovery(cluster, request);
Mockito.verify(mockSdxUpgradeRecoveryService).triggerRecovery(cluster, request);
assertNotNull(result);
assertEquals(response, result);
}
Aggregations