Search in sources :

Example 6 with MissionHealthCheckMatcher

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

the class PercentageBasedMissionHealthCheckEvaluatorTest method testBurnInThresholdsAreWorkingWhenNoPreparationStepsAreUsed.

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

Example 7 with MissionHealthCheckMatcher

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

the class PercentageBasedMissionHealthCheckEvaluatorTest method testBurnInTestCountShouldThrowExceptionWhenCalledWithInvalidValue.

@ParameterizedTest
@ValueSource(ints = { -2, -1 })
void testBurnInTestCountShouldThrowExceptionWhenCalledWithInvalidValue(final int input) {
    // given
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    // when
    assertThrows(IllegalArgumentException.class, () -> PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).burnInTestCount(input));
// then exception
}
Also used : MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with MissionHealthCheckMatcher

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

the class AndMatcherTest method testMatchesRequiresAllOperandsToMatchWhenCalled.

@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesRequiresAllOperandsToMatchWhenCalled(final boolean matches, final Collection<String> operands) {
    // given
    final MissionHealthCheckMatcherBuilder builder = (MissionHealthCheckMatcherBuilder) builder();
    for (final String regex : operands) {
        builder.and(builder().classNamePattern(regex).build());
    }
    final MissionHealthCheckMatcher underTest = builder.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)

Example 9 with MissionHealthCheckMatcher

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

the class ClassMatcherTest method testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithMethod.

@ParameterizedTest
@MethodSource("inputProvider")
void testMatchesShouldMatchFullyQualifiedClassNameToRegexpWhenCalledWithMethod(final boolean matches, final String pattern) {
    // given
    final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().classNamePattern(pattern).build();
    // when
    final boolean actual = underTest.matches(this.getClass().getDeclaredMethods()[0]);
    // 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)

Example 10 with MissionHealthCheckMatcher

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

the class ClassMatcherTest method testMatchesShouldThrowExceptionWhenCalledWithUnsupportedInput.

@ParameterizedTest
@NullSource
@MethodSource("unsupportedComponentProvider")
void testMatchesShouldThrowExceptionWhenCalledWithUnsupportedInput(final Object invalidInput) {
    // given
    final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().classNamePattern(".*").build();
    // when
    final boolean actual = underTest.matches(invalidInput);
    // 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) NullSource(org.junit.jupiter.params.provider.NullSource)

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