use of com.sequenceiq.sdx.api.model.SdxClusterResponse 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.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.
the class CloudStorageDecorator method decorate.
public CloudStorageRequest decorate(String blueprintName, String clusterName, CloudStorageRequest request, DetailedEnvironmentResponse environment) {
if (environment != null) {
if (request == null) {
request = new CloudStorageRequest();
}
TelemetryResponse telemetry = environment.getTelemetry();
if (telemetry != null && telemetry.getLogging() != null) {
LoggingResponse logging = telemetry.getLogging();
StorageIdentityBase identity = new StorageIdentityBase();
identity.setType(CloudIdentityType.LOG);
identity.setS3(logging.getS3());
identity.setAdlsGen2(logging.getAdlsGen2());
identity.setGcs(logging.getGcs());
List<StorageIdentityBase> identities = request.getIdentities();
if (identities == null) {
identities = new ArrayList<>();
}
boolean logConfiguredInRequest = false;
for (StorageIdentityBase identityBase : identities) {
if (CloudIdentityType.LOG.equals(identityBase.getType())) {
logConfiguredInRequest = true;
}
}
if (!logConfiguredInRequest) {
identities.add(identity);
}
request.setIdentities(identities);
}
List<SdxClusterResponse> datalakes = sdxClientService.getByEnvironmentCrn(environment.getCrn());
updateCloudStorageLocations(blueprintName, clusterName, request, datalakes);
updateDynamoDBTable(request, environment);
}
return request;
}
use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.
the class ClusterCreationEnvironmentValidatorTest method testValidateShouldBeSuccessWhenNoEnvironmentProvided.
@Test
void testValidateShouldBeSuccessWhenNoEnvironmentProvided() {
// GIVEN
Stack stack = getStack();
stack.setEnvironmentCrn(null);
DetailedEnvironmentResponse environment = getEnvironmentResponse();
when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(Arrays.asList(new SdxClusterResponse()));
ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder();
// WHEN
underTest.validate(stack, environment, true, validationBuilder);
// THEN
ValidationResult actualResult = validationBuilder.build();
assertFalse(actualResult.hasError());
}
use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.
the class ClusterCreationEnvironmentValidatorTest method testValidateShouldBeSuccessWhenStackRegionIsRegionDisplayNameAndEnvironmentsRegionsAreDisplayNames.
@Test
void testValidateShouldBeSuccessWhenStackRegionIsRegionDisplayNameAndEnvironmentsRegionsAreDisplayNames() {
// GIVEN
String westUs2RegionName = "westus2";
String westUs2RegionDisplayName = "West US 2";
Stack stack = getStack();
stack.setRegion(westUs2RegionDisplayName);
DetailedEnvironmentResponse environment = getEnvironmentResponse();
CompactRegionResponse regions = new CompactRegionResponse();
regions.getNames().add(westUs2RegionDisplayName);
regions.getNames().add("West US");
environment.setRegions(regions);
when(connector.displayNameToRegion(any())).thenReturn(westUs2RegionName);
when(connector.regionToDisplayName(any())).thenReturn(westUs2RegionDisplayName);
when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(Arrays.asList(new SdxClusterResponse()));
ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder();
// WHEN
underTest.validate(stack, environment, true, validationBuilder);
// THEN
ValidationResult actualResult = validationBuilder.build();
assertFalse(actualResult.hasError());
}
use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.
the class ClusterCreationEnvironmentValidatorTest method testValidateShouldBeSuccessWhenStackRegionIsValidAndEnvironmentsResourcesAreNotGiven.
@Test
void testValidateShouldBeSuccessWhenStackRegionIsValidAndEnvironmentsResourcesAreNotGiven() {
// GIVEN
Stack stack = getStack();
DetailedEnvironmentResponse environment = getEnvironmentResponse();
when(sdxClientService.getByEnvironmentCrn(any())).thenReturn(Arrays.asList(new SdxClusterResponse()));
ValidationResult.ValidationResultBuilder validationBuilder = ValidationResult.builder();
// WHEN
underTest.validate(stack, environment, true, validationBuilder);
// THEN
ValidationResult actualResult = validationBuilder.build();
assertFalse(actualResult.hasError());
}
Aggregations