use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class DatabaseServerV4ControllerTest method testRelease.
@Test
public void testRelease() {
when(service.release(SERVER_CRN)).thenReturn(server);
when(databaseServerConfigToDatabaseServerV4ResponseConverter.convert(server)).thenReturn(serverResponse);
DatabaseServerV4Response response = underTest.release(SERVER_CRN);
assertEquals(serverResponse.getId().longValue(), response.getId().longValue());
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class DatabaseServerV4ControllerTest method testGetByName.
@Test
public void testGetByName() {
when(service.getByName(DatabaseServerV4Controller.DEFAULT_WORKSPACE, ENVIRONMENT_CRN, SERVER_NAME)).thenReturn(server);
when(databaseServerConfigToDatabaseServerV4ResponseConverter.convert(any())).thenReturn(serverResponse);
DatabaseServerV4Response response = underTest.getByName(ENVIRONMENT_CRN, SERVER_NAME);
assertEquals(serverResponse.getId().longValue(), response.getId().longValue());
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class ClusterRepairServiceTest method testCanRepairCoreTypeNode.
@Test
public void testCanRepairCoreTypeNode() {
cluster.setDatabaseServerCrn("dbCrn");
HostGroup hostGroup1 = new HostGroup();
hostGroup1.setName("hostGroup1");
hostGroup1.setRecoveryMode(RecoveryMode.MANUAL);
InstanceMetaData host1 = getHost("host1", hostGroup1.getName(), InstanceStatus.SERVICES_RUNNING, InstanceGroupType.CORE);
hostGroup1.setInstanceGroup(host1.getInstanceGroup());
when(hostGroupService.getByCluster(eq(1L))).thenReturn(Set.of(hostGroup1));
when(stackService.getByIdWithListsInTransaction(1L)).thenReturn(stack);
when(freeipaService.checkFreeipaRunning(stack.getEnvironmentCrn())).thenReturn(true);
when(environmentService.environmentStatusInDesiredState(stack, Set.of(EnvironmentStatus.AVAILABLE))).thenReturn(true);
DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
databaseServerV4Response.setStatus(AVAILABLE);
when(redbeamsClientService.getByCrn(eq("dbCrn"))).thenReturn(databaseServerV4Response);
when(stackStopRestrictionService.isInfrastructureStoppable(stack)).thenReturn(StopRestrictionReason.NONE);
Result result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.repairWithDryRun(stack.getId()));
assertTrue(result.isSuccess());
verifyNoInteractions(stackUpdater, flowManager, resourceService);
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class DatabaseServiceTest method createDatabaseServerV4Response.
private DatabaseServerV4Response createDatabaseServerV4Response() {
DatabaseServerV4Response databaseServerV4Response = new DatabaseServerV4Response();
databaseServerV4Response.setCrn(DATABASE_CRN);
databaseServerV4Response.setName("databaseName");
databaseServerV4Response.setDescription("description");
databaseServerV4Response.setEnvironmentCrn("envCrn");
databaseServerV4Response.setHost("host");
databaseServerV4Response.setPort(1234);
databaseServerV4Response.setDatabaseVendor("vendor");
databaseServerV4Response.setDatabaseVendorDisplayName("vendorName");
databaseServerV4Response.setCreationDate(new Date().getTime());
databaseServerV4Response.setResourceStatus(ResourceStatus.SERVICE_MANAGED);
databaseServerV4Response.setStatus(Status.AVAILABLE);
databaseServerV4Response.setStatusReason("Everything is great");
databaseServerV4Response.setClusterCrn(CLUSTER_CRN);
return databaseServerV4Response;
}
use of com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response in project cloudbreak by hortonworks.
the class DatabaseServerConfigToDatabaseServerV4ResponseConverter method convert.
public DatabaseServerV4Response convert(DatabaseServerConfig source) {
DatabaseServerV4Response response = new DatabaseServerV4Response();
response.setId(source.getId());
response.setCrn(source.getResourceCrn().toString());
response.setName(source.getName());
response.setDescription(source.getDescription());
response.setHost(source.getHost());
response.setPort(source.getPort());
response.setDatabaseVendor(source.getDatabaseVendor().databaseType());
response.setDatabaseVendorDisplayName(source.getDatabaseVendor().displayName());
response.setConnectionDriver(source.getConnectionDriver());
response.setConnectionUserName(stringToSecretResponseConverter.convert(source.getConnectionUserNameSecret()));
response.setConnectionPassword(stringToSecretResponseConverter.convert(source.getConnectionPasswordSecret()));
response.setCreationDate(source.getCreationDate());
response.setEnvironmentCrn(source.getEnvironmentId());
response.setClusterCrn(source.getClusterCrn());
response.setResourceStatus(source.getResourceStatus());
if (source.getDbStack().isPresent()) {
DBStack dbStack = source.getDbStack().get();
response.setStatus(dbStack.getStatus());
response.setStatusReason(dbStack.getStatusReason());
if (dbStack.getSslConfig() != null) {
SslConfig sslConfig = dbStack.getSslConfig();
SslConfigV4Response sslConfigV4Response = new SslConfigV4Response();
sslConfigV4Response.setSslCertificates(sslConfig.getSslCertificates());
sslConfigV4Response.setSslCertificateType(sslConfig.getSslCertificateType());
sslConfigV4Response.setSslMode(NONE.equals(sslConfig.getSslCertificateType()) ? DISABLED : ENABLED);
String cloudPlatform = dbStack.getCloudPlatform();
String region = dbStack.getRegion();
// TODO Add SslConfig.sslCertificateMaxVersion that is kept up-to-date (mostly for GCP), use getMaxVersionByPlatform() as fallback
sslConfigV4Response.setSslCertificateHighestAvailableVersion(databaseServerSslCertificateConfig.getMaxVersionByCloudPlatformAndRegion(cloudPlatform, region));
sslConfigV4Response.setSslCertificateActiveVersion(Optional.ofNullable(sslConfig.getSslCertificateActiveVersion()).orElse(databaseServerSslCertificateConfig.getLegacyMaxVersionByCloudPlatformAndRegion(cloudPlatform, region)));
sslConfigV4Response.setSslCertificateActiveCloudProviderIdentifier(Optional.ofNullable(sslConfig.getSslCertificateActiveCloudProviderIdentifier()).orElse(databaseServerSslCertificateConfig.getLegacyCloudProviderIdentifierByCloudPlatformAndRegion(cloudPlatform, region)));
response.setSslConfig(sslConfigV4Response);
}
} else if (source.getHost() != null && source.getPort() != null) {
response.setStatus(Status.AVAILABLE);
} else {
response.setStatus(Status.UNKNOWN);
}
if (response.getSslConfig() == null) {
response.setSslConfig(new SslConfigV4Response());
}
return response;
}
Aggregations