Search in sources :

Example 31 with DatabaseServerV4Response

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

the class DatabaseCriteriaResolverTest method setUp.

@BeforeEach
void setUp() {
    database = new DatabaseServerV4Response();
    cluster = new Cluster();
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 32 with DatabaseServerV4Response

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

the class ExternalDatabaseServiceTest method provisionDatabase.

@ParameterizedTest
@EnumSource(DatabaseAvailabilityType.class)
void provisionDatabase(DatabaseAvailabilityType availabilty) throws JsonProcessingException {
    Assumptions.assumeTrue(!availabilty.isEmbedded());
    DatabaseServerStatusV4Response createResponse = new DatabaseServerStatusV4Response();
    createResponse.setResourceCrn(RDBMS_CRN);
    Cluster cluster = spy(new Cluster());
    Stack stack = new Stack();
    stack.setResourceCrn(CLUSTER_CRN);
    cluster.setStack(stack);
    when(redbeamsClient.getByClusterCrn(nullable(String.class), nullable(String.class))).thenReturn(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, availabilty, environmentResponse);
    ArgumentCaptor<DatabaseServerParameter> serverParameterCaptor = ArgumentCaptor.forClass(DatabaseServerParameter.class);
    verify(redbeamsClient).getByClusterCrn(ENV_CRN, CLUSTER_CRN);
    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()).isEqualTo(availabilty == DatabaseAvailabilityType.HA);
}
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) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) DatabaseServerParameter(com.sequenceiq.cloudbreak.service.externaldatabase.model.DatabaseServerParameter) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with DatabaseServerV4Response

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

the class ExternalDatabaseServiceTest method stopDatabase.

@Test
void stopDatabase() throws JsonProcessingException {
    Cluster cluster = spy(new Cluster());
    cluster.setDatabaseServerCrn(RDBMS_CRN);
    DatabaseServerV4Response deleteResponse = new DatabaseServerV4Response();
    deleteResponse.setCrn(RDBMS_CRN);
    when(databaseObtainerService.obtainAttemptResult(eq(cluster), eq(DatabaseOperation.STOP), eq(RDBMS_CRN), eq(false))).thenReturn(AttemptResults.finishWith(new DatabaseServerV4Response()));
    underTest.stopDatabase(cluster, DatabaseAvailabilityType.HA, environmentResponse);
    verify(redbeamsClient).stopByCrn(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 34 with DatabaseServerV4Response

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

the class ExternalDatabaseServiceTest method provisionDatabaseWhenAlreadyExists.

@Test
void provisionDatabaseWhenAlreadyExists() throws JsonProcessingException {
    Cluster cluster = spy(new Cluster());
    Stack stack = new Stack();
    stack.setResourceCrn(CLUSTER_CRN);
    cluster.setStack(stack);
    DatabaseServerV4Response dbServerResponse = new DatabaseServerV4Response();
    dbServerResponse.setCrn(RDBMS_CRN);
    when(redbeamsClient.getByClusterCrn(nullable(String.class), nullable(String.class))).thenReturn(dbServerResponse);
    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).getByClusterCrn(ENV_CRN, CLUSTER_CRN);
    verify(redbeamsClient, never()).create(any(AllocateDatabaseServerV4Request.class));
    verify(dbServerParameterDecorator, never()).setParameters(any(), any());
    verify(cluster).setDatabaseServerCrn(RDBMS_CRN);
    verify(clusterRepository).save(cluster);
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) AllocateDatabaseServerV4Request(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with DatabaseServerV4Response

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

the class DatabaseService method getDatabaseStatus.

private DatabaseServerStatusV4Response getDatabaseStatus(String databaseCrn) {
    DatabaseServerV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> databaseServerV4Endpoint.getByCrn(databaseCrn));
    DatabaseServerStatusV4Response statusResponse = new DatabaseServerStatusV4Response();
    statusResponse.setEnvironmentCrn(response.getEnvironmentCrn());
    statusResponse.setName(response.getName());
    statusResponse.setResourceCrn(response.getCrn());
    statusResponse.setStatus(response.getStatus());
    statusResponse.setStatusReason(response.getStatusReason());
    return statusResponse;
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DatabaseServerStatusV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerStatusV4Response)

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