Search in sources :

Example 11 with TelemetryResponse

use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.

the class EnvironmentResponseConverterTest method testDtoToSimpleResponse.

@ParameterizedTest
@EnumSource(value = CloudPlatform.class, names = { "AWS", "AZURE" })
void testDtoToSimpleResponse(CloudPlatform cloudPlatform) {
    EnvironmentDto environmentDto = createEnvironmentDto(cloudPlatform);
    CredentialViewResponse credentialResponse = mock(CredentialViewResponse.class);
    FreeIpaResponse freeIpaResponse = mock(FreeIpaResponse.class);
    CompactRegionResponse compactRegionResponse = mock(CompactRegionResponse.class);
    TelemetryResponse telemetryResponse = mock(TelemetryResponse.class);
    ProxyViewResponse proxyResponse = mock(ProxyViewResponse.class);
    EnvironmentNetworkResponse environmentNetworkResponse = mock(EnvironmentNetworkResponse.class);
    when(credentialViewConverter.convertResponse(environmentDto.getCredential())).thenReturn(credentialResponse);
    when(freeIpaConverter.convert(environmentDto.getFreeIpaCreation())).thenReturn(freeIpaResponse);
    when(regionConverter.convertRegions(environmentDto.getRegions())).thenReturn(compactRegionResponse);
    when(telemetryApiConverter.convert(environmentDto.getTelemetry())).thenReturn(telemetryResponse);
    when(proxyConfigToProxyResponseConverter.convertToView(environmentDto.getProxyConfig())).thenReturn(proxyResponse);
    when(networkDtoToResponseConverter.convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false)).thenReturn(environmentNetworkResponse);
    SimpleEnvironmentResponse actual = underTest.dtoToSimpleResponse(environmentDto, true, true);
    assertEquals(environmentDto.getResourceCrn(), actual.getCrn());
    assertEquals(environmentDto.getName(), actual.getName());
    assertEquals(environmentDto.getOriginalName(), actual.getOriginalName());
    assertEquals(environmentDto.getDescription(), actual.getDescription());
    assertEquals(environmentDto.getCloudPlatform(), actual.getCloudPlatform());
    assertEquals(credentialResponse, actual.getCredential());
    assertEquals(environmentDto.getStatus().getResponseStatus(), actual.getEnvironmentStatus());
    assertEquals(environmentDto.getCreator(), actual.getCreator());
    assertLocation(environmentDto.getLocation(), actual.getLocation());
    assertTrue(actual.getCreateFreeIpa());
    assertEquals(freeIpaResponse, actual.getFreeIpa());
    assertEquals(environmentDto.getStatusReason(), actual.getStatusReason());
    assertEquals(environmentDto.getCreated(), actual.getCreated());
    assertEquals(environmentDto.getExperimentalFeatures().getTunnel(), actual.getTunnel());
    assertEquals(environmentDto.getExperimentalFeatures().getCcmV2TlsType(), actual.getCcmV2TlsType());
    assertEquals(environmentDto.getAdminGroupName(), actual.getAdminGroupName());
    assertEquals(environmentDto.getTags().getUserDefinedTags(), actual.getTags().getUserDefined());
    assertEquals(environmentDto.getTags().getDefaultTags(), actual.getTags().getDefaults());
    assertEquals(telemetryResponse, actual.getTelemetry());
    assertEquals(compactRegionResponse, actual.getRegions());
    assertParameters(environmentDto, actual, cloudPlatform);
    assertEquals(environmentDto.getParentEnvironmentName(), actual.getParentEnvironmentName());
    assertEquals(proxyResponse, actual.getProxyConfig());
    assertEquals(environmentNetworkResponse, actual.getNetwork());
    verify(credentialViewConverter).convertResponse(environmentDto.getCredential());
    verify(freeIpaConverter).convert(environmentDto.getFreeIpaCreation());
    verify(regionConverter).convertRegions(environmentDto.getRegions());
    verify(telemetryApiConverter).convert(environmentDto.getTelemetry());
    verify(proxyConfigToProxyResponseConverter).convertToView(environmentDto.getProxyConfig());
    verify(networkDtoToResponseConverter).convert(environmentDto.getNetwork(), environmentDto.getExperimentalFeatures().getTunnel(), false);
}
Also used : CredentialViewResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialViewResponse) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) CompactRegionResponse(com.sequenceiq.environment.api.v1.environment.model.response.CompactRegionResponse) ProxyViewResponse(com.sequenceiq.environment.api.v1.proxy.model.response.ProxyViewResponse) SimpleEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) FreeIpaResponse(com.sequenceiq.environment.api.v1.environment.model.response.FreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with TelemetryResponse

use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.

the class TelemetryApiConverterTest method testConvertToResponse.

@Test
public void testConvertToResponse() {
    // GIVEN
    EnvironmentLogging logging = new EnvironmentLogging();
    S3CloudStorageParameters s3Params = new S3CloudStorageParameters();
    s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE);
    logging.setS3(s3Params);
    EnvironmentTelemetry telemetry = new EnvironmentTelemetry();
    telemetry.setLogging(logging);
    // WHEN
    TelemetryResponse result = underTest.convert(telemetry);
    // THEN
    assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile());
    assertNull(result.getWorkloadAnalytics());
}
Also used : EnvironmentLogging(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentLogging) TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) S3CloudStorageParameters(com.sequenceiq.environment.environment.dto.telemetry.S3CloudStorageParameters) Test(org.junit.jupiter.api.Test)

Example 13 with TelemetryResponse

use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse in project cloudbreak by hortonworks.

the class TelemetryApiConverter method convert.

public TelemetryResponse convert(EnvironmentTelemetry telemetry) {
    TelemetryResponse response = null;
    if (telemetry != null) {
        response = new TelemetryResponse();
        response.setLogging(createLoggingResponseFromSource(telemetry.getLogging()));
        response.setMonitoring(createMonitoringResponseFromSource(telemetry.getMonitoring()));
        response.setWorkloadAnalytics(createWorkloadAnalyticsResponseFromSource(telemetry.getWorkloadAnalytics()));
        response.setFluentAttributes(telemetry.getFluentAttributes());
        response.setFeatures(createFeaturesResponseFromSource(telemetry.getFeatures()));
        response.setFluentAttributes(telemetry.getFluentAttributes());
    }
    return response;
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse)

Example 14 with TelemetryResponse

use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse 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())));
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) 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) CloudStorageRequest(com.sequenceiq.common.api.cloudstorage.CloudStorageRequest) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) Test(org.junit.jupiter.api.Test)

Example 15 with TelemetryResponse

use of com.sequenceiq.common.api.telemetry.response.TelemetryResponse 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)

Aggregations

TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)45 LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)17 Test (org.junit.jupiter.api.Test)17 Test (org.junit.Test)16 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)14 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)10 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)10 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)9 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)8 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)8 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)8 ArrayList (java.util.ArrayList)8 FeaturesResponse (com.sequenceiq.common.api.telemetry.response.FeaturesResponse)7 CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)7 CloudStorageCdpService (com.sequenceiq.common.model.CloudStorageCdpService)7 FileSystemType (com.sequenceiq.common.model.FileSystemType)7 List (java.util.List)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Assertions.assertNull (org.junit.jupiter.api.Assertions.assertNull)7 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)7