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