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