Search in sources :

Example 56 with CloudbreakServiceException

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();
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 57 with CloudbreakServiceException

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

Example 58 with CloudbreakServiceException

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));
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 59 with CloudbreakServiceException

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;
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) JsonNode(com.fasterxml.jackson.databind.JsonNode) Node(com.sequenceiq.cloudbreak.common.orchestration.Node) HostList(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.HostList) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakOrchestratorTimeoutException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorTimeoutException) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Example 60 with CloudbreakServiceException

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);
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) Test(org.junit.jupiter.api.Test)

Aggregations

CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)142 Test (org.junit.jupiter.api.Test)25 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 List (java.util.List)20 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)18 IOException (java.io.IOException)18 Map (java.util.Map)18 ApiException (com.cloudera.api.swagger.client.ApiException)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)15 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)14 LoggerFactory (org.slf4j.LoggerFactory)14 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)12 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)12 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)12 Optional (java.util.Optional)12 Set (java.util.Set)12