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());
}
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);
}
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
}
});
}
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());
}
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);
}
}
Aggregations