use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class BasicEnvironmentVirtualGroupTest method getEnvironmentVirtualGroups.
private Map<UmsRight, String> getEnvironmentVirtualGroups(TestContext testContext, UmsClient client) {
String accountId = testContext.getActingUserCrn().getAccountId();
String environmentCrn = testContext.given(EnvironmentTestDto.class).getCrn();
Map<UmsRight, String> virtualGroups = new HashMap<>();
String virtualGroup = null;
for (UmsRight right : UmsRight.values()) {
try {
virtualGroup = client.getDefaultClient().getWorkloadAdministrationGroupName(accountId, MDCUtils.getRequestId(), right.getRight(), environmentCrn);
} catch (StatusRuntimeException ex) {
if (Status.Code.NOT_FOUND != ex.getStatus().getCode()) {
LOGGER.info(String.format(" Virtual groups is missing for right: '%s' ", right.getRight()));
}
}
if (StringUtils.hasText(virtualGroup)) {
virtualGroups.put(right, virtualGroup);
}
}
if (MapUtils.isNotEmpty(virtualGroups)) {
Log.then(LOGGER, format(" Virtual groups are present [%s] for environment '%s' ", virtualGroups, environmentCrn));
LOGGER.info(String.format(" Virtual groups are present [%s] for environment '%s' ", virtualGroups, environmentCrn));
} else {
throw new TestFailException(String.format(" Cannot find virtual groups for environment '%s' ", environmentCrn));
}
return virtualGroups;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class DistroXEncryptedVolumeTest method verifyVolumeEncryptionKey.
private void verifyVolumeEncryptionKey(CloudPlatform cloudPlatform, String resourceName, List<String> instanceIds, CloudFunctionality cloudFunctionality, String environmentName, String resourceGroupName) {
if (CloudPlatform.AWS.equals(cloudPlatform)) {
String kmsKeyArn = awsCloudProvider.getEncryptionKeyArn(true);
List<String> volumeKmsKeyIds = new ArrayList<>(cloudFunctionality.listVolumeEncryptionKeyIds(resourceName, null, instanceIds));
if (volumeKmsKeyIds.stream().noneMatch(keyId -> keyId.equalsIgnoreCase(kmsKeyArn))) {
LOGGER.error(format("Volume has not been encrypted with '%s' KMS key!", kmsKeyArn));
throw new TestFailException(format("Volume has not been encrypted with '%s' KMS key!", kmsKeyArn));
} else {
LOGGER.info(format("Volume has been encrypted with '%s' KMS key.", kmsKeyArn));
Log.then(LOGGER, format(" Volume has been encrypted with '%s' KMS key. ", kmsKeyArn));
}
} else if (CloudPlatform.AZURE.equals(cloudPlatform)) {
String desKeyUrl = azureCloudProvider.getEncryptionKeyUrl();
List<String> volumesDesId = new ArrayList<>(cloudFunctionality.listVolumeEncryptionKeyIds(resourceName, resourceGroupName, instanceIds));
volumesDesId.forEach(desId -> {
if (desId.contains("diskEncryptionSets/" + environmentName)) {
LOGGER.info(format("Volume has been encrypted with '%s' DES key.", desId));
Log.then(LOGGER, format(" Volume has been encrypted with '%s' DES key. ", desId));
} else {
LOGGER.error(format("Volume has not been encrypted with '%s' key!", desKeyUrl));
throw new TestFailException(format("Volume has not been encrypted with '%s' key!", desKeyUrl));
}
});
} else {
LOGGER.warn(format("Disk encryption feature is not available at '%s' currently!", cloudPlatform));
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class AbstractCloudProvider method getLatestBaseImage.
public String getLatestBaseImage(ImageCatalogTestDto imageCatalogTestDto, CloudbreakClient cloudbreakClient, String platform) {
try {
List<BaseImageV4Response> images = cloudbreakClient.getDefaultClient().imageCatalogV4Endpoint().getImagesByName(cloudbreakClient.getWorkspaceId(), imageCatalogTestDto.getRequest().getName(), null, platform, null, null).getBaseImages();
if (images.size() == 0) {
throw new IllegalStateException("Images are empty, there is not any base image on provider " + platform);
}
BaseImageV4Response baseImage = images.get(images.size() - 1);
Log.log(LOGGER, format(" Image Catalog Name: %s ", imageCatalogTestDto.getRequest().getName()));
Log.log(LOGGER, format(" Image Catalog URL: %s ", imageCatalogTestDto.getRequest().getUrl()));
Log.log(LOGGER, format(" Selected Base Image Date: %s | ID: %s | Description: %s ", baseImage.getDate(), baseImage.getUuid(), baseImage.getDescription()));
return baseImage.getUuid();
} catch (Exception e) {
LOGGER.error("Cannot fetch base images of {} image catalog, because of {}", imageCatalogTestDto.getRequest().getName(), e);
throw new TestFailException(" Cannot fetch base images of " + imageCatalogTestDto.getRequest().getName() + " image catalog", e);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class SshJClientActions method checkNoEphemeralDisksMounted.
public void checkNoEphemeralDisksMounted(List<InstanceGroupV4Response> instanceGroups, List<String> hostGroupNames) {
Map<String, Pair<Integer, String>> deviceMountPointMappingsByIp = getDeviceMountPointMappingsByIp(instanceGroups, hostGroupNames);
Map<String, Pair<Integer, String>> deviceDiskTypeMappingsByIp = getDeviceDiskTypeMappingsByIp(instanceGroups, hostGroupNames);
for (Entry<String, Pair<Integer, String>> node : deviceDiskTypeMappingsByIp.entrySet()) {
Map<String, String> ephemeralDisks = new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("Amazon EC2 NVMe Instance Storage")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
if (!ephemeralDisks.isEmpty()) {
LOGGER.error("Instance store volume unintentionally present on node with IP {}!", node.getKey());
throw new TestFailException(String.format("Instance store volume unintentionally present on node with IP %s!", node.getKey()));
}
}
for (Entry<String, Pair<Integer, String>> node : deviceMountPointMappingsByIp.entrySet()) {
Map<String, String> ephemeralMounts = new Json(node.getValue().getValue()).getMap().entrySet().stream().filter(e -> String.valueOf(e.getValue()).contains("ephfs")).collect(Collectors.toMap(Entry::getKey, x -> String.valueOf(x.getValue())));
if (!ephemeralMounts.isEmpty()) {
LOGGER.error("Device incorrectly mounted to /hadoopfs/ephfsN on node with IP {}!", node.getKey());
throw new TestFailException(String.format("Device incorrectly mounted to /hadoopfs/ephfsN on node with IP %s!", node.getKey()));
}
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class DistroXCreateAction method action.
@Override
public DistroXTestDto action(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
if (StringUtils.isEmpty(testDto.getRequest().getEnvironmentName())) {
Log.when(LOGGER, " Env name cannot be null ");
throw new TestFailException("Env name cannot be null");
}
Log.whenJson(LOGGER, " Distrox create request: ", testDto.getRequest());
StackV4Response stackV4Response = client.getDefaultClient().distroXV1Endpoint().post(testDto.getRequest());
testDto.setFlow("Distrox create", stackV4Response.getFlowIdentifier());
testDto.setResponse(stackV4Response);
Log.whenJson(LOGGER, " Distrox create response: ", stackV4Response);
return testDto;
}
Aggregations