use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class UpdateDatabaseServerRegistrationHandlerTest method doAcceptTestWhenFailureDatabaseServerConfigNotFound.
@Test
void doAcceptTestWhenFailureDatabaseServerConfigNotFound() throws Exception {
DBStack dbStack = getDBStack();
when(dbStackService.getById(anyLong())).thenReturn(dbStack);
UpdateDatabaseServerRegistrationRequest request = getRequest();
when(event.getData()).thenReturn(request);
when(databaseServerConfigService.getByCrn(CRN)).thenReturn(Optional.empty());
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
verifyFailureEvent(selectable);
Exception e = extractException(selectable);
assertThat(e).isInstanceOf(IllegalStateException.class);
assertThat(e).hasMessage("Cannot find database server " + CRN);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class UpdateDatabaseServerRegistrationHandlerTest method doAcceptTestWhenFailureCloudResourcePortNotFound.
@Test
void doAcceptTestWhenFailureCloudResourcePortNotFound() throws Exception {
DBStack dbStack = getDBStack();
when(dbStackService.getById(anyLong())).thenReturn(dbStack);
UpdateDatabaseServerRegistrationRequest request = getRequest();
when(event.getData()).thenReturn(request);
when(cloudResourceHelper.getResourceTypeFromList(eq(ResourceType.RDS_HOSTNAME), any())).thenReturn(Optional.of(mock(CloudResource.class)));
when(cloudResourceHelper.getResourceTypeFromList(eq(ResourceType.RDS_PORT), any())).thenReturn(Optional.empty());
DatabaseServerConfig originalDatabaseServerConfig = getOriginalDatabaseServerConfig();
when(databaseServerConfigService.getByCrn(CRN)).thenReturn(Optional.of(originalDatabaseServerConfig));
Selectable selectable = new ExceptionCatcherEventHandlerTestSupport<>(underTest).doAccept(event);
verifyFailureEvent(selectable);
Exception e = extractException(selectable);
assertThat(e).isInstanceOf(IllegalStateException.class);
assertThat(e).hasMessage("DB port not found for allocated database.");
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class StartDatabaseServerFailedActionTest method shouldUpdateStatusWithUknownErrorAndIncrementMetricOnPrepare.
@Test
public void shouldUpdateStatusWithUknownErrorAndIncrementMetricOnPrepare() {
RedbeamsFailureEvent event = new RedbeamsFailureEvent(RESOURCE_ID, null);
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.START_FAILED, "Unknown error")).thenReturn(dbStackOptional);
victim.prepareExecution(event, null);
verify(metricService).incrementMetricCounter(MetricType.DB_START_FAILED, dbStackOptional);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class StartDatabaseServerFailedActionTest method shouldUpdateStatusAndIncrementMetricOnPrepare.
@Test
public void shouldUpdateStatusAndIncrementMetricOnPrepare() {
RedbeamsFailureEvent event = new RedbeamsFailureEvent(RESOURCE_ID, exception);
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.START_FAILED, null)).thenReturn(dbStackOptional);
victim.prepareExecution(event, null);
verify(metricService).incrementMetricCounter(MetricType.DB_START_FAILED, dbStackOptional);
}
use of com.sequenceiq.redbeams.domain.stack.DBStack in project cloudbreak by hortonworks.
the class StartDatabaseServerFinishedActionTest method shouldUpdateStatusOnPrepare.
@Test
public void shouldUpdateStatusOnPrepare() {
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.STARTED)).thenReturn(dbStackOptional);
StartDatabaseServerSuccess event = new StartDatabaseServerSuccess(RESOURCE_ID);
victim.prepareExecution(event, null);
verify(dbStackStatusUpdater).updateStatus(RESOURCE_ID, DetailedDBStackStatus.STARTED);
verify(metricService).incrementMetricCounter(MetricType.DB_START_FINISHED, dbStackOptional);
}
Aggregations