use of com.sequenceiq.redbeams.domain.stack.DatabaseServer in project cloudbreak by hortonworks.
the class UpdateDatabaseServerRegistrationHandlerTest method addDatabaseServerToDBStack.
private void addDatabaseServerToDBStack(DBStack dbStack) {
DatabaseServer databaseServer = new DatabaseServer();
dbStack.setDatabaseServer(databaseServer);
databaseServer.setAccountId(ACCOUNT_ID);
databaseServer.setConnectionDriver(CONNECTION_DRIVER);
databaseServer.setRootUserName(ROOT_USER_NAME);
databaseServer.setRootPassword(ROOT_PASSWORD);
databaseServer.setDatabaseVendor(DatabaseVendor.POSTGRES);
databaseServer.setPort(PORT);
}
use of com.sequenceiq.redbeams.domain.stack.DatabaseServer in project cloudbreak by hortonworks.
the class RedbeamsCreationServiceTest method setup.
@BeforeEach
public void setup() {
dbStack = new DBStack();
// this wouldn't really be set before launchDatabaseServer is called
dbStack.setId(DB_STACK_ID);
dbStack.setName(DB_STACK_NAME);
dbStack.setDescription(DB_STACK_DESCRIPTION);
dbStack.setEnvironmentId(ENVIRONMENT_CRN);
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setPlatformVariant(PLATFORM_VARIANT);
dbStack.setUserName("username");
dbStack.setOwnerCrn(Crn.fromString("crn:cdp:iam:us-west-1:1234:user:234123"));
dbStack.setResourceCrn("crn:cdp:iam:us-west-1:1234:database:2312312");
DatabaseServer databaseServer = new DatabaseServer();
dbStack.setDatabaseServer(databaseServer);
databaseServer.setAccountId(ACCOUNT_ID);
databaseServer.setConnectionDriver(CONNECTION_DRIVER);
databaseServer.setRootUserName(ROOT_USER_NAME);
databaseServer.setRootPassword(ROOT_PASSWORD);
databaseServer.setDatabaseVendor(DatabaseVendor.POSTGRES);
databaseServer.setPort(PORT);
}
use of com.sequenceiq.redbeams.domain.stack.DatabaseServer in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAzureWithMultipleResourceGroups.
@Test
public void testConversionAzureWithMultipleResourceGroups() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.MULTIPLE).build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.containsKey(RESOURCE_GROUP_NAME_PARAMETER)).isFalse();
assertThat(parameters.containsKey(RESOURCE_GROUP_USAGE_PARAMETER)).isFalse();
assertThat(parameters.size()).isEqualTo(2);
}
use of com.sequenceiq.redbeams.domain.stack.DatabaseServer in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionAzureWithAzureEncryptionResourcesPresentAndSingleResourceGroup.
@Test
public void testConversionAzureWithAzureEncryptionResourcesPresentAndSingleResourceGroup() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform(CLOUD_PLATFORM);
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform(CLOUD_PLATFORM);
environmentResponse.setAzure(AzureEnvironmentParameters.builder().withAzureResourceGroup(AzureResourceGroup.builder().withResourceGroupUsage(ResourceGroupUsage.SINGLE).withName(RESOURCE_GROUP).build()).withResourceEncryptionParameters(AzureResourceEncryptionParameters.builder().withEncryptionKeyUrl(KEY_URL).withEncryptionKeyResourceGroupName(RESOURCE_GROUP).build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get(RESOURCE_GROUP_NAME_PARAMETER).toString()).isEqualTo(RESOURCE_GROUP);
assertThat(parameters.get(RESOURCE_GROUP_USAGE_PARAMETER).toString()).isEqualTo(ResourceGroupUsage.SINGLE.name());
assertThat(parameters.get(ENCRYPTION_KEY_URL).toString()).isEqualTo(KEY_URL);
assertThat(parameters.get(ENCRYPTION_KEY_RESOURCE_GROUP_NAME).toString()).isEqualTo(RESOURCE_GROUP);
assertThat(parameters.size()).isEqualTo(6);
}
use of com.sequenceiq.redbeams.domain.stack.DatabaseServer in project cloudbreak by hortonworks.
the class DBStackToDatabaseStackConverterTest method testConversionGcpWithGcpEncryptionResourcesPresent.
@Test
public void testConversionGcpWithGcpEncryptionResourcesPresent() {
Network network = new Network();
network.setAttributes(new Json(NETWORK_ATTRIBUTES));
dbStack.setNetwork(network);
dbStack.setCloudPlatform("GCP");
dbStack.setParameters(new HashMap<>());
DatabaseServer server = new DatabaseServer();
server.setDatabaseVendor(DatabaseVendor.POSTGRES);
server.setAttributes(new Json(DATABASE_SERVER_ATTRIBUTES));
dbStack.setDatabaseServer(server);
dbStack.setTags(new Json(STACK_TAGS));
dbStack.setTemplate("template");
DetailedEnvironmentResponse environmentResponse = new DetailedEnvironmentResponse();
environmentResponse.setCloudPlatform("GCP");
environmentResponse.setGcp(GcpEnvironmentParameters.builder().withResourceEncryptionParameters(GcpResourceEncryptionParameters.builder().withEncryptionKey("value").build()).build());
when(environmentService.getByCrn(anyString())).thenReturn(environmentResponse);
DatabaseStack convertedStack = underTest.convert(dbStack);
Map<String, Object> parameters = convertedStack.getDatabaseServer().getParameters();
assertThat(parameters.get("key").toString()).isEqualTo("value");
assertThat(parameters.size()).isEqualTo(3);
}
Aggregations