Search in sources :

Example 1 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentModificationServiceTest method testChangeTelemetryFeaturesByEnvironmentName.

@Test
public void testChangeTelemetryFeaturesByEnvironmentName() {
    String accountId = "myAccountId";
    String envName = "myEnvName";
    EnvironmentFeatures featuresInput = new EnvironmentFeatures();
    featuresInput.addClusterLogsCollection(true);
    Environment environment = new Environment();
    environment.setTelemetry(new EnvironmentTelemetry());
    when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(envName, accountId)).thenReturn(Optional.of(environment));
    when(environmentService.save(environment)).thenReturn(environment);
    when(environmentDtoConverter.environmentToDto(environment)).thenReturn(new EnvironmentDto());
    environmentModificationServiceUnderTest.changeTelemetryFeaturesByEnvironmentName(accountId, envName, featuresInput);
    verify(environmentService).save(any());
    assertTrue(environment.getTelemetry().getFeatures().getClusterLogsCollection().isEnabled());
}
Also used : EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures) Test(org.junit.jupiter.api.Test)

Example 2 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class TelemetryApiConverterTest method testConvertToRequestWithFeatures.

@Test
public void testConvertToRequestWithFeatures() {
    // GIVEN
    EnvironmentLogging logging = new EnvironmentLogging();
    S3CloudStorageParameters s3Params = new S3CloudStorageParameters();
    s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE);
    logging.setS3(s3Params);
    EnvironmentFeatures features = new EnvironmentFeatures();
    features.addClusterLogsCollection(false);
    features.addMonitoring(true);
    EnvironmentTelemetry telemetry = new EnvironmentTelemetry();
    telemetry.setLogging(logging);
    telemetry.setFeatures(features);
    // WHEN
    TelemetryRequest result = underTest.convertToRequest(telemetry);
    // THEN
    assertNotNull(result.getFeatures());
    assertFalse(result.getFeatures().getClusterLogsCollection().isEnabled());
    assertTrue(result.getFeatures().getMonitoring().isEnabled());
    assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile());
}
Also used : EnvironmentLogging(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentLogging) EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) TelemetryRequest(com.sequenceiq.common.api.telemetry.request.TelemetryRequest) S3CloudStorageParameters(com.sequenceiq.environment.environment.dto.telemetry.S3CloudStorageParameters) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures) Test(org.junit.jupiter.api.Test)

Example 3 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentController method changeTelemetryFeaturesByEnvironmentCrn.

@Override
@CheckPermissionByResourceCrn(action = AuthorizationResourceAction.EDIT_ENVIRONMENT)
public DetailedEnvironmentResponse changeTelemetryFeaturesByEnvironmentCrn(@ValidCrn(resource = CrnResourceDescriptor.ENVIRONMENT) @ResourceCrn String crn, @Valid FeaturesRequest request) {
    String accountId = ThreadBasedUserCrnProvider.getAccountId();
    EnvironmentFeatures features = environmentApiConverter.convertToEnvironmentTelemetryFeatures(request);
    EnvironmentDto result = environmentModificationService.changeTelemetryFeaturesByEnvironmentCrn(accountId, crn, features);
    return environmentResponseConverter.dtoToDetailedResponse(result);
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures) CheckPermissionByResourceCrn(com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)

Example 4 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class TelemetryApiConverter method createEnvironmentFeaturesFromRequest.

private EnvironmentFeatures createEnvironmentFeaturesFromRequest(FeaturesRequest featuresRequest, Features accountFeatures, String accountId) {
    EnvironmentFeatures features = null;
    boolean cdpSaas = entitlementService.isCdpSaasEnabled(accountId);
    if (featuresRequest != null) {
        features = new EnvironmentFeatures();
        if (useSharedAltusCredential) {
            features.addUseSharedAltusredential(true);
        }
        setClusterLogsCollectionFromAccountAndRequest(featuresRequest, accountFeatures, features);
        setMonitoringFromAccountAndRequest(featuresRequest, accountFeatures, features, cdpSaas);
        setCloudStorageLoggingFromAccountAndRequest(featuresRequest, accountFeatures, features);
        if (accountFeatures.getWorkloadAnalytics() != null) {
            features.setWorkloadAnalytics(accountFeatures.getWorkloadAnalytics());
        }
        if (featuresRequest.getWorkloadAnalytics() != null) {
            features.setWorkloadAnalytics(featuresRequest.getWorkloadAnalytics());
        }
    }
    return features;
}
Also used : EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)

Example 5 with EnvironmentFeatures

use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures in project cloudbreak by hortonworks.

the class EnvironmentModificationServiceTest method testChangeTelemetryFeaturesByEnvironmentCrn.

@Test
public void testChangeTelemetryFeaturesByEnvironmentCrn() {
    String accountId = "myAccountId";
    String envCrn = "myEnvCrn";
    EnvironmentFeatures featuresInput = new EnvironmentFeatures();
    featuresInput.addCloudStorageLogging(false);
    featuresInput.addClusterLogsCollection(true);
    Environment environment = new Environment();
    environment.setTelemetry(new EnvironmentTelemetry());
    when(environmentService.findByResourceCrnAndAccountIdAndArchivedIsFalse(envCrn, accountId)).thenReturn(Optional.of(environment));
    when(environmentService.save(environment)).thenReturn(environment);
    when(environmentDtoConverter.environmentToDto(environment)).thenReturn(new EnvironmentDto());
    environmentModificationServiceUnderTest.changeTelemetryFeaturesByEnvironmentCrn(accountId, envCrn, featuresInput);
    verify(environmentService).save(any());
    assertFalse(environment.getTelemetry().getFeatures().getCloudStorageLogging().isEnabled());
    assertTrue(environment.getTelemetry().getFeatures().getClusterLogsCollection().isEnabled());
}
Also used : EnvironmentTelemetry(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) Environment(com.sequenceiq.environment.environment.domain.Environment) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EnvironmentFeatures(com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentFeatures (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentFeatures)10 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 Test (org.junit.jupiter.api.Test)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)1 CheckPermissionByResourceCrn (com.sequenceiq.authorization.annotation.CheckPermissionByResourceCrn)1 CheckPermissionByResourceName (com.sequenceiq.authorization.annotation.CheckPermissionByResourceName)1 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)1 EnvironmentLogging (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentLogging)1 S3CloudStorageParameters (com.sequenceiq.environment.environment.dto.telemetry.S3CloudStorageParameters)1