Search in sources :

Example 36 with SdxClusterResponse

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

the class SdxController method getDetailByCrn.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_DETAILED_DATALAKE)
public SdxClusterDetailResponse getDetailByCrn(@TenantAwareParam @ResourceCrn String clusterCrn, Set<String> entries) {
    SdxCluster sdxCluster = getSdxClusterByCrn(clusterCrn);
    StackV4Response stackV4Response = sdxService.getDetail(sdxCluster.getClusterName(), entries, sdxCluster.getAccountId());
    SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
    return SdxClusterDetailResponse.create(sdxClusterResponse, stackV4Response);
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 37 with SdxClusterResponse

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

the class SdxController method getDetail.

@Override
@CheckPermissionByResourceName(action = AuthorizationResourceAction.DESCRIBE_DETAILED_DATALAKE)
public SdxClusterDetailResponse getDetail(@ResourceName String name, Set<String> entries) {
    SdxCluster sdxCluster = getSdxClusterByName(name);
    StackV4Response stackV4Response = sdxService.getDetail(name, entries, sdxCluster.getAccountId());
    SdxClusterResponse sdxClusterResponse = sdxClusterConverter.sdxClusterToResponse(sdxCluster);
    return SdxClusterDetailResponse.create(sdxClusterResponse, stackV4Response);
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) CheckPermissionByResourceName(com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)

Example 38 with SdxClusterResponse

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

the class SdxPollerServiceTest method testGetExecuteSdxOperationsAndGetCrnsWhenShouldSkipTheConsumer.

@Test
public void testGetExecuteSdxOperationsAndGetCrnsWhenShouldSkipTheConsumer() {
    SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
    sdxClusterResponse.setStatus(SdxClusterStatusResponse.STOPPED);
    when(sdxService.list(ENV_NAME)).thenReturn(List.of(sdxClusterResponse));
    List<String> actual = underTest.getExecuteSdxOperationsAndGetCrns(ENV_NAME, consumer, Set.of(SdxClusterStatusResponse.STOPPED));
    verify(consumer, never()).accept(any());
    Assertions.assertEquals(1, actual.size());
}
Also used : SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.jupiter.api.Test)

Example 39 with SdxClusterResponse

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

Example 40 with SdxClusterResponse

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

the class TelemetryConverterTest method testConvertFromEnvAndSdxResponseWithWADisabled.

@Test
public void testConvertFromEnvAndSdxResponseWithWADisabled() {
    // GIVEN
    TelemetryResponse response = new TelemetryResponse();
    SdxClusterResponse sdxClusterResponse = new SdxClusterResponse();
    sdxClusterResponse.setCrn("crn:cdp:cloudbreak:us-west-1:someone:sdxcluster:sdxId");
    sdxClusterResponse.setName("sdxName");
    FeaturesResponse featuresResponse = new FeaturesResponse();
    featuresResponse.addWorkloadAnalytics(false);
    response.setFeatures(featuresResponse);
    // WHEN
    TelemetryRequest result = underTest.convert(response, sdxClusterResponse);
    // THEN
    assertNull(result.getWorkloadAnalytics());
    assertFalse(result.getFeatures().getWorkloadAnalytics().isEnabled());
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) FeaturesResponse(com.sequenceiq.common.api.telemetry.response.FeaturesResponse) SdxClusterResponse(com.sequenceiq.sdx.api.model.SdxClusterResponse) Test(org.junit.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