use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class DatabaseObtainerServiceTest method rdsNotFoundServiceException.
@Test
void rdsNotFoundServiceException() throws JsonProcessingException {
when(clusterPollingCheckerService.checkClusterCancelledState(any(), anyBoolean())).thenReturn(null);
CloudbreakServiceException serviceException = new CloudbreakServiceException("error", new NotFoundException("baseException"));
when(redbeamsClient.getByCrn(anyString())).thenThrow(serviceException);
AttemptResult<Object> result = underTest.obtainAttemptResult(cluster, DatabaseOperation.CREATION, "crn", true);
assertThat(result.getState()).isEqualTo(AttemptState.FINISH);
assertThat(result.getResult()).isNull();
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class DatabaseObtainerServiceTest method rdsNotHandledServiceException.
@Test
void rdsNotHandledServiceException() {
when(clusterPollingCheckerService.checkClusterCancelledState(any(), anyBoolean())).thenReturn(null);
CloudbreakServiceException serviceException = new CloudbreakServiceException("error", new IllegalStateException("baseException"));
when(redbeamsClient.getByCrn(anyString())).thenThrow(serviceException);
assertThatThrownBy(() -> underTest.obtainAttemptResult(cluster, DatabaseOperation.CREATION, "crn", true)).isEqualTo(serviceException);
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class ClusterCreationEnvironmentValidatorTest method testValidateShouldFailWhenProxyCouldNotBeFoundInTheSameWorkspace.
@Test
void testValidateShouldFailWhenProxyCouldNotBeFoundInTheSameWorkspace() {
// GIVEN
Stack stack = getStack();
stack.setEnvironmentCrn(null);
when(proxyConfigDtoService.getByCrn(anyString())).thenThrow(new CloudbreakServiceException("Some reason"));
ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder();
// WHEN
underTest.validateProxyConfig("proxy", validationBuilder);
// THEN
ValidationResult actualResult = validationBuilder.build();
assertTrue(actualResult.hasError());
assertEquals(1, actualResult.getErrors().size());
assertEquals("The specified 'proxy' Proxy config resource couldn't be used: Some reason.", actualResult.getErrors().get(0));
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class SaltOrchestrator method getFreeDiskSpaceByNodes.
@Override
public Map<String, String> getFreeDiskSpaceByNodes(Set<Node> nodes, List<GatewayConfig> gatewayConfigs) {
Map<String, String> freeDiskSpaceByNode;
try {
GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(gatewayConfigs);
SaltConnector sc = saltService.createSaltConnector(primaryGateway);
Target<String> allHosts = new HostList(nodes.stream().map(Node::getHostname).collect(Collectors.toSet()));
freeDiskSpaceByNode = SaltStates.runCommandOnHosts(retry, sc, allHosts, "df -k / | tail -1 | awk '{print $4}'");
} catch (Exception e) {
String errorMessage = String.format("Failed to get free disk space on hosts. Reason: %s", e.getMessage());
LOGGER.warn(errorMessage, e);
throw new CloudbreakServiceException(errorMessage, e);
}
return freeDiskSpaceByNode;
}
use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.
the class SdxImageCatalogServiceTest method generateImageCatalogShouldThrowApiExceptionInCaseOfServiceException.
@Test
void generateImageCatalogShouldThrowApiExceptionInCaseOfServiceException() {
when(stackV4Endpoint.generateImageCatalogInternal(WORKSPACE_ID_DEFAULT, CLUSTER_NAME, USER_CRN)).thenThrow(new CloudbreakServiceException(EXCEPTION_MESSAGE));
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
assertThatThrownBy(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.generateImageCatalog(CLUSTER_NAME))).isInstanceOf(CloudbreakApiException.class).hasMessage(EXCEPTION_MESSAGE);
}
Aggregations