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;
}
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();
}
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);
}
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);
}
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();
}
Aggregations