Search in sources :

Example 16 with DatabaseServerV4Response

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());
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Test(org.junit.Test)

Example 17 with DatabaseServerV4Response

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());
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Test(org.junit.Test)

Example 18 with DatabaseServerV4Response

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Result(com.sequenceiq.cloudbreak.service.cluster.model.Result) Test(org.junit.jupiter.api.Test)

Example 19 with DatabaseServerV4Response

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;
}
Also used : DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) Date(java.util.Date)

Example 20 with 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;
}
Also used : SslConfig(com.sequenceiq.redbeams.domain.stack.SslConfig) DatabaseServerV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) SslConfigV4Response(com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.SslConfigV4Response)

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