use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorTest method testDoFetchAllShouldThrowStrongbackExceptionWhenCaughtException.
@Test
void testDoFetchAllShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
when(service.fetchMeasurementsFor(anyString(), anyString(), anyBoolean())).thenThrow(new RemoteException());
final Registry registry = mock(Registry.class);
when(registry.lookup(eq(RmiServerConstants.SERVICE_NAME))).thenReturn(service);
final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(CONTEXT, matcher, registry, true);
// when
Assertions.assertThrows(StrongbackException.class, () -> underTest.doFetchAll(CONTEXT, matcher, true));
// then + exception
final InOrder inOrder = inOrder(registry, service, matcher);
inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
inOrder.verify(service).fetchMeasurementsFor(eq(CONTEXT), eq(MATCHER), eq(true));
inOrder.verifyNoMoreInteractions();
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorTest method testDoGetSnapshotShouldThrowStrongbackExceptionWhenCaughtException.
@Test
void testDoGetSnapshotShouldThrowStrongbackExceptionWhenCaughtException() throws Exception {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final LaunchStatisticsService service = mock(LaunchStatisticsService.class);
when(service.getSnapshot(anyString(), anyString(), anyBoolean())).thenThrow(new RemoteException());
final Registry registry = mock(Registry.class);
when(registry.lookup(eq(RmiServerConstants.SERVICE_NAME))).thenReturn(service);
final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(CONTEXT, matcher, registry, true);
// when
Assertions.assertThrows(StrongbackException.class, () -> underTest.doGetSnapshot(CONTEXT, matcher, true));
// then + exception
final InOrder inOrder = inOrder(registry, service, matcher);
inOrder.verify(registry).lookup(eq(RmiServerConstants.SERVICE_NAME));
inOrder.verify(service).getSnapshot(eq(CONTEXT), eq(MATCHER), eq(true));
inOrder.verifyNoMoreInteractions();
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class H2BackedStageStatisticsCollectorIntegrationTest method testGetSnapshotShouldCountAndGroupMeasurementWhenCalled.
@ParameterizedTest
@MethodSource("measurementProvider")
void testGetSnapshotShouldCountAndGroupMeasurementWhenCalled(final List<StageTimeMeasurement> measurements) {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final H2BackedStageStatisticsCollector underTestCountdown = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, true);
final H2BackedStageStatisticsCollector underTestMission = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, false);
jdbi.withExtension(LaunchStatisticsRepository.class, dao -> {
measurements.forEach(m -> {
final boolean countdown = m.getTestCaseId().equals(CLASS_ONLY);
dao.insertStageTimeMeasurement(contextName, MATCHER_PREFIX, countdown, m);
});
return null;
});
// when
final StageStatisticsSnapshot actualCountdown = underTestCountdown.getSnapshot();
final StageStatisticsSnapshot actualMission = underTestMission.getSnapshot();
// then
verify(matcher, atLeastOnce()).getName();
assertSnapshotCountersMatch(measurements, actualCountdown, actualMission);
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class MissionOutlineDefinition method defineOutline.
@Override
@SuppressWarnings("checkstyle:MagicNumber")
protected Map<String, Consumer<AbortMissionCommandOps>> defineOutline() {
final DependencyNameExtractor extractor = new TagDependencyNameExtractor();
final Registry registry = RmiServiceProvider.lookupRegistry(RmiServerConstants.DEFAULT_RMI_PORT);
final Map<String, Consumer<AbortMissionCommandOps>> plan = new HashMap<>();
plan.put(STATIC_FIRE, ops -> {
final StageStatisticsCollectorFactory factory = getCollectorFactory(STATIC_FIRE, registry);
final MissionHealthCheckMatcher sideBoosterMatcher = matcher().dependencyWith(SIDE_BOOSTER).extractor(extractor).build();
final MissionHealthCheckMatcher centerCoreMatcher = matcher().dependencyWith(CENTER_CORE).extractor(extractor).build();
ops.registerHealthCheck(percentageBasedEvaluator(sideBoosterMatcher, factory).abortThreshold(10).burnInTestCount(2).build());
ops.registerHealthCheck(percentageBasedEvaluator(centerCoreMatcher, factory).build());
});
plan.put(PARALLEL, ops -> {
final StageStatisticsCollectorFactory factory = getCollectorFactory(PARALLEL, registry);
final MissionHealthCheckMatcher anyClassMatcher = matcher().anyClass().build();
ops.registerHealthCheck(reportOnlyEvaluator(anyClassMatcher, factory).build());
});
return plan;
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class H2BackedStageStatisticsCollectorIntegrationTest method testFetchAllShouldReturnAllSavedMeasurementsInTheRightOrderWhenCalled.
@ParameterizedTest
@MethodSource("measurementProvider")
void testFetchAllShouldReturnAllSavedMeasurementsInTheRightOrderWhenCalled(final List<StageTimeMeasurement> measurements) {
// given
final boolean countdown = false;
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final H2BackedStageStatisticsCollector underTest = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, countdown);
jdbi.withExtension(LaunchStatisticsRepository.class, dao -> {
measurements.forEach(m -> dao.insertStageTimeMeasurement(contextName, MATCHER_PREFIX, countdown, m));
return null;
});
// when
final List<StageTimeMeasurement> actual = underTest.doFetchAll(contextName, matcher, countdown);
// then
verify(matcher, atLeastOnce()).getName();
Assertions.assertIterableEquals(measurements.stream().sorted().collect(Collectors.toList()), actual);
}
Aggregations