use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class ResizeRecoveryServiceTest method testEmptyFlowLogValidateNonRecoverable.
@Test
public void testEmptyFlowLogValidateNonRecoverable() {
lenient().when(flow2Handler.getFirstStateLogfromLatestFlow(cluster.getId())).thenReturn(Optional.empty());
sdxStatusEntity.setStatus(DatalakeStatusEnum.REQUESTED);
SdxRecoverableResponse sdxRecoverableResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateRecovery(cluster));
assertEquals(RecoveryStatus.NON_RECOVERABLE, sdxRecoverableResponse.getStatus(), "No recent flowlog should be non-recoverable");
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorServiceTest method testRecoveryServiceCanValidateResizeRecovery.
@Test
public void testRecoveryServiceCanValidateResizeRecovery() {
setResizeTest();
SdxRecoverableResponse result = sdxRecoverySelectorService.validateRecovery(cluster);
// Basically, just check that we pass through
Mockito.verify(mockResizeRecoveryService).validateRecovery(cluster);
Mockito.verify(mockSdxUpgradeRecoveryService, never()).validateRecovery(cluster);
assertNotNull(result);
assertEquals(recoverableResponse, result);
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class ResizeRecoveryServiceTest method testNoEntitlementValidate.
@Test
public void testNoEntitlementValidate() {
when(entitlementService.isDatalakeResizeRecoveryEnabled(anyString())).thenReturn(false);
sdxStatusEntity.setStatus(STOP_FAILED);
SdxRecoverableResponse sdxRecoverableResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateRecovery(cluster));
assertEquals(RecoveryStatus.NON_RECOVERABLE, sdxRecoverableResponse.getStatus());
assertEquals("Resize Recovery entitlement not enabled", sdxRecoverableResponse.getReason());
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class ResizeRecoveryServiceTest method testGetClusterRecoverableForStatusNotRecoverable.
public void testGetClusterRecoverableForStatusNotRecoverable(DatalakeStatusEnum status) {
sdxStatusEntity.setStatus(status);
SdxRecoverableResponse sdxRecoverableResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateRecovery(cluster));
assertEquals(RecoveryStatus.NON_RECOVERABLE, sdxRecoverableResponse.getStatus(), status + " should be non-recoverable");
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class SdxUpgradeRecoveryService method validateRecovery.
@Override
public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster, SdxRecoveryRequest request) {
MDCBuilder.buildMdcContext(sdxCluster);
try {
String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
if (Objects.nonNull(request) && request.getType() == SdxRecoveryType.RECOVER_WITH_DATA) {
String clusterRuntime = sdxCluster.getRuntime();
datalakeDRProto.DatalakeBackupInfo lastSuccessfulBackup = datalakeDrClient.getLastSuccessfulBackup(sdxCluster.getClusterName(), initiatorUserCrn, Optional.of(clusterRuntime));
if (Objects.isNull(lastSuccessfulBackup)) {
return new SdxRecoverableResponse("There is no successful backup taken yet for data lake cluster with runtime " + clusterRuntime + ".", RecoveryStatus.NON_RECOVERABLE);
}
}
RecoveryValidationV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.getClusterRecoverableByNameInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn));
return new SdxRecoverableResponse(response.getReason(), response.getStatus());
} catch (WebApplicationException e) {
String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
String message = String.format("Stack recovery validation failed on cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
throw new CloudbreakApiException(message, e);
}
}
Aggregations