Search in sources :

Example 46 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class CmVersionQueryServiceTest method testWhenNoPackageVersionsThenValidateConsistencyShouldFail.

@Test
void testWhenNoPackageVersionsThenValidateConsistencyShouldFail() {
    Map<String, List<PackageInfo>> hostPackageMap = Maps.newHashMap();
    hostPackageMap.put(HOST_1, new ArrayList<>());
    hostPackageMap.put(HOST_2, new ArrayList<>());
    CloudbreakServiceException exception = assertThrows(CloudbreakServiceException.class, () -> underTest.checkCmPackageInfoConsistency(hostPackageMap));
    Assertions.assertEquals("Error during sync! CM server and agent versions cannot be determined!", exception.getMessage());
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 47 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class MetadataSetupServiceTest method saveInstanceMetaDataTestShouldNotSaveInstancesWhenImageNotFound.

@Test
public void saveInstanceMetaDataTestShouldNotSaveInstancesWhenImageNotFound() throws CloudbreakImageNotFoundException {
    Iterable<CloudVmMetaDataStatus> cloudVmMetaDataStatuses = getCloudVmMetaDataStatuses(InstanceStatus.CREATED);
    CloudbreakImageNotFoundException exception = new CloudbreakImageNotFoundException("Image does not exist");
    doThrow(exception).when(imageService).getImage(STACK_ID);
    CloudbreakServiceException cloudbreakServiceException = assertThrows(CloudbreakServiceException.class, () -> underTest.saveInstanceMetaData(stack, cloudVmMetaDataStatuses, CREATED));
    assertThat(cloudbreakServiceException).hasMessage("Instance metadata collection failed");
    assertThat(cloudbreakServiceException.getCause()).isSameAs(exception);
}
Also used : CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 48 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class LoadBalancerConfigServiceTest method testCreateAzureMultipleKnoxInstanceGroups.

@Test
public void testCreateAzureMultipleKnoxInstanceGroups() {
    Stack stack = createAzureStack(StackType.DATALAKE, PRIVATE_ID_1, true);
    CloudSubnet subnet = getPrivateCloudSubnet(PRIVATE_ID_1, AZ_1);
    DetailedEnvironmentResponse environment = createEnvironment(subnet, false, "AZURE");
    StackV4Request request = new StackV4Request();
    request.setEnableLoadBalancer(false);
    when(entitlementService.azureDatalakeLoadBalancerEnabled(anyString())).thenReturn(true);
    when(blueprint.getBlueprintText()).thenReturn(getBlueprintText("input/clouderamanager-multi-knox.bp"));
    when(subnetSelector.findSubnetById(any(), anyString())).thenReturn(Optional.of(subnet));
    ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> {
        try {
            underTest.createLoadBalancers(stack, environment, request);
            fail("Should not allow multiple knox groups with Azure load balancers");
        } catch (CloudbreakServiceException ignored) {
        // pass
        }
    });
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) SubnetTest(com.sequenceiq.cloudbreak.core.network.SubnetTest) Test(org.junit.Test)

Example 49 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaUnknownThenThrowsException.

@ParameterizedTest
@EnumSource(value = Status.class)
void testCheckFreeipaRunningWhenFreeIpaUnknownThenThrowsException(Status status) {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(status);
    freeipa.setAvailabilityStatus(AvailabilityStatus.UNKNOWN);
    when(freeipaClientService.getByEnvironmentCrn(ENV_CRN)).thenReturn(freeipa);
    CloudbreakServiceException exception = Assertions.assertThrows(CloudbreakServiceException.class, () -> underTest.checkFreeipaRunning(ENV_CRN));
    assertEquals("Freeipa availability cannot be determined currently.", exception.getMessage());
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 50 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ResourceEncryptionDeleteHandler method deleteEncryptionResources.

private void deleteEncryptionResources(EnvironmentDto environmentDto, Environment environment) {
    String environmentName = environment.getName();
    LOGGER.info("Deleting encryption resources for environment \"{}\".", environmentName);
    try {
        environmentEncryptionService.deleteEncryptionResources(environmentDto);
        environment.setStatus(EnvironmentStatus.ENVIRONMENT_ENCRYPTION_RESOURCES_DELETED);
        environment.setStatusReason(null);
        environmentService.save(environment);
        LOGGER.info("Finished deleting encryption resources for environment \"{}\".", environmentName);
    } catch (Exception e) {
        LOGGER.error(String.format("Failed to delete encryption resources for environment \"%s\"", environmentName), e);
        throw new CloudbreakServiceException("Error occurred while deleting encryption resources: " + e.getMessage(), e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

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