Search in sources :

Example 1 with DatabaseServer

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);
}
Also used : DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer)

Example 2 with DatabaseServer

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);
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DatabaseServer

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);
}
Also used : Network(com.sequenceiq.redbeams.domain.stack.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Json(com.sequenceiq.cloudbreak.common.json.Json) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 4 with DatabaseServer

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);
}
Also used : Network(com.sequenceiq.redbeams.domain.stack.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Json(com.sequenceiq.cloudbreak.common.json.Json) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 5 with DatabaseServer

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);
}
Also used : Network(com.sequenceiq.redbeams.domain.stack.Network) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) DatabaseStack(com.sequenceiq.cloudbreak.cloud.model.DatabaseStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) Json(com.sequenceiq.cloudbreak.common.json.Json) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

DatabaseServer (com.sequenceiq.redbeams.domain.stack.DatabaseServer)16 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)11 Test (org.junit.jupiter.api.Test)11 Json (com.sequenceiq.cloudbreak.common.json.Json)8 Network (com.sequenceiq.redbeams.domain.stack.Network)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)6 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)3 DatabaseVendor (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DatabaseVendor)1 TemplatingNotSupportedException (com.sequenceiq.cloudbreak.cloud.exception.TemplatingNotSupportedException)1 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)1 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)1 SecurityGroup (com.sequenceiq.redbeams.domain.stack.SecurityGroup)1 RedbeamsException (com.sequenceiq.redbeams.exception.RedbeamsException)1 HashSet (java.util.HashSet)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1