use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class CloudbreakUserCache method getUserByDisplayName.
public CloudbreakUser getUserByDisplayName(String name) {
if (MapUtils.isEmpty(usersByAccount)) {
initRealUmsUserCache();
}
if (isInitialized()) {
CloudbreakUser user = usersByAccount.values().stream().flatMap(Collection::stream).filter(u -> u.getDisplayName().equals(name)).findFirst().orElseThrow(() -> new TestFailException(String.format("There is no real UMS user with::%n name: %s%n deployment: %s%n account: %s%n", name, realUmsUserDeployment, realUmsUserAccount)));
LOGGER.info(" Real UMS user has been found:: \nDisplay name: {} \nCrn: {} \nAccess key: {} \nSecret key: {} \nAdmin: {} ", user.getDisplayName(), user.getCrn(), user.getAccessKey(), user.getSecretKey(), user.getAdmin());
return user;
} else {
throw new TestFailException("Cannot get real UMS user by name, because of 'ums-users/api-credentials.json' is not available.");
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class S3ClientActions method deleteNonVersionedBucket.
public void deleteNonVersionedBucket(String baseLocation) {
AmazonS3 s3Client = buildS3Client();
String bucketName = getBucketName();
String prefix = StringUtils.substringAfterLast(baseLocation, "/");
if (s3Client.doesBucketExistV2(bucketName)) {
try {
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucketName).withPrefix(prefix);
ObjectListing objectListing = s3Client.listObjects(listObjectsRequest);
do {
List<DeleteObjectsRequest.KeyVersion> deletableObjects = Lists.newArrayList();
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
deletableObjects.add(new DeleteObjectsRequest.KeyVersion(objectSummary.getKey()));
}
DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucketName);
deleteObjectsRequest.setKeys(deletableObjects);
s3Client.deleteObjects(deleteObjectsRequest);
if (objectListing.isTruncated()) {
objectListing = s3Client.listNextBatchOfObjects(objectListing);
}
} while (objectListing.isTruncated());
} catch (AmazonServiceException e) {
LOGGER.error("Amazon S3 couldn't process the call. So it has been returned with error!", e);
throw new TestFailException("Amazon S3 couldn't process the call.", e);
} catch (SdkClientException e) {
LOGGER.error("Amazon S3 response could not been parsed, because of error!", e);
throw new TestFailException("Amazon S3 response could not been parsed", e);
} finally {
s3Client.shutdown();
}
} else {
LOGGER.error("Amazon S3 bucket is not present with name: {}", bucketName);
throw new TestFailException("Amazon S3 bucket is not present with name: " + bucketName);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class AzureCloudBlobClientActions method deleteAllFolders.
public SdxTestDto deleteAllFolders(TestContext testContext, SdxTestDto sdxTestDto, SdxClient sdxClient) {
String containerName = getContainerName(sdxTestDto.getRequest().getCloudStorage().getBaseLocation());
CloudBlobContainer cloudBlobContainer = getCloudBlobContainer(containerName);
try {
for (ListBlobItem blob : cloudBlobContainer.listBlobs()) {
String blobName = blob.getUri().getPath().split("/", 3)[2];
String blobUriPath = blob.getUri().getPath();
if (blob instanceof CloudBlob) {
((CloudBlob) blob).deleteIfExists();
} else {
if (blobName.endsWith("/")) {
blobName = blobName.replaceAll(".$", "");
}
CloudBlobDirectory blobDirectory = cloudBlobContainer.getDirectoryReference(blobName);
deleteBlobsInDirectory(blobDirectory);
}
}
} catch (StorageException | URISyntaxException e) {
LOGGER.error("Azure Adls Gen 2 Blob couldn't process the call. So it has been returned with error!", e);
throw new TestFailException("Azure Adls Gen 2 Blob couldn't process the call.", e);
}
return sdxTestDto;
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class AzureCloudBlobClientActions method getLoggingUrl.
public String getLoggingUrl(String baseLocation, String clusterLogPath) {
String containerName = getContainerName(baseLocation);
CloudBlobContainer cloudBlobContainer = getCloudBlobContainer(containerName);
String keyPrefix = StringUtils.substringAfterLast(baseLocation, "/");
Log.log(LOGGER, format(" Azure Blob Storage URI: %s", cloudBlobContainer.getStorageUri()));
Log.log(LOGGER, format(" Azure Blob Container: %s", cloudBlobContainer.getName()));
Log.log(LOGGER, format(" Azure Blob Key Prefix: %s", keyPrefix));
Log.log(LOGGER, format(" Azure Blob Cluster Logs: %s", clusterLogPath));
try {
CloudBlobDirectory storageDirectory = cloudBlobContainer.getDirectoryReference(keyPrefix);
CloudBlobDirectory logsDirectory = storageDirectory.getDirectoryReference(clusterLogPath);
if (logsDirectory.listBlobs().iterator().hasNext()) {
return String.format("https://autotestingapi.blob.core.windows.net/%s/%s%s", containerName, keyPrefix, clusterLogPath);
} else {
LOGGER.error("Azure Adls Gen 2 Blob is NOT present at '{}' container in '{}' storage directory with path: [{}]", containerName, keyPrefix, clusterLogPath);
throw new TestFailException(format("Azure Adls Gen 2 Blob is NOT present at '%s' container in '%s' storage directory with path: [%s]", containerName, keyPrefix, clusterLogPath));
}
} catch (StorageException | URISyntaxException e) {
LOGGER.error("Azure Adls Gen 2 Blob couldn't process the call. So it has been returned with error!", e);
throw new TestFailException("Azure Adls Gen 2 Blob couldn't process the call.", e);
}
}
use of com.sequenceiq.it.cloudbreak.exception.TestFailException in project cloudbreak by hortonworks.
the class AzureClientActions method createResourceGroup.
public ResourceGroup createResourceGroup(String resourceGroupName, Map<String, String> tags) {
if (StringUtils.isNotBlank(resourceGroupName)) {
LOGGER.info(format("Creating resource group '%s'...", resourceGroupName));
Map<String, String> allTags = new HashMap<>();
allTags.putAll(tags);
allTags.putAll(commonCloudProperties.getTags());
ResourceGroup resourceGroup;
resourceGroup = azure.resourceGroups().define(resourceGroupName).withRegion(azureProperties.getRegion()).withTags(allTags).create();
if (resourceGroup.provisioningState().equalsIgnoreCase("Succeeded")) {
LOGGER.info(format("New resource group '%s' has been created.", resourceGroupName));
Log.then(LOGGER, format(" New resource group '%s' has been created. ", resourceGroupName));
return resourceGroup;
} else {
LOGGER.error("Failed to provision the resource group '{}'!", resourceGroupName);
throw new TestFailException(format("Failed to provision the resource group '%s'!", resourceGroupName));
}
} else {
LOGGER.error("Resource group name has not been provided! So create new resource group for environment is not possible.");
throw new TestFailException("Resource group name has not been provided! So create new resource group for environment is not possible.");
}
}
Aggregations