Search in sources :

Example 1 with ObjectStorageMetadataRequest

use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.

the class AwsObjectStorageConnectorTest method getObjectStorageMetadataThrows.

@Test
public void getObjectStorageMetadataThrows() {
    AmazonS3Exception exception = new AmazonS3Exception(ERROR_MESSAGE);
    thrown.expect(CloudConnectorException.class);
    thrown.expectMessage("We were not able to query S3 object storage location for mybucket. " + "Refer to Cloudera documentation at " + DocumentationLinkProvider.awsCloudStorageSetupLink() + " for the required setup. The message from Amazon S3 was: errormessage.");
    when(s3Client.getBucketLocation(BUCKET_NAME)).thenThrow(exception);
    ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withObjectStoragePath(BUCKET_NAME).build();
    underTest.getObjectStorageMetadata(request);
}
Also used : ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest) AmazonS3Exception(com.amazonaws.services.s3.model.AmazonS3Exception) Test(org.junit.Test)

Example 2 with ObjectStorageMetadataRequest

use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.

the class CloudStorageLocationValidatorTest method validateS3.

@Test
public void validateS3() {
    ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
    ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
    when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(S3_OBJECT_PATH, FileSystemType.S3, environment, validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : ObjectStorageMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest) Test(org.junit.jupiter.api.Test)

Example 3 with ObjectStorageMetadataRequest

use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.

the class CloudStorageLocationValidatorTest method validateWasb.

@Test
public void validateWasb() {
    ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
    ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
    when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(WASB_OBJECT_PATH, FileSystemType.WASB, environment, validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : ObjectStorageMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest) Test(org.junit.jupiter.api.Test)

Example 4 with ObjectStorageMetadataRequest

use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.

the class CloudStorageLocationValidatorTest method validateNoProtocol.

@Test
public void validateNoProtocol() {
    ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
    ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
    when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(OBJECT_PATH, FileSystemType.S3, environment, validationResultBuilder);
    assertFalse(validationResultBuilder.build().hasError());
}
Also used : ObjectStorageMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest) Test(org.junit.jupiter.api.Test)

Example 5 with ObjectStorageMetadataRequest

use of com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest in project cloudbreak by hortonworks.

the class CloudStorageLocationValidatorTest method validateError.

@Test
public void validateError() {
    ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
    ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(OTHER_REGION).withStatus(ResponseStatus.OK).build();
    when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
    underTest.validate(OBJECT_PATH, FileSystemType.S3, environment, validationResultBuilder);
    ValidationResult result = validationResultBuilder.build();
    assertTrue(result.hasError());
    assertEquals(String.format("Object storage location [%s] of bucket '%s' must match environment location [%s]", OTHER_REGION, BUCKET_NAME, ENV_REGION), result.getErrors().get(0));
}
Also used : ObjectStorageMetadataResponse(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ObjectStorageMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Aggregations

ObjectStorageMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)16 ObjectStorageMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse)15 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)10 Test (org.junit.jupiter.api.Test)10 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)3 Test (org.junit.Test)3 AmazonS3Exception (com.amazonaws.services.s3.model.AmazonS3Exception)2 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)2 FileSystemType (com.sequenceiq.common.model.FileSystemType)2 Credential (com.sequenceiq.datalake.entity.Credential)1 EnvironmentServiceException (com.sequenceiq.environment.exception.EnvironmentServiceException)1