Search in sources :

Example 1 with StageStatisticsSnapshot

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;
}
Also used : StageStatisticsSnapshot(com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot)

Example 2 with StageStatisticsSnapshot

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;
}
Also used : StageStatisticsSnapshot(com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot)

Example 3 with StageStatisticsSnapshot

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);
}
Also used : StageStatisticsSnapshot(com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with StageStatisticsSnapshot

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);
}
Also used : StageStatisticsSnapshot(com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) Registry(java.rmi.registry.Registry) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with StageStatisticsSnapshot

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());
}
Also used : StageStatisticsSnapshot(com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

StageStatisticsSnapshot (com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 MissionHealthCheckMatcher (com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)2 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)1 Registry (java.rmi.registry.Registry)1