Search in sources :

Example 36 with SdxClusterRequest

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

the class CloudStorageManifesterTest method whenCloudStorageEnabledFromInternalRequestWithLogging.

@Test
public void whenCloudStorageEnabledFromInternalRequestWithLogging() {
    ClusterV4Request clusterV4Request = new ClusterV4Request();
    clusterV4Request.setBlueprintName(exampleBlueprintName);
    CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
    StorageLocationBase storageLocationBase = new StorageLocationBase();
    storageLocationBase.setType(CloudStorageCdpService.RANGER_AUDIT);
    storageLocationBase.setValue("s3a://ranger-audit");
    cloudStorageRequest.setLocations(List.of(storageLocationBase));
    clusterV4Request.setCloudStorage(cloudStorageRequest);
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    environment.setCloudPlatform("AWS");
    TelemetryResponse telemetryResponse = new TelemetryResponse();
    LoggingResponse loggingResponse = new LoggingResponse();
    S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
    s3CloudStorageV1Parameters.setInstanceProfile("logprofile");
    loggingResponse.setS3(s3CloudStorageV1Parameters);
    telemetryResponse.setLogging(loggingResponse);
    environment.setTelemetry(telemetryResponse);
    CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, null, new SdxClusterRequest());
    assertEquals(CloudStorageCdpService.RANGER_AUDIT, cloudStorageConfigReq.getLocations().get(0).getType());
    assertEquals(CloudIdentityType.LOG, cloudStorageConfigReq.getIdentities().get(0).getType());
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) SdxCloudStorageRequest(com.sequenceiq.sdx.api.model.SdxCloudStorageRequest) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) S3CloudStorageV1Parameters(com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 37 with SdxClusterRequest

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

the class SdxControllerTest method createTest.

@Test
void createTest() {
    SdxCluster sdxCluster = getValidSdxCluster();
    when(sdxService.createSdx(anyString(), anyString(), any(SdxClusterRequest.class), nullable(StackV4Request.class))).thenReturn(Pair.of(sdxCluster, new FlowIdentifier(FlowType.FLOW, "FLOW_ID")));
    SdxClusterRequest createSdxClusterRequest = new SdxClusterRequest();
    createSdxClusterRequest.setClusterShape(SdxClusterShape.MEDIUM_DUTY_HA);
    createSdxClusterRequest.setEnvironment("test-env");
    Map<String, String> tags = new HashMap<>();
    tags.put("tag1", "value1");
    createSdxClusterRequest.addTags(tags);
    SdxStatusEntity sdxStatusEntity = new SdxStatusEntity();
    sdxStatusEntity.setStatus(DatalakeStatusEnum.REQUESTED);
    sdxStatusEntity.setStatusReason("statusreason");
    sdxStatusEntity.setCreated(1L);
    when(sdxStatusService.getActualStatusForSdx(sdxCluster)).thenReturn(sdxStatusEntity);
    ReflectionTestUtils.setField(sdxClusterConverter, "sdxStatusService", sdxStatusService);
    SdxClusterResponse sdxClusterResponse = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> sdxController.create(SDX_CLUSTER_NAME, createSdxClusterRequest));
    verify(sdxService).createSdx(eq(USER_CRN), eq(SDX_CLUSTER_NAME), eq(createSdxClusterRequest), nullable(StackV4Request.class));
    verify(sdxStatusService, times(1)).getActualStatusForSdx(sdxCluster);
    assertEquals(SDX_CLUSTER_NAME, sdxClusterResponse.getName());
    assertEquals("test-env", sdxClusterResponse.getEnvironmentName());
    assertEquals("crn:sdxcluster", sdxClusterResponse.getCrn());
    assertEquals(SdxClusterStatusResponse.REQUESTED, sdxClusterResponse.getStatus());
    assertEquals("statusreason", sdxClusterResponse.getStatusReason());
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) HashMap(java.util.HashMap) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxClusterRequest(com.sequenceiq.sdx.api.model.SdxClusterRequest) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.jupiter.api.Test)

Aggregations

SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)37 Test (org.junit.jupiter.api.Test)26 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)20 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)17 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)16 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)14 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)13 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)11 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)10 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)10 MethodSource (org.junit.jupiter.params.provider.MethodSource)10 Supplier (java.util.function.Supplier)9 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)8 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)7 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)7 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)5 RegionAwareInternalCrnGenerator (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGenerator)5 RegionAwareInternalCrnGeneratorFactory (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory)5 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)5