Search in sources :

Example 11 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class DatabaseServerSslCertificateSyncServiceTest method syncSslCertificateIfNeededTestWhenSuccessNoSsl.

@Test
void syncSslCertificateIfNeededTestWhenSuccessNoSsl() throws Exception {
    DBStack dbStack = getDBStack();
    dbStack.setCloudPlatform(CloudPlatform.AZURE.toString());
    underTest.syncSslCertificateIfNeeded(cloudContext, cloudCredential, dbStack, databaseStack);
    assertThat(dbStack.getSslConfig()).isNull();
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class RedbeamsCreationServiceTest method testLaunchDatabaseServer.

@Test
public void testLaunchDatabaseServer() throws Exception {
    when(cloudPlatformConnectors.get(any(CloudPlatformVariant.class))).thenReturn(connector);
    when(connector.resources().getDBStackTemplate()).thenReturn(TEMPLATE);
    Crn crn = Crn.fromString("crn:cdp:iam:us-west-1:1234:database:2312312");
    when(dbStackService.findByNameAndEnvironmentCrn(DB_STACK_NAME, ENVIRONMENT_CRN)).thenReturn(Optional.empty());
    when(dbStackService.save(dbStack)).thenReturn(dbStack);
    when(databaseServerConfigService.findByEnvironmentCrnAndClusterCrn(ENVIRONMENT_CRN, CLUSTER_CRN)).thenReturn(Optional.empty());
    DBStack launchedStack = underTest.launchDatabaseServer(dbStack, CLUSTER_CRN);
    assertThat(launchedStack).isEqualTo(dbStack);
    verify(dbStackService).save(dbStack);
    assertThat(dbStack.getResourceCrn()).isEqualTo(crn.toString());
    assertThat(dbStack.getTemplate()).isEqualTo(TEMPLATE);
    ArgumentCaptor<DatabaseServerConfig> databaseServerConfigCaptor = ArgumentCaptor.forClass(DatabaseServerConfig.class);
    verify(databaseServerConfigService).create(databaseServerConfigCaptor.capture(), eq(RedbeamsCreationService.DEFAULT_WORKSPACE), eq(false));
    DatabaseServerConfig databaseServerConfig = databaseServerConfigCaptor.getValue();
    assertThat(databaseServerConfig.getResourceStatus()).isEqualTo(ResourceStatus.SERVICE_MANAGED);
    assertThat(databaseServerConfig.getAccountId()).isEqualTo(ACCOUNT_ID);
    assertThat(databaseServerConfig.getName()).isEqualTo(DB_STACK_NAME);
    assertThat(databaseServerConfig.getDescription()).isEqualTo(DB_STACK_DESCRIPTION);
    assertThat(databaseServerConfig.getEnvironmentId()).isEqualTo(ENVIRONMENT_CRN);
    assertThat(databaseServerConfig.getConnectionDriver()).isEqualTo(CONNECTION_DRIVER);
    assertThat(databaseServerConfig.getConnectionUserName()).isEqualTo(ROOT_USER_NAME);
    assertThat(databaseServerConfig.getConnectionPassword()).isEqualTo(ROOT_PASSWORD);
    assertThat(databaseServerConfig.getDatabaseVendor()).isEqualTo(DatabaseVendor.POSTGRES);
    assertThat(databaseServerConfig.getHost()).isNull();
    assertThat(databaseServerConfig.getPort()).isNull();
    assertThat(databaseServerConfig.getResourceCrn()).isEqualTo(crn);
    assertThat(databaseServerConfig.getDbStack().isPresent()).isTrue();
    assertThat(databaseServerConfig.getDbStack().get()).isEqualTo(dbStack);
    ArgumentCaptor<RedbeamsEvent> eventCaptor = ArgumentCaptor.forClass(RedbeamsEvent.class);
    verify(flowManager).notify(eq(RedbeamsProvisionEvent.REDBEAMS_PROVISION_EVENT.selector()), eventCaptor.capture());
    RedbeamsEvent provisionEvent = eventCaptor.getValue();
    assertThat(provisionEvent.selector()).isEqualTo(RedbeamsProvisionEvent.REDBEAMS_PROVISION_EVENT.selector());
    assertThat(provisionEvent.getResourceId()).isEqualTo(dbStack.getId());
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) DatabaseServerConfig(com.sequenceiq.redbeams.domain.DatabaseServerConfig) CloudPlatformVariant(com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant) RedbeamsEvent(com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) Test(org.junit.jupiter.api.Test)

Example 13 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class RedbeamsCreationServiceTest method setup.

@BeforeEach
public void setup() {
    dbStack = new DBStack();
    // this wouldn't really be set before launchDatabaseServer is called
    dbStack.setId(DB_STACK_ID);
    dbStack.setName(DB_STACK_NAME);
    dbStack.setDescription(DB_STACK_DESCRIPTION);
    dbStack.setEnvironmentId(ENVIRONMENT_CRN);
    dbStack.setCloudPlatform(CLOUD_PLATFORM);
    dbStack.setPlatformVariant(PLATFORM_VARIANT);
    dbStack.setUserName("username");
    dbStack.setOwnerCrn(Crn.fromString("crn:cdp:iam:us-west-1:1234:user:234123"));
    dbStack.setResourceCrn("crn:cdp:iam:us-west-1:1234:database:2312312");
    DatabaseServer databaseServer = new DatabaseServer();
    dbStack.setDatabaseServer(databaseServer);
    databaseServer.setAccountId(ACCOUNT_ID);
    databaseServer.setConnectionDriver(CONNECTION_DRIVER);
    databaseServer.setRootUserName(ROOT_USER_NAME);
    databaseServer.setRootPassword(ROOT_PASSWORD);
    databaseServer.setDatabaseVendor(DatabaseVendor.POSTGRES);
    databaseServer.setPort(PORT);
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) DatabaseServer(com.sequenceiq.redbeams.domain.stack.DatabaseServer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class AbstractRedbeamsTerminationActionTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    dbStack = new DBStack();
    dbStack.setId(101L);
    dbStack.setName("mystack");
    dbStack.setRegion("us-east-1");
    dbStack.setAvailabilityZone("us-east-1b");
    dbStack.setCloudPlatform("AWS");
    dbStack.setPlatformVariant("GovCloud");
    dbStack.setEnvironmentId("myenv");
    dbStack.setOwnerCrn(Crn.safeFromString("crn:cdp:iam:us-west-1:cloudera:user:bob@cloudera.com"));
    dbStack.setResourceCrn(CrnTestUtil.getDatabaseCrnBuilder().setAccountId("acc").setResource("resource").build().toString());
    credential = new Credential("userId", null, "userCrn", "account");
    cloudCredential = new CloudCredential("userId", "userName", "account");
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Credential(com.sequenceiq.redbeams.dto.Credential) DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) Before(org.junit.Before)

Example 15 with DBStack

use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.

the class DeregisterDatabaseServerHandlerTest method testNotDeleteDatabaseServerConfigIfExists.

@Test
public void testNotDeleteDatabaseServerConfigIfExists() {
    mockDeregisterEvent();
    DBStack dbStack = new DBStack();
    dbStack.setResourceCrn(RESOURCE_CRN);
    when(dbStackService.getById(RESOURCE_ID)).thenReturn(dbStack);
    when(databaseServerConfigService.getByCrn(any(Crn.class))).thenReturn(Optional.empty());
    underTest.accept(event);
    verify(databaseServerConfigService, times(0)).delete(any());
    verify(eventBus).notify(any(Object.class), any(Event.class));
}
Also used : DBStack(com.sequenceiq.redbeams.domain.stack.DBStack) Event(reactor.bus.Event) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) Test(org.junit.jupiter.api.Test)

Aggregations

DBStack (com.sequenceiq.redbeams.domain.stack.DBStack)83 Test (org.junit.jupiter.api.Test)28 DatabaseServerConfig (com.sequenceiq.redbeams.domain.DatabaseServerConfig)17 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 Test (org.junit.Test)13 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)7 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)7 DatabaseStack (com.sequenceiq.cloudbreak.cloud.model.DatabaseStack)7 DatabaseServerV4Response (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.responses.DatabaseServerV4Response)7 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)6 SslConfig (com.sequenceiq.redbeams.domain.stack.SslConfig)6 Credential (com.sequenceiq.redbeams.dto.Credential)6 RedbeamsFailureEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent)6 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)5 CloudDatabaseServerSslCertificate (com.sequenceiq.cloudbreak.cloud.model.database.CloudDatabaseServerSslCertificate)5 RedbeamsEvent (com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsEvent)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Location (com.sequenceiq.cloudbreak.cloud.model.Location)4