Search in sources :

Example 21 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 22 with DatabaseServerV4Response

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

the class DatabaseObtainerServiceTest method attemptResultObtained.

@Test
void attemptResultObtained() throws JsonProcessingException {
    when(clusterPollingCheckerService.checkClusterCancelledState(any(), anyBoolean())).thenReturn(null);
    when(redbeamsClient.getByCrn(anyString())).thenReturn(new DatabaseServerV4Response());
    AttemptResult<Object> attemptResult = AttemptResults.justContinue();
    when(databaseCriteriaResolver.resolveResultByCriteria(any(), any(), any())).thenReturn(attemptResult);
    AttemptResult<Object> result = underTest.obtainAttemptResult(cluster, DatabaseOperation.CREATION, "crn", true);
    assertThat(result.getState()).isEqualTo(attemptResult.getState());
    assertThat(result.getResult()).isNull();
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Test(org.junit.jupiter.api.Test)

Example 23 with DatabaseServerV4Response

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

the class ExternalDatabaseServiceTest method terminateDatabase.

@ParameterizedTest
@ValueSource(booleans = { false, true })
void terminateDatabase(boolean forced) throws JsonProcessingException {
    Cluster cluster = new Cluster();
    cluster.setDatabaseServerCrn(RDBMS_CRN);
    DatabaseServerV4Response deleteResponse = new DatabaseServerV4Response();
    deleteResponse.setCrn(RDBMS_CRN);
    when(databaseObtainerService.obtainAttemptResult(eq(cluster), eq(DatabaseOperation.DELETION), eq(RDBMS_CRN), eq(false))).thenReturn(AttemptResults.finishWith(new DatabaseServerV4Response()));
    when(redbeamsClient.deleteByCrn(any(), anyBoolean())).thenReturn(deleteResponse);
    underTest.terminateDatabase(cluster, DatabaseAvailabilityType.HA, environmentResponse, forced);
    ArgumentCaptor<Boolean> forceCaptor = ArgumentCaptor.forClass(Boolean.class);
    verify(redbeamsClient).deleteByCrn(eq(RDBMS_CRN), forceCaptor.capture());
    assertThat(forceCaptor.getValue()).isEqualTo(forced);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with DatabaseServerV4Response

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

the class ExternalDatabaseServiceTest method startDatabase.

@Test
void startDatabase() throws JsonProcessingException {
    Cluster cluster = new Cluster();
    cluster.setDatabaseServerCrn(RDBMS_CRN);
    DatabaseServerV4Response deleteResponse = new DatabaseServerV4Response();
    deleteResponse.setCrn(RDBMS_CRN);
    when(databaseObtainerService.obtainAttemptResult(eq(cluster), eq(DatabaseOperation.START), eq(RDBMS_CRN), eq(false))).thenReturn(AttemptResults.finishWith(new DatabaseServerV4Response()));
    underTest.startDatabase(cluster, DatabaseAvailabilityType.HA, environmentResponse);
    verify(redbeamsClient).startByCrn(RDBMS_CRN);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with DatabaseServerV4Response

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

the class ExternalDatabaseServiceTest method provisionDatabaseWhenStackIsNullOnCluster.

@Test
void provisionDatabaseWhenStackIsNullOnCluster() throws JsonProcessingException {
    DatabaseServerStatusV4Response createResponse = new DatabaseServerStatusV4Response();
    createResponse.setResourceCrn(RDBMS_CRN);
    Cluster cluster = spy(new Cluster());
    cluster.setStack(null);
    when(redbeamsClient.create(any())).thenReturn(createResponse);
    when(databaseObtainerService.obtainAttemptResult(eq(cluster), eq(DatabaseOperation.CREATION), eq(RDBMS_CRN), eq(true))).thenReturn(AttemptResults.finishWith(new DatabaseServerV4Response()));
    underTest.provisionDatabase(cluster, DatabaseAvailabilityType.NON_HA, environmentResponse);
    verify(redbeamsClient, never()).getByClusterCrn(nullable(String.class), nullable(String.class));
    ArgumentCaptor<DatabaseServerParameter> serverParameterCaptor = ArgumentCaptor.forClass(DatabaseServerParameter.class);
    verify(redbeamsClient).create(any(AllocateDatabaseServerV4Request.class));
    verify(cluster).setDatabaseServerCrn(RDBMS_CRN);
    verify(dbServerParameterDecorator).setParameters(any(), serverParameterCaptor.capture());
    verify(clusterRepository).save(cluster);
    DatabaseServerParameter paramValue = serverParameterCaptor.getValue();
    assertThat(paramValue.isHighlyAvailable()).isFalse();
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) DatabaseServerStatusV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DatabaseServerParameter(com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter) 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