Search in sources :

Example 1 with SdxRecoveryResponse

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;
}
Also used : SdxRecoveryRequest(com.sequenceiq.sdx.api.model.SdxRecoveryRequest) SdxClusterDetailResponse(com.sequenceiq.sdx.api.model.SdxClusterDetailResponse) SdxRecoveryResponse(com.sequenceiq.sdx.api.model.SdxRecoveryResponse)

Example 2 with SdxRecoveryResponse

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);
}
Also used : SdxRecoveryResponse(com.sequenceiq.sdx.api.model.SdxRecoveryResponse) Test(org.junit.Test)

Example 3 with SdxRecoveryResponse

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());
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) SdxRecoveryResponse(com.sequenceiq.sdx.api.model.SdxRecoveryResponse) Test(org.junit.jupiter.api.Test)

Example 4 with SdxRecoveryResponse

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());
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) com.cloudera.thunderhead.service.datalakedr.datalakeDRProto(com.cloudera.thunderhead.service.datalakedr.datalakeDRProto) SdxRecoveryResponse(com.sequenceiq.sdx.api.model.SdxRecoveryResponse) Test(org.junit.jupiter.api.Test)

Example 5 with SdxRecoveryResponse

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);
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxRecoveryResponse(com.sequenceiq.sdx.api.model.SdxRecoveryResponse) Test(org.junit.Test)

Aggregations

SdxRecoveryResponse (com.sequenceiq.sdx.api.model.SdxRecoveryResponse)9 Test (org.junit.jupiter.api.Test)4 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 Test (org.junit.Test)3 RecoveryValidationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response)2 SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)2 com.cloudera.thunderhead.service.datalakedr.datalakeDRProto (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 SdxClusterDetailResponse (com.sequenceiq.sdx.api.model.SdxClusterDetailResponse)1 SdxRecoveryRequest (com.sequenceiq.sdx.api.model.SdxRecoveryRequest)1