use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorServiceTest method testNoValidRecoveryValidation.
@Test
public void testNoValidRecoveryValidation() {
SdxRecoverableResponse nonrecoverableResponse2 = new SdxRecoverableResponse("Some non reason2", RecoveryStatus.NON_RECOVERABLE);
when(mockResizeRecoveryService.validateRecovery(cluster)).thenReturn(nonrecoverableResponse);
when(mockSdxUpgradeRecoveryService.validateRecovery(cluster)).thenReturn(nonrecoverableResponse2);
SdxRecoverableResponse result = sdxRecoverySelectorService.validateRecovery(cluster);
Mockito.verify(mockResizeRecoveryService).validateRecovery(cluster);
Mockito.verify(mockSdxUpgradeRecoveryService).validateRecovery(cluster);
assertNotNull(result);
assertTrue(result.getStatus().nonRecoverable());
// "Some non reason, Some non reason2" order independent
assertEquals(33, result.getReason().length(), result.getReason());
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorServiceTest method testNoValidRecoveryTrigger.
@Test
public void testNoValidRecoveryTrigger() {
SdxRecoverableResponse nonrecoverableResponse2 = new SdxRecoverableResponse("Some non reason2", RecoveryStatus.NON_RECOVERABLE);
SdxRecoveryRequest request = new SdxRecoveryRequest();
when(mockResizeRecoveryService.validateRecovery(cluster, request)).thenReturn(nonrecoverableResponse);
when(mockSdxUpgradeRecoveryService.validateRecovery(cluster, request)).thenReturn(nonrecoverableResponse2);
BadRequestException result = assertThrows(BadRequestException.class, () -> sdxRecoverySelectorService.triggerRecovery(cluster, request));
Mockito.verify(mockResizeRecoveryService).validateRecovery(cluster, request);
Mockito.verify(mockSdxUpgradeRecoveryService).validateRecovery(cluster, request);
Mockito.verify(mockSdxUpgradeRecoveryService, never()).triggerRecovery(cluster, request);
Mockito.verify(mockSdxUpgradeRecoveryService, never()).triggerRecovery(cluster, request);
assertNotNull(result);
assertEquals(33, result.getMessage().length(), result.getMessage());
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorServiceTest method testRecoveryServiceCanValidateUpgradeFailureByClusterName.
@Test
public void testRecoveryServiceCanValidateUpgradeFailureByClusterName() {
setUpgradeTest();
SdxRecoverableResponse result = sdxRecoverySelectorService.validateRecovery(cluster);
// Basically, just check that we pass through
Mockito.verify(mockSdxUpgradeRecoveryService).validateRecovery(cluster);
assertNotNull(result);
assertEquals(recoverableResponse, result);
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class ResizeRecoveryServiceTest method testGetClusterRecoverableForStatusRecoverable.
public void testGetClusterRecoverableForStatusRecoverable(DatalakeStatusEnum status) {
sdxStatusEntity.setStatus(status);
SdxRecoverableResponse sdxRecoverableResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.validateRecovery(cluster));
assertEquals(RecoveryStatus.RECOVERABLE, sdxRecoverableResponse.getStatus(), status + " should be recoverable");
}
use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.
the class SdxRecoverySelectorService method triggerRecovery.
public SdxRecoveryResponse triggerRecovery(SdxCluster sdxCluster, SdxRecoveryRequest sdxRecoveryRequest) {
List<String> responseReasons = new ArrayList<>();
SdxRecoverableResponse recoverableResponse;
for (RecoveryService recoveryService : services) {
try {
recoverableResponse = recoveryService.validateRecovery(sdxCluster, sdxRecoveryRequest);
} catch (Exception e) {
recoverableResponse = interpretValidationError(sdxCluster, e);
}
responseReasons.add(recoverableResponse.getReason());
if (recoverableResponse.getStatus().recoverable()) {
return recoveryService.triggerRecovery(sdxCluster, sdxRecoveryRequest);
}
}
String reasons = String.join(", ", responseReasons);
LOGGER.debug("Cluster is not in a recoverable state with message(s): {}", reasons);
throw new BadRequestException(reasons);
}
Aggregations