use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class TelemetryApiConverterTest method testConvertWithWADisabled.
@Test
public void testConvertWithWADisabled() {
// GIVEN
TelemetryRequest telemetryRequest = new TelemetryRequest();
FeaturesRequest fr = new FeaturesRequest();
fr.addWorkloadAnalytics(false);
telemetryRequest.setFeatures(fr);
// WHEN
EnvironmentTelemetry result = underTest.convert(telemetryRequest, new Features(), ACCOUNT_ID);
// THEN
assertFalse(result.getFeatures().getWorkloadAnalytics().isEnabled());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry 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());
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class EnvironmentCreationService method validateCreation.
private void validateCreation(EnvironmentCreationDto creationDto, Environment environment) {
LOGGER.info("Validating environment creation. CreationDto: '{}', Environment: '{}'.", creationDto, environment);
ValidationResultBuilder validationBuilder = validatorService.validateNetworkCreation(environment, creationDto.getNetwork());
validationBuilder.merge(validatorService.validatePublicKey(creationDto.getAuthentication().getPublicKey()));
validationBuilder.merge(validatorService.validateTags(creationDto));
if (creationDto.getCloudPlatform() != null) {
validationBuilder.merge(validateEncryptionKey(creationDto));
}
ValidationResult parentChildValidation = validatorService.validateParentChildRelation(environment, creationDto.getParentEnvironmentName());
validationBuilder.merge(parentChildValidation);
EnvironmentTelemetry environmentTelemetry = creationDto.getTelemetry();
if (environmentTelemetry != null && environmentTelemetry.getLogging() != null && environmentTelemetry.getLogging().getStorageLocation() != null) {
validationBuilder.merge(validatorService.validateStorageLocation(environmentTelemetry.getLogging().getStorageLocation(), "logging"));
}
validationBuilder.ifError(() -> isCloudPlatformInvalid(creationDto.getCreator(), creationDto.getCloudPlatform()), "Provisioning in " + creationDto.getCloudPlatform() + " is not enabled for this account.");
ValidationResult freeIpaCreationValidation = validatorService.validateFreeIpaCreation(creationDto.getFreeIpaCreation());
validationBuilder.merge(freeIpaCreationValidation);
ValidationResult validationResult = validationBuilder.build();
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class NetworkServiceTest method testRefreshMetadataFromAwsCloudProviderMustUseSubnetId.
@Test
public void testRefreshMetadataFromAwsCloudProviderMustUseSubnetId() {
NetworkDto networkDto = mock(NetworkDto.class);
AuthenticationDto authenticationDto = mock(AuthenticationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
EnvironmentBackup environmentBackup = mock(EnvironmentBackup.class);
SecurityAccessDto securityAccessDto = mock(SecurityAccessDto.class);
ParametersDto parametersDto = mock(ParametersDto.class);
EnvironmentNetworkConverter environmentNetworkConverter = mock(EnvironmentNetworkConverter.class);
Network network = mock(Network.class);
Credential credential = mock(Credential.class);
BaseNetwork baseNetwork = new GcpNetwork();
baseNetwork.setRegistrationType(RegistrationType.EXISTING);
Environment environment = new Environment();
environment.setCloudPlatform("AWS");
environment.setCredential(credential);
EnvironmentEditDto environmentEditDto = new EnvironmentEditDto("description", "accountId", networkDto, authenticationDto, environmentTelemetry, environmentBackup, securityAccessDto, Tunnel.CCMV2, IdBrokerMappingSource.MOCK, CloudStorageValidation.ENABLED, "adminGroupName", parametersDto);
when(environmentNetworkConverterMap.get(any(CloudPlatform.class))).thenReturn(environmentNetworkConverter);
when(environmentNetworkConverter.convertToDto(baseNetwork)).thenReturn(networkDto);
when(cloudNetworkService.retrieveSubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(cloudNetworkService.retrieveEndpointGatewaySubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(environmentNetworkConverter.convertToNetwork(any(BaseNetwork.class))).thenReturn(network);
when(environmentNetworkService.getNetworkCidr(any(Network.class), anyString(), any(Credential.class))).thenReturn(new NetworkCidr("10.0.0.0", new ArrayList<>()));
BaseNetwork result = underTest.refreshMetadataFromCloudProvider(baseNetwork, environmentEditDto, environment);
Assertions.assertEquals(result.getSubnetMetas().keySet().stream().findFirst().get(), "s1");
Assertions.assertEquals(result.getSubnetMetas().keySet().size(), 1);
}
use of com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry in project cloudbreak by hortonworks.
the class NetworkServiceTest method testRefreshMetadataFromGoogleCloudProviderMustUseSubnetName.
@Test
public void testRefreshMetadataFromGoogleCloudProviderMustUseSubnetName() {
NetworkDto networkDto = mock(NetworkDto.class);
AuthenticationDto authenticationDto = mock(AuthenticationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
EnvironmentBackup environmentBackup = mock(EnvironmentBackup.class);
SecurityAccessDto securityAccessDto = mock(SecurityAccessDto.class);
ParametersDto parametersDto = mock(ParametersDto.class);
EnvironmentNetworkConverter environmentNetworkConverter = mock(EnvironmentNetworkConverter.class);
Network network = mock(Network.class);
Credential credential = mock(Credential.class);
BaseNetwork baseNetwork = new GcpNetwork();
baseNetwork.setRegistrationType(RegistrationType.EXISTING);
Environment environment = new Environment();
environment.setCloudPlatform("GCP");
environment.setCredential(credential);
EnvironmentEditDto environmentEditDto = new EnvironmentEditDto("description", "accountId", networkDto, authenticationDto, environmentTelemetry, environmentBackup, securityAccessDto, Tunnel.CCMV2, IdBrokerMappingSource.MOCK, CloudStorageValidation.ENABLED, "adminGroupName", parametersDto);
when(environmentNetworkConverterMap.get(any(CloudPlatform.class))).thenReturn(environmentNetworkConverter);
when(environmentNetworkConverter.convertToDto(baseNetwork)).thenReturn(networkDto);
when(cloudNetworkService.retrieveSubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(cloudNetworkService.retrieveEndpointGatewaySubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(environmentNetworkConverter.convertToNetwork(any(BaseNetwork.class))).thenReturn(network);
when(environmentNetworkService.getNetworkCidr(any(Network.class), anyString(), any(Credential.class))).thenReturn(new NetworkCidr("10.0.0.0", new ArrayList<>()));
BaseNetwork result = underTest.refreshMetadataFromCloudProvider(baseNetwork, environmentEditDto, environment);
Assertions.assertEquals(result.getSubnetMetas().keySet().stream().findFirst().get(), "subnet1");
Assertions.assertEquals(result.getSubnetMetas().keySet().size(), 1);
}
Aggregations