Search in sources :

Example 16 with LoggingResponse

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

the class CloudStorageDecoratorTest method testConvertWhenCloudStorageLocationsIsEmptyAndEnvironmentHasTelemetryWithLogging.

@Test
void testConvertWhenCloudStorageLocationsIsEmptyAndEnvironmentHasTelemetryWithLogging() {
    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())));
    assertTrue(result.getLocations().isEmpty());
}
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 17 with LoggingResponse

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

the class CloudStorageDecoratorTest method testConvertWhenEnvironmentHaveTelemetryAndStorageLocationsIsNotNullOrEmpty.

@Test
void testConvertWhenEnvironmentHaveTelemetryAndStorageLocationsIsNotNullOrEmpty() {
    TelemetryResponse telemetry = new TelemetryResponse();
    telemetry.setLogging(new LoggingResponse());
    DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
    environment.setTelemetry(telemetry);
    CloudStorageCdpService eStorageLocationType = CloudStorageCdpService.RANGER_AUDIT;
    String eStorageLocationValue = "MYBUCKET/CONTAINER";
    StorageLocationBase storageLocationBase = new StorageLocationBase();
    storageLocationBase.setType(eStorageLocationType);
    storageLocationBase.setValue(eStorageLocationValue);
    List<StorageLocationBase> storageLocations = List.of(storageLocationBase);
    CloudStorageRequest request = new CloudStorageRequest();
    request.setLocations(storageLocations);
    CloudStorageRequest result = underTest.decorate(BLUEPRINT_NAME, CLUSTER_NAME, request, environment);
    assertNotNull(result);
    assertTrue(result.getIdentities().stream().anyMatch(id -> CloudIdentityType.LOG.equals(id.getType())));
    assertTrue(result.getLocations().stream().anyMatch(loc -> eStorageLocationType.equals(loc.getType()) && eStorageLocationValue.equals(loc.getValue())));
}
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) CloudStorageCdpService(com.sequenceiq.common.model.CloudStorageCdpService) 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) StorageLocationBase(com.sequenceiq.common.api.cloudstorage.StorageLocationBase) Test(org.junit.jupiter.api.Test)

Example 18 with LoggingResponse

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

the class TelemetryConverter method createLoggingRequestFromResponse.

private LoggingRequest createLoggingRequestFromResponse(TelemetryResponse response) {
    LoggingRequest loggingRequest = null;
    if (response.getLogging() != null) {
        LOGGER.debug("Setting logging response (telemetry) based on environment response");
        LoggingResponse loggingResponse = response.getLogging();
        loggingRequest = new LoggingRequest();
        loggingRequest.setStorageLocation(loggingResponse.getStorageLocation());
        loggingRequest.setS3(loggingResponse.getS3());
        loggingRequest.setAdlsGen2(loggingResponse.getAdlsGen2());
        loggingRequest.setGcs(loggingResponse.getGcs());
        loggingRequest.setCloudwatch(loggingResponse.getCloudwatch());
    }
    return loggingRequest;
}
Also used : LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) LoggingRequest(com.sequenceiq.common.api.telemetry.request.LoggingRequest)

Example 19 with LoggingResponse

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

the class TelemetryConverter method createLoggingResponseFromSource.

private LoggingResponse createLoggingResponseFromSource(Telemetry telemetry) {
    LoggingResponse loggingResponse = null;
    if (telemetry.getLogging() != null) {
        LOGGER.debug("Setting logging telemetry settings (response).");
        Logging logging = telemetry.getLogging();
        loggingResponse = new LoggingResponse();
        loggingResponse.setStorageLocation(logging.getStorageLocation());
        loggingResponse.setS3(logging.getS3());
        loggingResponse.setAdlsGen2(logging.getAdlsGen2());
        loggingResponse.setGcs(logging.getGcs());
        loggingResponse.setCloudwatch(CloudwatchParams.copy(logging.getCloudwatch()));
    }
    return loggingResponse;
}
Also used : Logging(com.sequenceiq.common.api.telemetry.model.Logging) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse)

Example 20 with LoggingResponse

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

the class TelemetryConverter method convert.

public TelemetryResponse convert(Telemetry telemetry) {
    TelemetryResponse response = null;
    if (telemetry != null) {
        LoggingResponse loggingResponse = createLoggingResponseFromSource(telemetry);
        MonitoringResponse monitoringResponse = createMonitoringResponseFromSource(telemetry);
        WorkloadAnalyticsResponse waResponse = createWorkloadAnalyticsResponseFromSource(telemetry);
        response = new TelemetryResponse();
        response.setLogging(loggingResponse);
        response.setMonitoring(monitoringResponse);
        response.setWorkloadAnalytics(waResponse);
        response.setFluentAttributes(telemetry.getFluentAttributes());
        response.setRules(telemetry.getRules());
        createFeaturesResponseFromSource(response, telemetry.getFeatures());
    }
    return response;
}
Also used : TelemetryResponse(com.sequenceiq.common.api.telemetry.response.TelemetryResponse) WorkloadAnalyticsResponse(com.sequenceiq.common.api.telemetry.response.WorkloadAnalyticsResponse) LoggingResponse(com.sequenceiq.common.api.telemetry.response.LoggingResponse) MonitoringResponse(com.sequenceiq.common.api.telemetry.response.MonitoringResponse)

Aggregations

LoggingResponse (com.sequenceiq.common.api.telemetry.response.LoggingResponse)22 TelemetryResponse (com.sequenceiq.common.api.telemetry.response.TelemetryResponse)17 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)12 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)10 Test (org.junit.jupiter.api.Test)10 S3CloudStorageV1Parameters (com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters)9 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)8 CloudIdentityType (com.sequenceiq.common.model.CloudIdentityType)7 CloudStorageCdpService (com.sequenceiq.common.model.CloudStorageCdpService)7 FileSystemType (com.sequenceiq.common.model.FileSystemType)7 ArrayList (java.util.ArrayList)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 InjectMocks (org.mockito.InjectMocks)7 Mock (org.mockito.Mock)7 Mockito.when (org.mockito.Mockito.when)7 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)7 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)5