Search in sources :

Example 31 with MissionHealthCheckMatcher

use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.

the class PercentageBasedMissionHealthCheckEvaluatorTest method testBurnInThresholdsAreWorkingWhenPreparationStepsAreUsed.

@ParameterizedTest
@MethodSource("countdownEvaluatorProvider")
void testBurnInThresholdsAreWorkingWhenPreparationStepsAreUsed(final int burnInCount, final int countdownFailure, final int countdownComplete, final int failureCount, final boolean expectedCountdownAbort) {
    // given
    final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
    final PercentageBasedMissionHealthCheckEvaluator underTest = PercentageBasedMissionHealthCheckEvaluator.builder(anyClass, new MissionStatisticsCollector(anyClass)).abortThreshold(1).burnInTestCount(burnInCount).build();
    // when
    IntStream.range(0, countdownFailure).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(failure()));
    IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(failure()));
    IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(success()));
    final boolean actual = underTest.shouldAbortCountdown();
    // then
    assertEquals(expectedCountdownAbort, actual);
    assertEquals(burnInCount, underTest.getBurnInTestCount());
}
Also used : MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 32 with MissionHealthCheckMatcher

use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.

the class PercentageBasedMissionHealthCheckEvaluatorTest method testShouldAbortCountdownShouldNotCallInternalMethodWhenDisarmed.

@Test
void testShouldAbortCountdownShouldNotCallInternalMethodWhenDisarmed() {
    // given
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    final PercentageBasedMissionHealthCheckEvaluator underTest = spy(PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).abortThreshold(1).build());
    doReturn(true).when(underTest).isDisarmed(eq(ABORT_MISSION_DISARM_COUNTDOWN));
    // when
    underTest.shouldAbortCountdown();
    // then
    verify(underTest, never()).shouldAbortCountdownInternal();
}
Also used : MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with MissionHealthCheckMatcher

use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.

the class ReportOnlyMissionHealthCheckEvaluatorTest method testShouldAbortShouldAlwaysReturnFalseWhenCalled.

@ParameterizedTest
@MethodSource("launchEvaluatorProvider")
void testShouldAbortShouldAlwaysReturnFalseWhenCalled(final int countdownComplete, final int failureCount, final int successCount) {
    // given
    final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
    final ReportOnlyMissionHealthCheckEvaluator underTest = MissionControl.reportOnlyEvaluator(anyClass).build();
    // when
    IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(with(StageResult.FAILURE)));
    IntStream.range(0, successCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(with(StageResult.SUCCESS)));
    IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(with(StageResult.SUCCESS)));
    final boolean actual = underTest.shouldAbort();
    // then
    assertFalse(actual);
}
Also used : MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 34 with MissionHealthCheckMatcher

use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.

the class ReportOnlyMissionHealthCheckEvaluatorTest method testShouldAbortCountdownShouldAlwaysReturnFalseWhenCalled.

@ParameterizedTest
@MethodSource("countdownEvaluatorProvider")
void testShouldAbortCountdownShouldAlwaysReturnFalseWhenCalled(final int countdownFailure, final int countdownComplete, final int failureCount) {
    // given
    final MissionHealthCheckMatcher anyClass = mock(MissionHealthCheckMatcher.class);
    final ReportOnlyMissionHealthCheckEvaluator underTest = MissionControl.reportOnlyEvaluator(anyClass).build();
    // when
    IntStream.range(0, countdownFailure).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(with(StageResult.FAILURE)));
    IntStream.range(0, failureCount).parallel().forEach(i -> underTest.missionLogger().logAndIncrement(with(StageResult.FAILURE)));
    IntStream.range(0, countdownComplete).parallel().forEach(i -> underTest.countdownLogger().logAndIncrement(with(StageResult.SUCCESS)));
    final boolean actual = underTest.shouldAbortCountdown();
    // then
    assertFalse(actual);
}
Also used : MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 35 with MissionHealthCheckMatcher

use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project abort-mission by nagyesta.

the class ClassMatcherTest method testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithClass.

@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithClass(final boolean matches, final String pattern) {
    // given
    final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().classNamePattern(pattern).build();
    // when
    final boolean actual = underTest.matches(this.getClass());
    // then
    assertEquals(matches, actual);
}
Also used : MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

MissionHealthCheckMatcher (com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)47 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)29 MethodSource (org.junit.jupiter.params.provider.MethodSource)21 Test (org.junit.jupiter.api.Test)15 Registry (java.rmi.registry.Registry)7 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)5 MissionHealthCheckEvaluator (com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator)4 LaunchStatisticsService (com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)3 RemoteException (java.rmi.RemoteException)3 NullSource (org.junit.jupiter.params.provider.NullSource)3 ValueSource (org.junit.jupiter.params.provider.ValueSource)3 InOrder (org.mockito.InOrder)3 TagDependencyNameExtractor (com.github.nagyesta.abortmission.booster.jupiter.extractor.TagDependencyNameExtractor)2 DependencyNameExtractor (com.github.nagyesta.abortmission.core.extractor.DependencyNameExtractor)2 StringDependencyNameExtractor (com.github.nagyesta.abortmission.core.extractor.impl.StringDependencyNameExtractor)2 StageStatisticsCollectorFactory (com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsCollectorFactory)2 StageStatisticsSnapshot (com.github.nagyesta.abortmission.core.healthcheck.StageStatisticsSnapshot)2 MissionStatisticsCollector (com.github.nagyesta.abortmission.core.healthcheck.impl.MissionStatisticsCollector)2 HashMap (java.util.HashMap)2 Consumer (java.util.function.Consumer)2