Search in sources :

Example 21 with SdxClusterResponse

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());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ConfigQueryEntry(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) ArrayList(java.util.ArrayList) FileSystemConfigQueryObject(com.sequenceiq.cloudbreak.template.filesystem.FileSystemConfigQueryObject) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 22 with SdxClusterResponse

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;
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) StorageIdentityBase(com.sequenceiq.common.api.cloudstorage.StorageIdentityBase)

Example 23 with SdxClusterResponse

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());
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with SdxClusterResponse

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());
}
Also used : CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with SdxClusterResponse

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());
}
Also used : DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)54 Test (org.junit.jupiter.api.Test)22 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)10 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)8 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)8 Test (org.junit.Test)8 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)7 ArrayList (java.util.ArrayList)7 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)5 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 SdxClientService (com.sequenceiq.cloudbreak.service.datalake.SdxClientService)4 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)4 CompactRegionResponse (com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse)4 Set (java.util.Set)4 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)3 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)3