use of com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluator method shouldAbortInternal.
@Override
protected boolean shouldAbortInternal() {
final StageStatisticsSnapshot snapshot = getMissionStatistics().getSnapshot();
final double totalMissions = snapshot.getTotal();
final boolean isActive = burnInTestCount <= totalMissions;
final double failedOrAborted = snapshot.getNotSuccessful();
final double failurePercentage = (failedOrAborted * DOUBLE_100) / totalMissions;
return isActive && abortThreshold < failurePercentage;
}
use of com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot in project abort-mission by nagyesta.
the class PercentageBasedMissionHealthCheckEvaluator method shouldAbortCountdownInternal.
@Override
protected boolean shouldAbortCountdownInternal() {
final StageStatisticsSnapshot snapshot = getCountdownStatistics().getSnapshot();
final boolean isActive = burnInTestCount <= snapshot.getTotal();
final boolean countdownNeverCompleted = snapshot.getSucceeded() == 0;
return isActive && countdownNeverCompleted;
}
use of com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot in project abort-mission by nagyesta.
the class LaunchStatisticsRepositoryIntegrationTest method testGetSnapshotOfAMatcherShouldReturnTheAggregatedStatusCountsWhenCalled.
@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testGetSnapshotOfAMatcherShouldReturnTheAggregatedStatusCountsWhenCalled(final Map<String, List<StageTimeMeasurement>> input) {
// given
final String matcherName = findMatcherName(input);
jdbi.withExtension(LaunchStatisticsRepository.class, insertAllCallback(input));
// when
final StageStatisticsSnapshot actualCountdown = jdbi.withExtension(LaunchStatisticsRepository.class, dao -> dao.getSnapshot(CONTEXT_NAME, matcherName, true));
final StageStatisticsSnapshot actualMission = jdbi.withExtension(LaunchStatisticsRepository.class, dao -> dao.getSnapshot(CONTEXT_NAME, matcherName, false));
// then
assertSnapshotCountersMatch(input.get(matcherName), actualCountdown, actualMission);
}
use of com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot 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.healthcheck.StageStatisticsSnapshot in project abort-mission by nagyesta.
the class RmiStageStatisticsSnapshotTest method testConvertToStageStatisticsSnapshotShouldConvertAllValuableFieldsWhenCalled.
@ParameterizedTest
@MethodSource("statsProvider")
void testConvertToStageStatisticsSnapshotShouldConvertAllValuableFieldsWhenCalled(final int failed, final int succeeded, final int aborted, final int suppressed) {
// given
final RmiStageStatisticsSnapshot underTest = new RmiStageStatisticsSnapshot(failed, succeeded, aborted, suppressed);
// when
final StageStatisticsSnapshot actual = underTest.toStageStatisticsSnapshot();
// then
Assertions.assertEquals(failed, actual.getFailed());
Assertions.assertEquals(succeeded, actual.getSucceeded());
Assertions.assertEquals(aborted, actual.getAborted());
Assertions.assertEquals(suppressed, actual.getSuppressed());
}
Aggregations