use of com.sequenceiq.common.model.CloudStorageCdpService in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testUpdateCloudStorageLocationsWhenRequestContainsTemplatedLocationThenItShouldBeReplaced.
@Test
void testUpdateCloudStorageLocationsWhenRequestContainsTemplatedLocationThenItShouldBeReplaced() {
CloudStorageCdpService storageLocationType = CloudStorageCdpService.DEFAULT_FS;
String eStorageLocationValue = "s3a://some-dir/some-other-dir/{{{clusterName}}}";
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(storageLocationType);
storageLocationBase.setValue(eStorageLocationValue);
List<StorageLocationBase> storageLocations = new ArrayList<>(1);
storageLocations.add(storageLocationBase);
CloudStorageRequest request = new CloudStorageRequest();
request.setLocations(storageLocations);
SdxClusterResponse sdxResponse = new SdxClusterResponse();
String storageLocationValue = "s3a://some-dir/some-other-dir/" + CLUSTER_NAME;
sdxResponse.setCloudStorageBaseLocation(storageLocationValue);
sdxResponse.setCloudStorageFileSystemType(FileSystemType.S3);
ConfigQueryEntry cqe = new ConfigQueryEntry();
cqe.setType(CloudStorageCdpService.DEFAULT_FS);
cqe.setDefaultPath(storageLocationValue);
Set<ConfigQueryEntry> cqes = new LinkedHashSet<>(1);
cqes.add(cqe);
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, sdxResponse.getCloudStorageBaseLocation(), sdxResponse.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(sdxResponse));
assertNotNull(result);
assertEquals(0, result.getLocations().stream().filter(slb -> slb.getValue().contains("{{{") && slb.getValue().contains("}}}")).count());
}
use of com.sequenceiq.common.model.CloudStorageCdpService in project cloudbreak by hortonworks.
the class CloudStorageDecorator method updateCloudStorageLocations.
public CloudStorageRequest updateCloudStorageLocations(String blueprintName, String clusterName, CloudStorageRequest request, List<SdxClusterResponse> datalakes) {
if (hasDatalake(datalakes)) {
Pair<String, FileSystemType> sdxBaseLocationFileSystemType = getBaseLocationWithFileSystemTypeFromSdx(datalakes.get(0));
Set<ConfigQueryEntry> recommendations = getRecommendations(blueprintName, clusterName, sdxBaseLocationFileSystemType);
if (storageLocationsNotDefined(request)) {
if (request == null) {
request = new CloudStorageRequest();
}
if (request.getLocations() == null) {
request.setLocations(new ArrayList<>());
}
for (ConfigQueryEntry recommendation : recommendations) {
request.getLocations().add(createStorageLocationBaseByTypeAndDefaultPath(recommendation.getType(), recommendation.getDefaultPath()));
}
} else {
Map<CloudStorageCdpService, String> templatedLocations = findLocationsThatContainsTemplatedValue(request);
if (!templatedLocations.isEmpty()) {
LOGGER.info("Cloud storage location(s) has found with template placeholder(s). About to replace them with the recommended one(s).");
Set<ConfigQueryEntry> filtered = filterConfigsWithTemplatePlaceholder(request, recommendations);
Set<ConfigQueryEntry> replaced = queryParameters(filtered, blueprintName, clusterName, sdxBaseLocationFileSystemType);
replaceTemplatedLocationValuesWithFilledValues(request, replaced, templatedLocations);
}
}
}
return request;
}
use of com.sequenceiq.common.model.CloudStorageCdpService in project cloudbreak by hortonworks.
the class AzureIDBrokerObjectStorageValidatorTest method getStorageLocation.
private List<StorageLocationBase> getStorageLocation() {
CloudStorageCdpService eStorageLocationType = CloudStorageCdpService.RANGER_AUDIT;
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(eStorageLocationType);
storageLocationBase.setValue(STORAGE_LOCATION_RANGER);
return List.of(storageLocationBase);
}
use of com.sequenceiq.common.model.CloudStorageCdpService in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testConvertWhenRequestHasNotCloudStorageLocationsAndSdxHasShouldTheSdxOnesBeUsed.
@Test
void testConvertWhenRequestHasNotCloudStorageLocationsAndSdxHasShouldTheSdxOnesBeUsed() {
CloudStorageCdpService storageLocationType = CloudStorageCdpService.RANGER_AUDIT;
SdxClusterResponse sdxReponse = new SdxClusterResponse();
String storageLocationValue = "MYBUCKET/CONTAINER2";
sdxReponse.setCloudStorageBaseLocation(storageLocationValue);
sdxReponse.setCloudStorageFileSystemType(FileSystemType.S3);
when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(List.of(sdxReponse));
ConfigQueryEntry sdxConfigQueryEntry = new ConfigQueryEntry();
sdxConfigQueryEntry.setType(storageLocationType);
sdxConfigQueryEntry.setDefaultPath(storageLocationValue);
when(blueprintService.queryFileSystemParameters(any(), any(), any(), any(), any(), eq(Boolean.TRUE), eq(Boolean.FALSE), eq(0L))).thenReturn(Set.of(sdxConfigQueryEntry));
CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, null, new DetailedEnvironmentResponse());
assertNotNull(result);
assertTrue(result.getLocations().stream().anyMatch(loc -> storageLocationType.equals(loc.getType()) && storageLocationValue.equals(loc.getValue())));
}
use of com.sequenceiq.common.model.CloudStorageCdpService 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())));
}
Aggregations