use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class ExternalStageStatisticsCollectorTest method testLogTimeMeasurementShouldCallDoLogTimeMeasurementWhenCalled.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void testLogTimeMeasurementShouldCallDoLogTimeMeasurementWhenCalled(final boolean countdown) {
// given
final StageTimeMeasurement measurement = new StageTimeMeasurement(UUID.randomUUID(), ExternalStageStatisticsCollectorTest.class.getName(), StageTimeMeasurement.CLASS_ONLY, StageResult.SUCCESS, 0, 0);
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER);
final ExternalStageStatisticsCollector underTest = spy(new NoOpExternalStageStatisticsCollector(CONTEXT, matcher, countdown));
// when
underTest.logTimeMeasurement(measurement);
// then
verify(underTest).doLogTimeMeasurement(eq(CONTEXT), eq(matcher), eq(countdown), same(measurement));
}
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 DataSource dataSource = H2DataSourceProvider.createDefaultDataSource(PORT_NUMBER);
final Map<String, Consumer<AbortMissionCommandOps>> plan = new HashMap<>();
plan.put(STATIC_FIRE, ops -> {
final StageStatisticsCollectorFactory factory = getCollectorFactory(STATIC_FIRE, dataSource);
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, dataSource);
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 LaunchSequenceTemplateTest method addEvaluatorMockWithSpyLogger.
private Set<MissionHealthCheckEvaluator> addEvaluatorMockWithSpyLogger(final Set<MissionHealthCheckEvaluator> evaluators, final boolean aborting) {
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
final MissionHealthCheckEvaluator evaluator = mock(MissionHealthCheckEvaluator.class);
when(evaluator.countdownLogger()).thenReturn(spy(new StageStatisticsCollector(matcher)));
when(evaluator.missionLogger()).thenReturn(spy(new StageStatisticsCollector(matcher)));
when(evaluator.shouldAbort()).thenReturn(aborting);
when(evaluator.shouldAbortCountdown()).thenReturn(aborting);
evaluators.add(evaluator);
return evaluators;
}
use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.
the class RmiBackedStageStatisticsCollectorIntegrationTest method testGetSnapshotShouldCountAndGroupMeasurementWhenCalled.
@ParameterizedTest
@MethodSource("measurementProvider")
void testGetSnapshotShouldCountAndGroupMeasurementWhenCalled(final List<StageTimeMeasurement> measurements) throws RemoteException {
// given
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
final Registry registry = RmiServiceProvider.lookupRegistry(port);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final RmiBackedStageStatisticsCollector underTestCountdown = new RmiBackedStageStatisticsCollector(contextName, matcher, registry, true);
final RmiBackedStageStatisticsCollector underTestMission = new RmiBackedStageStatisticsCollector(contextName, matcher, registry, false);
for (final StageTimeMeasurement m : measurements) {
final boolean countdown = m.getTestCaseId().equals(CLASS_ONLY);
service.insertStageTimeMeasurement(contextName, MATCHER_PREFIX, countdown, new RmiStageTimeMeasurement(m));
}
// 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 RmiBackedStageStatisticsCollectorIntegrationTest method testFetchAllShouldReturnAllSavedMeasurementsInTheRightOrderWhenCalled.
@ParameterizedTest
@MethodSource("measurementProvider")
void testFetchAllShouldReturnAllSavedMeasurementsInTheRightOrderWhenCalled(final List<StageTimeMeasurement> measurements) throws RemoteException {
// given
final boolean countdown = false;
final Registry registry = RmiServiceProvider.lookupRegistry(port);
final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
when(matcher.getName()).thenReturn(MATCHER_PREFIX);
final RmiBackedStageStatisticsCollector underTest = new RmiBackedStageStatisticsCollector(contextName, matcher, registry, countdown);
for (final StageTimeMeasurement m : measurements) {
service.insertStageTimeMeasurement(contextName, MATCHER_PREFIX, countdown, new RmiStageTimeMeasurement(m));
}
// 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