Search in sources :

Example 31 with DatabaseServer

use of com.sequenceiq.cloudbreak.cloud.model.DatabaseServer in project cloudbreak by hortonworks.

the class GcpDatabaseServerViewTest method testGcpDatabaseNetworkView.

@Test
public void testGcpDatabaseNetworkView() {
    Map<String, Object> map = new HashMap<>();
    map.put("engineVersion", "1");
    DatabaseServer databaseServer = DatabaseServer.builder().connectionDriver("driver").serverId("driver").connectorJarUrl("driver").engine(DatabaseEngine.POSTGRESQL).location("location").port(99).storageSize(50L).rootUserName("rootUserName").rootPassword("rootPassword").flavor("flavor").useSslEnforcement(true).params(map).build();
    GcpDatabaseServerView gcpDatabaseServerView = new GcpDatabaseServerView(databaseServer);
    Assert.assertEquals("POSTGRES", gcpDatabaseServerView.getDatabaseType());
    Assert.assertEquals("POSTGRES_1", gcpDatabaseServerView.getDatabaseVersion());
    Assert.assertEquals("driver", gcpDatabaseServerView.getDbServerName());
    Assert.assertEquals("rootUserName", gcpDatabaseServerView.getAdminLoginName());
    Assert.assertEquals(Integer.valueOf(99), gcpDatabaseServerView.getPort());
    Assert.assertEquals("rootPassword", gcpDatabaseServerView.getAdminPassword());
    Assert.assertEquals(Long.valueOf(50L), gcpDatabaseServerView.getAllocatedStorageInGb());
    Assert.assertEquals("1", gcpDatabaseServerView.getDbVersion());
}
Also used : HashMap(java.util.HashMap) DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) Test(org.junit.jupiter.api.Test)

Example 32 with DatabaseServer

use of com.sequenceiq.cloudbreak.cloud.model.DatabaseServer in project cloudbreak by hortonworks.

the class AwsRdsDbParameterGroupViewTest method getDBParameterGroupNameTestWhenNullServerId.

@Test
void getDBParameterGroupNameTestWhenNullServerId() {
    DatabaseServer databaseServer = DatabaseServer.builder().build();
    AwsRdsDbParameterGroupView underTest = new AwsRdsDbParameterGroupView(databaseServer);
    assertThat(underTest.getDBParameterGroupName()).isNull();
}
Also used : DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with DatabaseServer

use of com.sequenceiq.cloudbreak.cloud.model.DatabaseServer in project cloudbreak by hortonworks.

the class AwsRdsDbParameterGroupViewTest method getDBParameterGroupNameTestWhenHasServerId.

@Test
void getDBParameterGroupNameTestWhenHasServerId() {
    DatabaseServer databaseServer = DatabaseServer.builder().serverId("myserver").build();
    AwsRdsDbParameterGroupView underTest = new AwsRdsDbParameterGroupView(databaseServer);
    assertThat(underTest.getDBParameterGroupName()).isEqualTo("dpg-myserver");
}
Also used : DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with DatabaseServer

use of com.sequenceiq.cloudbreak.cloud.model.DatabaseServer in project cloudbreak by hortonworks.

the class AwsRdsDbParameterGroupViewTest method getDBParameterGroupFamilyTestWhenPgSqlAndBadVersionFormat.

// Note: There is no easy way to test the "bad engine variant" case as enum classes are final and hard to mock.
@Test
void getDBParameterGroupFamilyTestWhenPgSqlAndBadVersionFormat() {
    DatabaseServer databaseServer = DatabaseServer.builder().engine(DatabaseEngine.POSTGRESQL).build();
    databaseServer.putParameter(ENGINE_VERSION, "latest");
    AwsRdsDbParameterGroupView underTest = new AwsRdsDbParameterGroupView(databaseServer);
    assertThatCode(underTest::getDBParameterGroupFamily).isInstanceOf(IllegalStateException.class);
}
Also used : DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with DatabaseServer

use of com.sequenceiq.cloudbreak.cloud.model.DatabaseServer in project cloudbreak by hortonworks.

the class DBStackToDatabaseStackConverter method buildDatabaseServer.

private DatabaseServer buildDatabaseServer(DBStack dbStack) {
    com.sequenceiq.redbeams.domain.stack.DatabaseServer dbStackDatabaseServer = dbStack.getDatabaseServer();
    if (dbStackDatabaseServer == null) {
        return null;
    }
    Map<String, Object> params = buildParameters(dbStack);
    SecurityGroup securityGroup = dbStackDatabaseServer.getSecurityGroup();
    DatabaseServer.Builder builder = DatabaseServer.builder().serverId(dbStackDatabaseServer.getName()).flavor(dbStackDatabaseServer.getInstanceType()).engine(getDatabaseEngine(dbStackDatabaseServer)).connectionDriver(dbStackDatabaseServer.getConnectionDriver()).rootUserName(dbStackDatabaseServer.getRootUserName()).rootPassword(dbStackDatabaseServer.getRootPassword()).port(dbStackDatabaseServer.getPort()).useSslEnforcement(determineSslEnforcement(dbStack)).storageSize(dbStackDatabaseServer.getStorageSize()).security(securityGroup == null ? null : new Security(Collections.emptyList(), securityGroup.getSecurityGroupIds())).status(CREATE_REQUESTED).location(dbStack.getRegion()).highAvailability(dbStack.isHa()).params(params);
    return builder.build();
}
Also used : DatabaseServer(com.sequenceiq.cloudbreak.cloud.model.DatabaseServer) SecurityGroup(com.sequenceiq.redbeams.domain.stack.SecurityGroup) Security(com.sequenceiq.cloudbreak.cloud.model.Security)

Aggregations

DatabaseServer (com.sequenceiq.cloudbreak.cloud.model.DatabaseServer)36 Test (org.junit.jupiter.api.Test)27 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)23 AuthenticatedContext (com.sequenceiq.cloudbreak.cloud.context.AuthenticatedContext)18 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)17 SQLAdmin (com.google.api.services.sqladmin.SQLAdmin)16 DatabaseInstance (com.google.api.services.sqladmin.model.DatabaseInstance)13 InstancesListResponse (com.google.api.services.sqladmin.model.InstancesListResponse)13 PersistenceNotifier (com.sequenceiq.cloudbreak.cloud.notification.PersistenceNotifier)10 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)10 Network (com.sequenceiq.cloudbreak.cloud.model.Network)8 ExternalDatabaseStatus (com.sequenceiq.cloudbreak.cloud.model.ExternalDatabaseStatus)7 Subnet (com.sequenceiq.cloudbreak.cloud.model.Subnet)7 HashMap (java.util.HashMap)7 GcpResourceException (com.sequenceiq.cloudbreak.cloud.gcp.GcpResourceException)6 Settings (com.google.api.services.sqladmin.model.Settings)5 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)5 GoogleJsonError (com.google.api.client.googleapis.json.GoogleJsonError)4 GoogleJsonResponseException (com.google.api.client.googleapis.json.GoogleJsonResponseException)4 Compute (com.google.api.services.compute.Compute)4