use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageValidationUtilTest method testIsCloudStorageConfiguredWhenAdlsNotNull.
@Test
public void testIsCloudStorageConfiguredWhenAdlsNotNull() {
CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
StorageIdentityBase storageIdentityBase = new StorageIdentityBase();
storageIdentityBase.setAdls(new AdlsCloudStorageV1Parameters());
cloudStorageRequest.setIdentities(List.of(storageIdentityBase));
cloudStorageRequest.setLocations(List.of(new StorageLocationBase()));
boolean actual = underTest.isCloudStorageConfigured(cloudStorageRequest);
Assert.assertTrue(actual);
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testConvertWhenEnvironmentHaveTelemetryAndStorageLocationsIsNotNullOrEmpty.
@Test
void testConvertWhenEnvironmentHaveTelemetryAndStorageLocationsIsNotNullOrEmpty() {
TelemetryResponse telemetry = new TelemetryResponse();
telemetry.setLogging(new LoggingResponse());
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setTelemetry(telemetry);
CloudStorageCdpService eStorageLocationType = CloudStorageCdpService.RANGER_AUDIT;
String eStorageLocationValue = "MYBUCKET/CONTAINER";
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(eStorageLocationType);
storageLocationBase.setValue(eStorageLocationValue);
List<StorageLocationBase> storageLocations = List.of(storageLocationBase);
CloudStorageRequest request = new CloudStorageRequest();
request.setLocations(storageLocations);
CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, request, environment);
assertNotNull(result);
assertTrue(result.getIdentities().stream().anyMatch(id -> CloudIdentityType.LOG.equals(id.getType())));
assertTrue(result.getLocations().stream().anyMatch(loc -> eStorageLocationType.equals(loc.getType()) && eStorageLocationValue.equals(loc.getValue())));
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testConvertWhenRequestHasCloudStorageLocationsAndSdxHasDifferentStorageLocationsShouldTheRequestLocationsBeUsed.
@Test
void testConvertWhenRequestHasCloudStorageLocationsAndSdxHasDifferentStorageLocationsShouldTheRequestLocationsBeUsed() {
CloudStorageCdpService storageLocationType = CloudStorageCdpService.RANGER_AUDIT;
String eStorageLocationValue = "MYBUCKET/CONTAINER";
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(storageLocationType);
storageLocationBase.setValue(eStorageLocationValue);
List<StorageLocationBase> storageLocations = List.of(storageLocationBase);
CloudStorageRequest request = new CloudStorageRequest();
request.setLocations(storageLocations);
SdxClusterResponse sdxReponse = new SdxClusterResponse();
String storageLocationValue = "MYBUCKET/CONTAINER2";
sdxReponse.setCloudStorageBaseLocation(storageLocationValue);
sdxReponse.setCloudStorageFileSystemType(FileSystemType.S3);
when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(List.of(sdxReponse));
CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, request, new DetailedEnvironmentResponse());
assertNotNull(result);
assertTrue(result.getLocations().stream().anyMatch(loc -> storageLocationType.equals(loc.getType()) && eStorageLocationValue.equals(loc.getValue())));
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testConvertWhenEnvironmentDoesNotHaveTelemetryButCloudStorageLocationsIsNotEmpty.
@Test
void testConvertWhenEnvironmentDoesNotHaveTelemetryButCloudStorageLocationsIsNotEmpty() {
CloudStorageCdpService eStorageLocationType = CloudStorageCdpService.RANGER_AUDIT;
String eStorageLocationValue = "MYBUCKET/CONTAINER";
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(eStorageLocationType);
storageLocationBase.setValue(eStorageLocationValue);
List<StorageLocationBase> storageLocations = List.of(storageLocationBase);
CloudStorageRequest request = new CloudStorageRequest();
request.setLocations(storageLocations);
CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, request, new DetailedEnvironmentResponse());
assertNotNull(result);
assertTrue(result.getLocations().stream().anyMatch(loc -> eStorageLocationType.equals(loc.getType()) && eStorageLocationValue.equals(loc.getValue())));
}
use of com.sequenceiq.common.api.cloudstorage.StorageLocationBase in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testUpdateCloudStorageLocationsWhenRequestContainsOneTemplatedLocationAndOneWithoutTemplatePlaceholderThenThatShouldBeReplaced.
@Test
void testUpdateCloudStorageLocationsWhenRequestContainsOneTemplatedLocationAndOneWithoutTemplatePlaceholderThenThatShouldBeReplaced() {
String templatedStorageLocationBaseValue = "s3a://some-dir/some-other-dir/";
CloudStorageCdpService templatedStorageLocationType = CloudStorageCdpService.DEFAULT_FS;
String templatedStorageLocationValue = templatedStorageLocationBaseValue + "{{{clusterName}}}";
StorageLocationBase templatedStorageLocationBase = new StorageLocationBase();
templatedStorageLocationBase.setType(templatedStorageLocationType);
templatedStorageLocationBase.setValue(templatedStorageLocationValue);
CloudStorageCdpService storageLocationType = CloudStorageCdpService.FLINK_JOBMANAGER_ARCHIVE;
String eStorageLocationValue = "s3a://some-awesome-dir/some-other-awesome-dir/" + CLUSTER_NAME;
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(storageLocationType);
storageLocationBase.setValue(eStorageLocationValue);
List<StorageLocationBase> storageLocations = new ArrayList<>(2);
storageLocations.add(storageLocationBase);
storageLocations.add(templatedStorageLocationBase);
ConfigQueryEntry cqe = new ConfigQueryEntry();
cqe.setType(CloudStorageCdpService.DEFAULT_FS);
cqe.setDefaultPath(templatedStorageLocationBaseValue + CLUSTER_NAME);
CloudStorageRequest request = new CloudStorageRequest();
request.setLocations(storageLocations);
SdxClusterResponse sdxReponse = new SdxClusterResponse();
String storageLocationValue = eStorageLocationValue;
sdxReponse.setCloudStorageBaseLocation(storageLocationValue);
sdxReponse.setCloudStorageFileSystemType(FileSystemType.S3);
ConfigQueryEntry cqeFlink = new ConfigQueryEntry();
cqeFlink.setType(CloudStorageCdpService.FLINK_JOBMANAGER_ARCHIVE);
cqeFlink.setDefaultPath(storageLocationValue);
Set<ConfigQueryEntry> cqes = new LinkedHashSet<>(1);
cqes.add(cqe);
cqes.add(cqeFlink);
when(blueprintService.queryFileSystemParameters(BLUEPRINT_NAME, CLUSTER_NAME, storageLocationValue, FileSystemType.S3.name(), "", true, false, 0L)).thenReturn(cqes);
Pair<Blueprint, String> mockBt = mock(Pair.class);
when(blueprintService.getBlueprintAndText(BLUEPRINT_NAME, 0L)).thenReturn(mockBt);
FileSystemConfigQueryObject mockfscqo = mock(FileSystemConfigQueryObject.class);
when(blueprintService.createFileSystemConfigQueryObject(mockBt, CLUSTER_NAME, sdxReponse.getCloudStorageBaseLocation(), sdxReponse.getCloudStorageFileSystemType().name(), "", true, false)).thenReturn(mockfscqo);
when(cmCloudStorageConfigProvider.queryParameters(any(), eq(mockfscqo))).thenReturn(cqes);
CloudStorageRequest result = underTest.updateCloudStorageLocations(BLUEPRINT_NAME, CLUSTER_NAME, request, List.of(sdxReponse));
assertNotNull(result);
assertEquals(0, result.getLocations().stream().filter(slb -> slb.getValue().contains("{{{") && slb.getValue().contains("}}}")).count());
}
Aggregations