use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters 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());
}
use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.
the class CloudStorageManifesterTest method whenCloudStorageEnabledFromInternalRequestWithLogging.
@Test
public void whenCloudStorageEnabledFromInternalRequestWithLogging() {
ClusterV4Request clusterV4Request = new ClusterV4Request();
clusterV4Request.setBlueprintName(exampleBlueprintName);
CloudStorageRequest cloudStorageRequest = new CloudStorageRequest();
StorageLocationBase storageLocationBase = new StorageLocationBase();
storageLocationBase.setType(CloudStorageCdpService.RANGER_AUDIT);
storageLocationBase.setValue("s3a://ranger-audit");
cloudStorageRequest.setLocations(List.of(storageLocationBase));
clusterV4Request.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);
environment.setTelemetry(telemetryResponse);
CloudStorageRequest cloudStorageConfigReq = underTest.initCloudStorageRequest(environment, clusterV4Request, null, new SdxClusterRequest());
assertEquals(CloudStorageCdpService.RANGER_AUDIT, cloudStorageConfigReq.getLocations().get(0).getType());
assertEquals(CloudIdentityType.LOG, cloudStorageConfigReq.getIdentities().get(0).getType());
}
use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
LoggingRequest loggingRequest = new LoggingRequest();
S3CloudStorageV1Parameters s3Params = new S3CloudStorageV1Parameters();
s3Params.setInstanceProfile(INSTANCE_PROFILE_VALUE);
loggingRequest.setS3(s3Params);
telemetryRequest.setLogging(loggingRequest);
telemetryRequest.setWorkloadAnalytics(new WorkloadAnalyticsRequest());
FeaturesRequest fr = new FeaturesRequest();
fr.addClusterLogsCollection(true);
fr.addWorkloadAnalytics(true);
fr.addMonitoring(true);
telemetryRequest.setFeatures(fr);
given(entitlementService.isCdpSaasEnabled(anyString())).willReturn(true);
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertEquals(INSTANCE_PROFILE_VALUE, result.getLogging().getS3().getInstanceProfile());
assertEquals("http://myaddress/api/v1/receive", result.getMonitoring().getRemoteWriteUrl());
assertTrue(result.getFeatures().getClusterLogsCollection().isEnabled());
assertTrue(result.getFeatures().getWorkloadAnalytics().isEnabled());
assertTrue(result.getFeatures().getUseSharedAltusCredential().isEnabled());
assertTrue(result.getFeatures().getMonitoring().isEnabled());
assertTrue(result.getFeatures().getCloudStorageLogging().isEnabled());
}
use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.
the class CloudStorageValidatorTest method validateCloudStorageSetLocationBaseWhenLoggingIsConfigured.
@Test
public void validateCloudStorageSetLocationBaseWhenLoggingIsConfigured() {
when(credentialService.getByCrnForAccountId(anyString(), anyString(), any(), anyBoolean())).thenReturn(new Credential());
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
EnvironmentCloudStorageValidationRequest request = new EnvironmentCloudStorageValidationRequest();
TelemetryRequest telemetryRequest = new TelemetryRequest();
LoggingRequest loggingRequest = new LoggingRequest();
loggingRequest.setStorageLocation("s3://mybucket/location");
S3CloudStorageV1Parameters s3CloudStorageV1Parameters = new S3CloudStorageV1Parameters();
s3CloudStorageV1Parameters.setInstanceProfile("instanceProfile");
loggingRequest.setS3(s3CloudStorageV1Parameters);
telemetryRequest.setLogging(loggingRequest);
request.setTelemetry(telemetryRequest);
request.setCredentialCrn("credential");
ArgumentCaptor<ObjectStorageValidateRequest> requestCaptor = ArgumentCaptor.forClass(ObjectStorageValidateRequest.class);
when(cloudProviderServicesV4Endpoint.validateObjectStorage(requestCaptor.capture())).thenReturn(ObjectStorageValidateResponse.builder().withStatus(ResponseStatus.OK).build());
ObjectStorageValidateResponse response = underTest.validateCloudStorage("1234", request);
assertEquals(ResponseStatus.OK, response.getStatus());
assertNull(response.getError());
ObjectStorageValidateRequest objectStorageValidateRequest = requestCaptor.getValue();
assertEquals("s3://mybucket/location", objectStorageValidateRequest.getLogsLocationBase());
List<StorageIdentityBase> storageIdentities = objectStorageValidateRequest.getCloudStorageRequest().getIdentities();
assertEquals(1, storageIdentities.size());
StorageIdentityBase storageIdentity = storageIdentities.get(0);
assertEquals(CloudIdentityType.LOG, storageIdentity.getType());
assertEquals("instanceProfile", storageIdentity.getS3().getInstanceProfile());
}
use of com.sequenceiq.common.api.cloudstorage.old.S3CloudStorageV1Parameters in project cloudbreak by hortonworks.
the class CloudStorageValidationServiceTest method getEnvironment.
private DetailedEnvironmentResponse getEnvironment() {
DetailedEnvironmentResponse environment = new DetailedEnvironmentResponse();
TelemetryResponse telemetry = new TelemetryResponse();
FeaturesResponse features = new FeaturesResponse();
FeatureSetting featureSetting = new FeatureSetting();
featureSetting.setEnabled(true);
features.setCloudStorageLogging(featureSetting);
telemetry.setFeatures(features);
LoggingResponse logging = new LoggingResponse();
logging.setS3(new S3CloudStorageV1Parameters());
telemetry.setLogging(logging);
environment.setTelemetry(telemetry);
return environment;
}
Aggregations