use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest in project cloudbreak by hortonworks.
the class StackV4RequestToTemplatePreparationObjectConverterTest method testConvertWhenClusterHasCloudStorageThenConvertedFileSystemShouldBeStoredComingFromFileSystemConfigurationProvider.
@Test
public void testConvertWhenClusterHasCloudStorageThenConvertedFileSystemShouldBeStoredComingFromFileSystemConfigurationProvider() throws IOException {
BaseFileSystemConfigurationsView expected = mock(BaseFileSystemConfigurationsView.class);
CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
FileSystem fileSystem = new FileSystem();
ConfigQueryEntries configQueryEntries = new ConfigQueryEntries();
when(cloudStorageValidationUtil.isCloudStorageConfigured(cloudStorageRequest)).thenReturn(true);
when(cluster.getCloudStorage()).thenReturn(cloudStorageRequest);
when(cloudStorageConverter.requestToFileSystem(cloudStorageRequest)).thenReturn(fileSystem);
when(cmCloudStorageConfigProvider.getConfigQueryEntries()).thenReturn(configQueryEntries);
when(fileSystemConfigurationProvider.fileSystemConfiguration(fileSystem, source, credential.getAttributes(), configQueryEntries)).thenReturn(expected);
TemplatePreparationObject result = underTest.convert(source);
assertTrue(result.getFileSystemConfigurationView().isPresent());
assertEquals(expected, result.getFileSystemConfigurationView().get());
}
use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest in project cloudbreak by hortonworks.
the class DistroXClusterToClusterConverterTest method testConvertWithoutEnvTheCloudStorageShouldBeSetBasedOnTheInputs.
@Test
void testConvertWithoutEnvTheCloudStorageShouldBeSetBasedOnTheInputs() {
CloudStorageRequest decoratorResult = new CloudStorageRequest();
when(cloudStorageDecorator.decorate(distroXV1RequestInput.getCluster().getBlueprintName(), distroXV1RequestInput.getName(), distroXV1RequestInput.getCluster().getCloudStorage(), null)).thenReturn(decoratorResult);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ClusterV4Request result = testConvertDistroXV1Request();
assertNotNull(result);
assertEquals(decoratorResult, result.getCloudStorage());
verify(cloudStorageDecorator, times(1)).decorate(any(), any(), any(), any());
verify(cloudStorageDecorator, times(1)).decorate(distroXV1RequestInput.getCluster().getBlueprintName(), distroXV1RequestInput.getName(), distroXV1RequestInput.getCluster().getCloudStorage(), null);
}
use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest in project cloudbreak by hortonworks.
the class DistroXClusterToClusterConverterTest method testConvertWithEnvTheCloudStorageShouldBeSetBasedOnTheInputs.
@Test
void testConvertWithEnvTheCloudStorageShouldBeSetBasedOnTheInputs() {
CloudStorageRequest decoratorResult = new CloudStorageRequest();
when(cloudStorageDecorator.decorate(distroXV1RequestInput.getCluster().getBlueprintName(), distroXV1RequestInput.getName(), distroXV1RequestInput.getCluster().getCloudStorage(), env)).thenReturn(decoratorResult);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ClusterV4Request result = testConvertDistroXV1RequestWithEnvironment();
assertNotNull(result);
assertEquals(decoratorResult, result.getCloudStorage());
verify(cloudStorageDecorator, times(1)).decorate(any(), any(), any(), any());
verify(cloudStorageDecorator, times(1)).decorate(distroXV1RequestInput.getCluster().getBlueprintName(), distroXV1RequestInput.getName(), distroXV1RequestInput.getCluster().getCloudStorage(), env);
}
use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest in project cloudbreak by hortonworks.
the class CloudStorageDecoratorTest method testConvertWhenCloudStorageLocationsIsNullAndEnvironmentHasTelemetryWithLogging.
@Test
void testConvertWhenCloudStorageLocationsIsNullAndEnvironmentHasTelemetryWithLogging() {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
TelemetryResponse telemetry = new TelemetryResponse();
telemetry.setLogging(new LoggingResponse());
environment.setTelemetry(telemetry);
CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, null, environment);
assertNotNull(result);
assertTrue(result.getIdentities().stream().anyMatch(id -> CloudIdentityType.LOG.equals(id.getType())));
}
use of com.sequenceiq.common.api.cloudstorage.CloudStorageRequest 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());
}
Aggregations