use of com.sequenceiq.environment.api.v1.environment.model.response.TagResponse in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method setupForEndpointGateway.
private StackV4Request setupForEndpointGateway(boolean enabled) {
initMocks();
ReflectionTestUtils.setField(underTest, "defaultRegions", "AWS:eu-west-2");
StackV4Request request = getRequest("stack-datalake-with-instancegroups.json");
EnvironmentNetworkResponse networkResponse = new EnvironmentNetworkResponse();
networkResponse.setPublicEndpointAccessGateway(enabled ? PublicEndpointAccessGateway.ENABLED : PublicEndpointAccessGateway.DISABLED);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCredential(credentialResponse);
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setTunnel(Tunnel.DIRECT);
environmentResponse.setTags(new TagResponse());
environmentResponse.setNetwork(networkResponse);
when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
given(credentialClientService.getByCrn(anyString())).willReturn(credential);
given(credentialClientService.getByName(anyString())).willReturn(credential);
given(providerParameterCalculator.get(request)).willReturn(getMappable());
given(clusterV4RequestToClusterConverter.convert(any(ClusterV4Request.class))).willReturn(new Cluster());
given(telemetryConverter.convert(null, StackType.DATALAKE)).willReturn(new Telemetry());
given(loadBalancerConfigService.getKnoxGatewayGroups(any(Stack.class))).willReturn(Set.of("master"));
return request;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.TagResponse in project cloudbreak by hortonworks.
the class StackV4RequestToStackConverterTest method setUp.
@BeforeEach
void setUp() {
when(restRequestThreadLocalService.getCloudbreakUser()).thenReturn(cloudbreakUser);
when(cloudbreakUser.getUsername()).thenReturn("username");
when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(1L);
when(workspaceService.getForCurrentUser()).thenReturn(workspace);
when(workspace.getId()).thenReturn(1L);
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCredential(credentialResponse);
environmentResponse.setCloudPlatform("AWS");
environmentResponse.setTunnel(Tunnel.DIRECT);
environmentResponse.setTags(new TagResponse());
when(environmentClientService.getByName(anyString())).thenReturn(environmentResponse);
when(environmentClientService.getByCrn(anyString())).thenReturn(environmentResponse);
when(kerberosConfigService.get(anyString(), anyString())).thenReturn(Optional.empty());
when(costTagging.mergeTags(any(CDPTagMergeRequest.class))).thenReturn(new HashMap<>());
when(datalakeService.getDatalakeCrn(any(), any())).thenReturn("crn");
when(targetedUpscaleSupportService.isUnboundEliminationSupported(anyString())).thenReturn(Boolean.FALSE);
credential = Credential.builder().cloudPlatform("AWS").build();
}
use of com.sequenceiq.environment.api.v1.environment.model.response.TagResponse in project cloudbreak by hortonworks.
the class EnvironmentResponseConverter method environmentTagsToTagResponse.
private TagResponse environmentTagsToTagResponse(EnvironmentTags tags) {
TagResponse tagResponse = new TagResponse();
tagResponse.setDefaults(tags.getDefaultTags());
tagResponse.setUserDefined(tags.getUserDefinedTags());
return tagResponse;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.TagResponse in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenOptionalElementsGenerated.
@Test
void conversionTestWhenOptionalElementsGenerated() throws IOException {
setupAllocateRequest(false);
when(databaseServerSslCertificateConfig.getNumberOfCertsByCloudPlatformAndRegion(AWS_CLOUD_PLATFORM.name(), REGION)).thenReturn(SINGLE_CERT);
when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndVersion(AWS_CLOUD_PLATFORM.name(), REGION, VERSION_3)).thenReturn(sslCertificateEntryV3);
List<CloudSubnet> cloudSubnets = List.of(new CloudSubnet("subnet-1", "", "az-a", ""), new CloudSubnet("subnet-2", "", "az-b", ""));
DetailedEnvironmentResponse environment = DetailedEnvironmentResponse.builder().withCloudPlatform(AWS_CLOUD_PLATFORM.name()).withName(ENVIRONMENT_NAME).withCrn(ENVIRONMENT_CRN).withTag(new TagResponse()).withLocation(LocationResponse.LocationResponseBuilder.aLocationResponse().withName(REGION).build()).withSecurityAccess(SecurityAccessResponse.builder().withDefaultSecurityGroupId(DEFAULT_SECURITY_GROUP_ID).build()).withNetwork(EnvironmentNetworkResponse.builder().withSubnetMetas(Map.of("subnet-1", cloudSubnets.get(0), "subnet-2", cloudSubnets.get(1))).build()).build();
when(environmentService.getByCrn(ENVIRONMENT_CRN)).thenReturn(environment);
when(subnetListerService.listSubnets(any(), any())).thenReturn(cloudSubnets);
when(subnetChooserService.chooseSubnets(any(), any(), any())).thenReturn(cloudSubnets);
when(networkParameterAdder.addSubnetIds(any(), any(), any(), any())).thenReturn(SUBNET_ID_REQUEST_PARAMETERS);
when(userGeneratorService.generateUserName()).thenReturn(USERNAME);
when(passwordGeneratorService.generatePassword(any())).thenReturn(PASSWORD);
DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
assertEquals(ENVIRONMENT_NAME + "-dbstck-parts", dbStack.getName());
assertEquals(PASSWORD, dbStack.getDatabaseServer().getRootPassword());
assertEquals(USERNAME, dbStack.getDatabaseServer().getRootUserName());
assertEquals("n-uuid", dbStack.getNetwork().getName());
assertEquals(1, dbStack.getNetwork().getAttributes().getMap().size());
assertEquals("netvalue", dbStack.getNetwork().getAttributes().getMap().get("netkey"));
assertThat(dbStack.getDatabaseServer().getSecurityGroup().getSecurityGroupIds()).hasSize(1);
assertEquals(dbStack.getDatabaseServer().getSecurityGroup().getSecurityGroupIds().iterator().next(), DEFAULT_SECURITY_GROUP_ID);
assertEquals(dbStack.getTags().get(StackTags.class).getUserDefinedTags().get("DistroXKey1"), "DistroXValue1");
verifySsl(dbStack, Set.of(CERT_PEM_V3), CLOUD_PROVIDER_IDENTIFIER_V3);
verify(databaseServerSslCertificateConfig, never()).getCertsByCloudPlatformAndRegionAndVersions(anyString(), anyString(), any());
verify(providerParameterCalculator).get(allocateRequest);
verify(providerParameterCalculator, never()).get(networkRequest);
verify(subnetListerService).listSubnets(any(), any());
verify(subnetChooserService).chooseSubnets(anyList(), any(), any());
verify(networkParameterAdder).addSubnetIds(any(), any(), any(), any());
verify(userGeneratorService).generateUserName();
verify(passwordGeneratorService).generatePassword(any());
}
use of com.sequenceiq.environment.api.v1.environment.model.response.TagResponse in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method conversionTestWhenOptionalElementsAreProvided.
@Test
void conversionTestWhenOptionalElementsAreProvided() throws IOException {
setupAllocateRequest(true);
when(databaseServerSslCertificateConfig.getNumberOfCertsByCloudPlatformAndRegion(AWS_CLOUD_PLATFORM.name(), REGION)).thenReturn(SINGLE_CERT);
when(databaseServerSslCertificateConfig.getCertByCloudPlatformAndRegionAndVersion(AWS_CLOUD_PLATFORM.name(), REGION, VERSION_3)).thenReturn(sslCertificateEntryV3);
DetailedEnvironmentResponse environment = DetailedEnvironmentResponse.builder().withCloudPlatform(AWS_CLOUD_PLATFORM.name()).withCrn(ENVIRONMENT_CRN).withLocation(LocationResponse.LocationResponseBuilder.aLocationResponse().withName(REGION).build()).withName(ENVIRONMENT_NAME).withTag(new TagResponse()).build();
when(environmentService.getByCrn(ENVIRONMENT_CRN)).thenReturn(environment);
DBStack dbStack = underTest.convert(allocateRequest, OWNER_CRN);
assertEquals(allocateRequest.getName(), dbStack.getName());
assertEquals(allocateRequest.getEnvironmentCrn(), dbStack.getEnvironmentId());
assertEquals(REGION, dbStack.getRegion());
assertEquals(AWS_CLOUD_PLATFORM.name(), dbStack.getCloudPlatform());
assertEquals(AWS_CLOUD_PLATFORM.name(), dbStack.getPlatformVariant());
assertEquals(1, dbStack.getParameters().size());
assertEquals("value", dbStack.getParameters().get("key"));
assertEquals(Crn.safeFromString(OWNER_CRN), dbStack.getOwnerCrn());
assertEquals(USER_EMAIL, dbStack.getUserName());
assertEquals(Status.REQUESTED, dbStack.getStatus());
assertEquals(DetailedDBStackStatus.PROVISION_REQUESTED, dbStack.getDbStackStatus().getDetailedDBStackStatus());
assertEquals(NOW.toEpochMilli(), dbStack.getDbStackStatus().getCreated().longValue());
assertEquals("n-uuid", dbStack.getNetwork().getName());
assertEquals(1, dbStack.getNetwork().getAttributes().getMap().size());
assertEquals("netvalue", dbStack.getNetwork().getAttributes().getMap().get("netkey"));
assertEquals("dbsvr-uuid", dbStack.getDatabaseServer().getName());
assertEquals(databaseServerRequest.getInstanceType(), dbStack.getDatabaseServer().getInstanceType());
assertEquals(DatabaseVendor.fromValue(databaseServerRequest.getDatabaseVendor()), dbStack.getDatabaseServer().getDatabaseVendor());
assertEquals("org.postgresql.Driver", dbStack.getDatabaseServer().getConnectionDriver());
assertEquals(databaseServerRequest.getStorageSize(), dbStack.getDatabaseServer().getStorageSize());
assertEquals(databaseServerRequest.getRootUserName(), dbStack.getDatabaseServer().getRootUserName());
assertEquals(databaseServerRequest.getRootUserPassword(), dbStack.getDatabaseServer().getRootPassword());
assertEquals(2, dbStack.getDatabaseServer().getAttributes().getMap().size());
assertEquals("dbvalue", dbStack.getDatabaseServer().getAttributes().getMap().get("dbkey"));
assertEquals(REDBEAMS_DB_MAJOR_VERSION, dbStack.getDatabaseServer().getAttributes().getMap().get("engineVersion"));
assertEquals(securityGroupRequest.getSecurityGroupIds(), dbStack.getDatabaseServer().getSecurityGroup().getSecurityGroupIds());
assertEquals(dbStack.getTags().get(StackTags.class).getUserDefinedTags().get("DistroXKey1"), "DistroXValue1");
verifySsl(dbStack, Set.of(CERT_PEM_V3), CLOUD_PROVIDER_IDENTIFIER_V3);
verify(databaseServerSslCertificateConfig, never()).getCertsByCloudPlatformAndRegionAndVersions(anyString(), anyString(), any());
verify(providerParameterCalculator).get(allocateRequest);
verify(providerParameterCalculator).get(networkRequest);
verify(subnetListerService, never()).listSubnets(any(), any());
verify(subnetChooserService, never()).chooseSubnets(anyList(), any(), any());
verify(networkParameterAdder, never()).addSubnetIds(any(), any(), any(), any());
verify(userGeneratorService, never()).generateUserName();
verify(passwordGeneratorService, never()).generatePassword(any());
}
Aggregations