Search in sources :

Example 26 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseServiceTest method shouldCallStartAndWaitForAvailableStatus.

@Test
public void shouldCallStartAndWaitForAvailableStatus() {
    SdxCluster cluster = new SdxCluster();
    cluster.setDatabaseCrn(DATABASE_CRN);
    DatabaseServerV4Response databaseServerV4Response = mock(DatabaseServerV4Response.class);
    when(databaseServerV4Endpoint.getByCrn(DATABASE_CRN)).thenReturn(databaseServerV4Response);
    when(databaseServerV4Response.getStatus()).thenReturn(Status.AVAILABLE);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    underTest.start(cluster);
    verify(databaseServerV4Endpoint).start(DATABASE_CRN);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 27 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseServiceTest method testGetDatabaseServerShouldReturnDatabaseServer.

@Test
public void testGetDatabaseServerShouldReturnDatabaseServer() {
    SdxCluster cluster = new SdxCluster();
    cluster.setDatabaseCrn(DATABASE_CRN);
    when(sdxService.getByCrn(USER_CRN, CLUSTER_CRN)).thenReturn(cluster);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
    databaseServerV4Response.setCrn(DATABASE_CRN);
    databaseServerV4Response.setClusterCrn(CLUSTER_CRN);
    databaseServerV4Response.setStatus(Status.AVAILABLE);
    when(databaseServerV4Endpoint.getByCrn(DATABASE_CRN)).thenReturn(databaseServerV4Response);
    StackDatabaseServerResponse response = underTest.getDatabaseServer(USER_CRN, CLUSTER_CRN);
    assertThat(response.getClusterCrn()).isEqualTo(CLUSTER_CRN);
    assertThat(response.getCrn()).isEqualTo(DATABASE_CRN);
    assertThat(response.getStatus()).isEqualTo(DatabaseServerStatus.AVAILABLE);
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 28 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseServerConverter method convert.

public StackDatabaseServerResponse convert(DatabaseServerV4Response databaseServerV4Response) {
    StackDatabaseServerResponse stackDatabaseServerResponse = new StackDatabaseServerResponse();
    stackDatabaseServerResponse.setCrn(databaseServerV4Response.getCrn());
    stackDatabaseServerResponse.setName(databaseServerV4Response.getName());
    stackDatabaseServerResponse.setDescription(databaseServerV4Response.getDescription());
    stackDatabaseServerResponse.setEnvironmentCrn(databaseServerV4Response.getEnvironmentCrn());
    stackDatabaseServerResponse.setHost(databaseServerV4Response.getHost());
    stackDatabaseServerResponse.setPort(databaseServerV4Response.getPort());
    stackDatabaseServerResponse.setDatabaseVendor(databaseServerV4Response.getDatabaseVendor());
    stackDatabaseServerResponse.setDatabaseVendorDisplayName(databaseServerV4Response.getDatabaseVendorDisplayName());
    stackDatabaseServerResponse.setCreationDate(databaseServerV4Response.getCreationDate());
    if (databaseServerV4Response.getResourceStatus() != null) {
        stackDatabaseServerResponse.setResourceStatus(resourceStatusToDatabaseServerResourceStatus(databaseServerV4Response.getResourceStatus()));
    }
    if (databaseServerV4Response.getStatus() != null) {
        stackDatabaseServerResponse.setStatus(statusToDatabaseServerStatus(databaseServerV4Response.getStatus()));
    }
    stackDatabaseServerResponse.setStatusReason(databaseServerV4Response.getStatusReason());
    stackDatabaseServerResponse.setClusterCrn(databaseServerV4Response.getClusterCrn());
    if (databaseServerV4Response.getSslConfig() != null) {
        SslConfigV4Response sslConfig = databaseServerV4Response.getSslConfig();
        DatabaseServerSslConfig databaseServerSslConfig = new DatabaseServerSslConfig();
        databaseServerSslConfig.setSslCertificates(sslConfig.getSslCertificates());
        if (sslConfig.getSslMode() != null) {
            databaseServerSslConfig.setSslMode(sslModeToDatabaseServerSslMode(sslConfig.getSslMode()));
        }
        if (sslConfig.getSslCertificateType() != null) {
            databaseServerSslConfig.setSslCertificateType(sslCertificateTypeToDatabaseServerSslCertificateType(sslConfig.getSslCertificateType()));
        }
        stackDatabaseServerResponse.setSslConfig(databaseServerSslConfig);
    }
    return stackDatabaseServerResponse;
}
Also used : StackDatabaseServerResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response) DatabaseServerSslConfig(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)

Example 29 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class ClusterRepairServiceTest method repairShouldFailIfNotAvailableDatabaseExistsForCluster.

@Test
public void repairShouldFailIfNotAvailableDatabaseExistsForCluster() {
    cluster.setDatabaseServerCrn("dbCrn");
    when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
    DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
    databaseServerV4Response.setStatus(STOPPED);
    when(redbeamsClientService.getByCrn(eq("dbCrn"))).thenReturn(databaseServerV4Response);
    when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
    when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
    BadRequestException exception = assertThrows(BadRequestException.class, () -> {
        ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.repairHostGroups(1L, Set.of("hostGroup1"), false));
    });
    assertEquals("Database dbCrn is not in AVAILABLE status, could not start repair.", exception.getMessage());
    verifyEventArguments(CLUSTER_MANUALRECOVERY_COULD_NOT_START, "Database dbCrn is not in AVAILABLE status, could not start repair.");
    verifyNoInteractions(stackUpdater);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Test(org.junit.jupiter.api.Test)

Example 30 with DatabaseServerV4Response

use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.

the class DatabaseServiceTest method shouldCallStopAndWaitForStoppedStatus.

@Test
public void shouldCallStopAndWaitForStoppedStatus() {
    SdxCluster cluster = new SdxCluster();
    cluster.setDatabaseCrn(DATABASE_CRN);
    DatabaseServerV4Response databaseServerV4Response = mock(DatabaseServerV4Response.class);
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(databaseServerV4Endpoint.getByCrn(DATABASE_CRN)).thenReturn(databaseServerV4Response);
    when(databaseServerV4Response.getStatus()).thenReturn(Status.STOPPED);
    underTest.stop(cluster);
    verify(databaseServerV4Endpoint).stop(DATABASE_CRN);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)54 Test (org.junit.jupiter.api.Test)27 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)16 SslConfigV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)12 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)9 DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)7 Test (org.junit.Test)6 StackDatabaseServerResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.StackDatabaseServerResponse)5 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)5 DatabaseServerSslConfig (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseServerSslConfig)4 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)4 DatabaseServerStatusV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response)4 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)4 Date (java.util.Date)4 RDSConfig (com.sequenceiq.cloudbreak.domain.RDSConfig)3 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)3 NotFoundException (javax.ws.rs.NotFoundException)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3