use of com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest in project cloudbreak by hortonworks.
the class AllocateDatabaseServerV4RequestToDBStackConverterTest method setUp.
@BeforeEach
public void setUp() {
ReflectionTestUtils.setField(underTest, FIELD_DB_SERVICE_SUPPORTED_PLATFORMS, Set.of("AWS", "AZURE"));
ReflectionTestUtils.setField(underTest, FIELD_REDBEAMS_DB_MAJOR_VERSION, REDBEAMS_DB_MAJOR_VERSION);
ReflectionTestUtils.setField(underTest, FIELD_SSL_ENABLED, true);
allocateRequest = new AllocateDatabaseServerV4Request();
networkRequest = new NetworkV4StackRequest();
allocateRequest.setNetwork(networkRequest);
databaseServerRequest = new DatabaseServerV4StackRequest();
allocateRequest.setDatabaseServer(databaseServerRequest);
securityGroupRequest = new SecurityGroupV4StackRequest();
databaseServerRequest.setSecurityGroup(securityGroupRequest);
when(crnUserDetailsService.loadUserByUsername(OWNER_CRN)).thenReturn(getCrnUser());
when(uuidGeneratorService.randomUuid()).thenReturn("uuid");
when(accountTagService.list()).thenReturn(new HashMap<>());
when(uuidGeneratorService.uuidVariableParts(anyInt())).thenReturn("parts");
when(entitlementService.internalTenant(anyString())).thenReturn(true);
sslCertificateEntryV2 = new SslCertificateEntry(VERSION_2, CLOUD_PROVIDER_IDENTIFIER_V2, CERT_PEM_V2, x509Certificate);
sslCertificateEntryV3 = new SslCertificateEntry(VERSION_3, CLOUD_PROVIDER_IDENTIFIER_V3, CERT_PEM_V3, x509Certificate);
when(databaseServerSslCertificateConfig.getMaxVersionByCloudPlatformAndRegion(anyString(), eq(REGION))).thenReturn(MAX_VERSION);
when(clock.getCurrentInstant()).thenReturn(NOW);
when(crnService.createCrn(any(DBStack.class))).thenReturn(CrnTestUtil.getDatabaseServerCrnBuilder().setAccountId("accountid").setResource("1").build());
}
use of com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest in project cloudbreak by hortonworks.
the class AwsDatabaseServerParameterDecoratorTest method setParameters.
@ParameterizedTest
@ValueSource(booleans = { false, true })
void setParameters(boolean needsHA) {
DatabaseServerParameter serverParameter = DatabaseServerParameter.builder().withHighlyAvailable(needsHA).build();
DatabaseServerV4StackRequest request = new DatabaseServerV4StackRequest();
underTest.setParameters(request, serverParameter);
assertThat(request.getAws().getMultiAZ()).isEqualTo(Boolean.toString(needsHA));
}
use of com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest in project cloudbreak by hortonworks.
the class GcpDatabaseServerParameterSetter method setParameters.
@Override
public void setParameters(DatabaseServerV4StackRequest request, SdxDatabaseAvailabilityType availabilityType, String databaseEngineVersion) {
GcpDatabaseServerV4Parameters parameters = new GcpDatabaseServerV4Parameters();
if (SdxDatabaseAvailabilityType.HA.equals(availabilityType)) {
parameters.setBackupRetentionDays(backupRetentionPeriodNonHa);
} else if (SdxDatabaseAvailabilityType.NON_HA.equals(availabilityType)) {
parameters.setBackupRetentionDays(backupRetentionPeriodNonHa);
} else {
throw new IllegalArgumentException(availabilityType + " database availability type is not supported on Azure.");
}
if (StringUtils.isNotEmpty(databaseEngineVersion)) {
parameters.setEngineVersion(databaseEngineVersion);
}
request.setGcp(parameters);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest in project cloudbreak by hortonworks.
the class AwsDatabaseServerParameterSetter method setParameters.
@Override
public void setParameters(DatabaseServerV4StackRequest request, SdxDatabaseAvailabilityType availabilityType, String databaseEngineVersion) {
AwsDatabaseServerV4Parameters parameters = new AwsDatabaseServerV4Parameters();
if (SdxDatabaseAvailabilityType.HA.equals(availabilityType)) {
parameters.setBackupRetentionPeriod(backupRetentionPeriodHa);
parameters.setMultiAZ("true");
} else if (SdxDatabaseAvailabilityType.NON_HA.equals(availabilityType)) {
parameters.setBackupRetentionPeriod(backupRetentionPeriodNonHa);
parameters.setMultiAZ("false");
} else {
throw new IllegalArgumentException(availabilityType + " database availability type is not supported on AWS.");
}
if (StringUtils.isNotEmpty(databaseEngineVersion)) {
parameters.setEngineVersion(databaseEngineVersion);
}
request.setAws(parameters);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.stacks.DatabaseServerV4StackRequest in project cloudbreak by hortonworks.
the class DatabaseServiceTest method shouldSetDbConfigBasedOnClusterShape.
@ParameterizedTest(name = "{0}")
@MethodSource("sslEnforcementDataProvider")
public void shouldSetDbConfigBasedOnClusterShape(String testCaseName, boolean supportedPlatform, String runtime, Boolean entitled, boolean sslEnforcementAppliedExpected) {
SdxCluster cluster = new SdxCluster();
cluster.setClusterName("NAME");
cluster.setClusterShape(SdxClusterShape.LIGHT_DUTY);
cluster.setCrn(CLUSTER_CRN);
cluster.setRuntime(runtime);
DetailedEnvironmentResponse env = new DetailedEnvironmentResponse();
env.setName("ENV");
env.setCloudPlatform("aws");
env.setCrn(ENV_CRN);
DatabaseConfig databaseConfig = getDatabaseConfig();
when(databaseServerV4Endpoint.createInternal(any(), any())).thenThrow(BadRequestException.class);
DatabaseConfigKey dbConfigKey = new DatabaseConfigKey(CloudPlatform.AWS, SdxClusterShape.LIGHT_DUTY);
when(dbConfigs.get(dbConfigKey)).thenReturn(databaseConfig);
when(databaseParameterSetterMap.get(CloudPlatform.AWS)).thenReturn(getDatabaseParameterSetter());
when(platformConfig.isExternalDatabaseSslEnforcementSupportedFor(CloudPlatform.AWS)).thenReturn(supportedPlatform);
if (entitled != null) {
when(entitlementService.databaseWireEncryptionEnabled(ACCOUNT_ID)).thenReturn(entitled);
}
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
SdxStatusEntity status = new SdxStatusEntity();
status.setStatus(DatalakeStatusEnum.REQUESTED);
when(sdxStatusService.getActualStatusForSdx(any())).thenReturn(status);
assertThatCode(() -> ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.create(cluster, env))).isInstanceOf(BadRequestException.class);
verify(databaseServerV4Endpoint).createInternal(allocateDatabaseServerV4RequestCaptor.capture(), anyString());
AllocateDatabaseServerV4Request dbRequest = allocateDatabaseServerV4RequestCaptor.getValue();
assertThat(dbRequest).isNotNull();
DatabaseServerV4StackRequest databaseServer = dbRequest.getDatabaseServer();
assertThat(databaseServer).isNotNull();
assertThat(databaseServer.getInstanceType()).isEqualTo("instanceType");
assertThat(databaseServer.getDatabaseVendor()).isEqualTo("vendor");
assertThat(databaseServer.getStorageSize()).isEqualTo(100L);
assertThat(dbRequest.getClusterCrn()).isEqualTo(CLUSTER_CRN);
assertThat(databaseServer.getAws()).isNotNull();
SslConfigV4Request sslConfig = dbRequest.getSslConfig();
if (sslEnforcementAppliedExpected) {
assertThat(sslConfig).isNotNull();
assertThat(sslConfig.getSslMode()).isEqualTo(SslMode.ENABLED);
} else {
assertThat(sslConfig).isNull();
}
verifyNoInteractions(sdxClusterRepository);
verifyNoInteractions(notificationService);
}
Aggregations