use of com.sequenceiq.common.api.telemetry.response.LoggingResponse in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentityForGCS.
@Test
public void whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentityForGCS() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockFileSystemResponseForCloudbreakClient();
SdxCluster sdxCluster = new SdxCluster();
SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
sdxCluster.setInitiatorUserCrn(USER_CRN);
sdxCluster.setClusterName("sdx-cluster");
SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
cloudStorageRequest.setBaseLocation("gs://example-path");
cloudStorageRequest.setFileSystemType(FileSystemType.GCS);
GcsCloudStorageV1Parameters gcsCloudStorageV1Parameters = new GcsCloudStorageV1Parameters();
gcsCloudStorageV1Parameters.setServiceAccountEmail(EMAIL);
cloudStorageRequest.setGcs(gcsCloudStorageV1Parameters);
sdxClusterRequest.setCloudStorage(cloudStorageRequest);
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
environment.setCloudPlatform("GCP");
TelemetryResponse telemetryResponse = new TelemetryResponse();
LoggingResponse loggingResponse = new LoggingResponse();
loggingResponse.setGcs(gcsCloudStorageV1Parameters);
telemetryResponse.setLogging(loggingResponse);
GcpEnvironmentParameters gcpEnvironmentParameters = GcpEnvironmentParameters.builder().build();
environment.setGcp(gcpEnvironmentParameters);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.initCloudStorageRequest(environment, clusterV4Request, sdxCluster, sdxClusterRequest));
StorageLocationBase singleRequest = cloudStorageConfigReq.getLocations().iterator().next();
assertEquals(2, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.ID_BROKER)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals(2, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getGcs().getServiceAccountEmail().equals(EMAIL)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getLocations().size());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, singleRequest.getType());
assertEquals("ranger/example-path", singleRequest.getValue());
verify(storageValidationService).validateCloudStorage("GCP", cloudStorageRequest);
}
use of com.sequenceiq.common.api.telemetry.response.LoggingResponse in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentity.
@Test
public void whenEnvironmentHasLoggingEnabledThenShouldApplyAsLogIdentity() {
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
mockFileSystemResponseForCloudbreakClient();
SdxCluster sdxCluster = new SdxCluster();
SdxClusterRequest sdxClusterRequest = new SdxClusterRequest();
sdxCluster.setInitiatorUserCrn(USER_CRN);
sdxCluster.setClusterName("sdx-cluster");
SdxCloudStorageRequest cloudStorageRequest = new SdxCloudStorageRequest();
cloudStorageRequest.setBaseLocation("s3a://example-path");
cloudStorageRequest.setFileSystemType(FileSystemType.S3);
S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
s3Params.setInstanceProfile("instance:profile");
cloudStorageRequest.setS3(s3Params);
sdxClusterRequest.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);
AwsEnvironmentParameters awsEnvironmentParameters = new AwsEnvironmentParameters();
S3GuardRequestParameters s3GuardRequestParameters = new S3GuardRequestParameters();
s3GuardRequestParameters.setDynamoDbTableName("table");
awsEnvironmentParameters.setS3guard(s3GuardRequestParameters);
environment.setAws(awsEnvironmentParameters);
environment.setTelemetry(telemetryResponse);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.initCloudStorageRequest(environment, clusterV4Request, sdxCluster, sdxClusterRequest));
StorageLocationBase singleRequest = cloudStorageConfigReq.getLocations().iterator().next();
assertEquals(2, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.ID_BROKER)).collect(Collectors.toSet()).size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals("table", cloudStorageConfigReq.getAws().getS3Guard().getDynamoTableName());
assertEquals(1, cloudStorageConfigReq.getLocations().size());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, singleRequest.getType());
assertEquals("ranger/example-path", singleRequest.getValue());
verify(storageValidationService).validateCloudStorage("AWS", cloudStorageRequest);
}
use of com.sequenceiq.common.api.telemetry.response.LoggingResponse in project cloudbreak by hortonworks.
the class DiagnosticsCollectionValidatorTest method testWithCloudStorageWithEmptyLogging.
@Test
void testWithCloudStorageWithEmptyLogging() {
BaseDiagnosticsCollectionRequest request = new BaseDiagnosticsCollectionRequest();
request.setDestination(DiagnosticsDestination.CLOUD_STORAGE);
StackV4Response stackV4Response = new StackV4Response();
stackV4Response.setCrn(DATALAKE_CRN);
TelemetryResponse telemetry = new TelemetryResponse();
LoggingResponse logging = new LoggingResponse();
telemetry.setLogging(logging);
stackV4Response.setTelemetry(telemetry);
BadRequestException thrown = assertThrows(BadRequestException.class, () -> underTest.validate(request, stackV4Response));
assertTrue(thrown.getMessage().contains("S3, ABFS or GCS cloud storage logging setting should be enabled for Data Lake"));
}
use of com.sequenceiq.common.api.telemetry.response.LoggingResponse in project cloudbreak by hortonworks.
the class EnvironmentClientServiceTest method testSdxBackupLocationOnUpgradeRequestEnabled.
@Test
public void testSdxBackupLocationOnUpgradeRequestEnabled() {
BackupResponse backupResponse = new BackupResponse();
backupResponse.setStorageLocation(BACKUP_LOCATION);
LoggingResponse loggingResponse = new LoggingResponse();
loggingResponse.setStorageLocation(LOG_LOCATION);
TelemetryResponse telemetryResponse = new TelemetryResponse();
telemetryResponse.setLogging(loggingResponse);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
environmentResponse.setBackup(backupResponse);
environmentResponse.setTelemetry(telemetryResponse);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.MULTIPLE).build()).build());
when(environmentEndpoint.getByCrn(anyString())).thenReturn(environmentResponse);
Assert.assertEquals(BACKUP_LOCATION, underTest.getBackupLocation(ENV_CRN));
}
use of com.sequenceiq.common.api.telemetry.response.LoggingResponse in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenEnvironmentHasOnlyLoggingEnabledThenShouldApplyAsLogIdentity.
@Test
public void whenEnvironmentHasOnlyLoggingEnabledThenShouldApplyAsLogIdentity() {
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);
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, null, new SdxClusterRequest());
assertEquals(1, cloudStorageConfigReq.getIdentities().size());
assertEquals(1, cloudStorageConfigReq.getIdentities().stream().filter(r -> r.getType().equals(CloudIdentityType.LOG)).collect(Collectors.toSet()).size());
assertEquals("logprofile", cloudStorageConfigReq.getIdentities().get(0).getS3().getInstanceProfile());
}
Aggregations