Search in sources :

Example 41 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class TelemetryConverterTest method testConvertFromEnvAndSdxResponseWithWADisabledGlobally.

@Test
public void testConvertFromEnvAndSdxResponseWithWADisabledGlobally() {
    // GIVEN
    TelemetryResponse response = new TelemetryResponse();
    SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
    sdxClusterResponse.setCrn("crn:cdp:cloudbreak:us-west-1:someone:sdxcluster:sdxId");
    sdxClusterResponse.setName("sdxName");
    AltusDatabusConfiguration altusDatabusConfiguration = new AltusDatabusConfiguration(DATABUS_ENDPOINT, DATABUS_S3_BUCKET, false, "", null);
    MeteringConfiguration meteringConfiguration = new MeteringConfiguration(true, null, null);
    ClusterLogsCollectionConfiguration logCollectionConfig = new ClusterLogsCollectionConfiguration(true, null, null);
    MonitoringConfiguration monitoringConfig = new MonitoringConfiguration();
    monitoringConfig.setEnabled(true);
    TelemetryConfiguration telemetryConfiguration = new TelemetryConfiguration(altusDatabusConfiguration, meteringConfiguration, logCollectionConfig, monitoringConfig, null);
    TelemetryConverter converter = new TelemetryConverter(telemetryConfiguration, false, true);
    // WHEN
    TelemetryRequest result = converter.convert(response, sdxClusterResponse);
    // THEN
    assertNull(result.getWorkloadAnalytics());
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) MeteringConfiguration(com.sequenceiq.cloudbreak.telemetry.metering.MeteringConfiguration) TelemetryConfiguration(com.sequenceiq.cloudbreak.telemetry.TelemetryConfiguration) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) AltusDatabusConfiguration(com.sequenceiq.cloudbreak.altus.AltusDatabusConfiguration) MonitoringConfiguration(com.sequenceiq.cloudbreak.telemetry.monitoring.MonitoringConfiguration) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) ClusterLogsCollectionConfiguration(com.sequenceiq.cloudbreak.telemetry.logcollection.ClusterLogsCollectionConfiguration) Test(org.junit.Test)

Example 42 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse in project cloudbreak by hortonworks.

the class SdxConverterTest method testGetSharedServiceWhenSdxIsNotRunning.

@Test
public void testGetSharedServiceWhenSdxIsNotRunning() {
    SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
    sdxClusterResponse.setName("some-sdx");
    sdxClusterResponse.setEnvironmentName("some-env");
    sdxClusterResponse.setStatusReason("external db creation in progress");
    sdxClusterResponse.setStatus(SdxClusterStatusResponse.EXTERNAL_DATABASE_CREATION_IN_PROGRESS);
    BadRequestException exception = Assertions.assertThrows(BadRequestException.class, () -> underTest.getSharedService(sdxClusterResponse));
    Assertions.assertEquals(exception.getMessage(), "Your current Environment some-env contains one Data Lake " + "the name of which is some-sdx. This Data Lake should be in running/available state but currently it " + "is in 'EXTERNAL_DATABASE_CREATION_IN_PROGRESS' instead of Running. Please make sure your Data Lake" + " is up and running before you provision the Data Hub. If your Data Lake is in stopped state, please" + " restart it. If your Data Lake has failed to provision please check our documentation" + " https://docs.cloudera.com/management-console/cloud/data-lakes/topics/mc-data-lake.html or" + " contact the Cloudera support to get some help or try to provision a new Data Lake with the" + " correct configuration.");
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.jupiter.api.Test)

Example 43 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse 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())));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ArrayList(java.util.ArrayList) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Pair(org.apache.commons.lang3.tuple.Pair) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FileSystemConfigQueryObject(com.sequenceiq.cloudbreak.template.filesystem.FileSystemConfigQueryObject) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) LinkedHashSet(java.util.LinkedHashSet) InjectMocks(org.mockito.InjectMocks) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Test(org.junit.jupiter.api.Test) List(java.util.List) CmCloudStorageConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.cloudstorage.CmCloudStorageConfigProvider) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) FileSystemType(com.sequenceiq.common.model.FileSystemType) ConfigQueryEntry(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) CloudIdentityType(com.sequenceiq.common.model.CloudIdentityType) Mockito.mock(org.mockito.Mockito.mock) ConfigQueryEntry(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.jupiter.api.Test)

Example 44 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse 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())));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ArrayList(java.util.ArrayList) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Pair(org.apache.commons.lang3.tuple.Pair) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) FileSystemConfigQueryObject(com.sequenceiq.cloudbreak.template.filesystem.FileSystemConfigQueryObject) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) LinkedHashSet(java.util.LinkedHashSet) InjectMocks(org.mockito.InjectMocks) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Test(org.junit.jupiter.api.Test) List(java.util.List) CmCloudStorageConfigProvider(com.sequenceiq.cloudbreak.cmtemplate.cloudstorage.CmCloudStorageConfigProvider) SdxClientService(com.sequenceiq.cloudbreak.service.datalake.SdxClientService) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) FileSystemType(com.sequenceiq.common.model.FileSystemType) ConfigQueryEntry(com.sequenceiq.common.api.cloudstorage.query.ConfigQueryEntry) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) CloudIdentityType(com.sequenceiq.common.model.CloudIdentityType) Mockito.mock(org.mockito.Mockito.mock) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 45 with SdxClusterResponse

use of com.sequenceiq.sdx.api.model.SdxClusterResponse 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());
}
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)

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