Search in sources :

Example 16 with MissionHealthCheckMatcher

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

the class AbortMissionCommandOpsTest method testRegisterHealthCheckShouldThrowExceptionWhenCalledTwiceWithTheSame.

@Test
void testRegisterHealthCheckShouldThrowExceptionWhenCalledTwiceWithTheSame() {
    // given
    final AbortMissionCommandOps underTest = AbortMissionCommandOps.newInstance();
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    final MissionHealthCheckEvaluator evaluator = mock(MissionHealthCheckEvaluator.class);
    when(evaluator.getMatcher()).thenReturn(matcher);
    // when
    underTest.registerHealthCheck(evaluator);
    Assertions.assertThrows(IllegalStateException.class, () -> underTest.registerHealthCheck(evaluator));
// then exception
}
Also used : MissionHealthCheckEvaluator(com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with MissionHealthCheckMatcher

use of com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher in project yippee-ki-json by nagyesta.

the class MissionOutlineDefinition method defineOutline.

@Override
protected Map<String, Consumer<AbortMissionCommandOps>> defineOutline() {
    MissionHealthCheckMatcher integrationTestMatcher = matcher().classNamePattern(".+IntegrationTest").build();
    PercentageBasedMissionHealthCheckEvaluator evaluator = percentageBasedEvaluator(integrationTestMatcher).abortThreshold(ABORT_THRESHOLD).build();
    ReportOnlyMissionHealthCheckEvaluator noop = reportOnlyEvaluator(matcher().anyClass().build()).build();
    return Map.of(MissionOutline.SHARED_CONTEXT, ops -> {
        ops.registerHealthCheck(evaluator);
        ops.registerHealthCheck(noop);
    });
}
Also used : ReportOnlyMissionHealthCheckEvaluator(com.github.nagyesta.abortmission.core.healthcheck.impl.ReportOnlyMissionHealthCheckEvaluator) PercentageBasedMissionHealthCheckEvaluator(com.github.nagyesta.abortmission.core.healthcheck.impl.PercentageBasedMissionHealthCheckEvaluator) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)

Example 18 with MissionHealthCheckMatcher

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

the class MissionOutlineDefinition method callableConfig.

private static void callableConfig(final AbortMissionCommandOps ops) {
    final MissionHealthCheckMatcher simpleMatcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(SimpleCallableMissionTemplateSupportTest.class.getName()).build();
    ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(simpleMatcher, new MissionStatisticsCollector(simpleMatcher)).build());
    final MissionHealthCheckMatcher matcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(CallableMissionTemplateSupportTest.class.getName()).build();
    ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).build());
}
Also used : MissionStatisticsCollector(com.github.nagyesta.abortmission.core.healthcheck.impl.MissionStatisticsCollector) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)

Example 19 with MissionHealthCheckMatcher

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

the class MissionOutlineDefinition method runnableConfig.

private static void runnableConfig(final AbortMissionCommandOps ops) {
    final MissionHealthCheckMatcher simpleMatcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(SimpleRunnableMissionTemplateSupportTest.class.getName()).build();
    ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(simpleMatcher, new MissionStatisticsCollector(simpleMatcher)).build());
    final MissionHealthCheckMatcher matcher = MissionHealthCheckMatcherBuilder.builder().classNamePattern(RunnableMissionTemplateSupportTest.class.getName()).build();
    ops.registerHealthCheck(PercentageBasedMissionHealthCheckEvaluator.builder(matcher, new MissionStatisticsCollector(matcher)).build());
}
Also used : MissionStatisticsCollector(com.github.nagyesta.abortmission.core.healthcheck.impl.MissionStatisticsCollector) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)

Example 20 with MissionHealthCheckMatcher

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

the class EnvironmentMatcherTest method testMatchesShouldWorkRegardlessOfTheInput.

@ParameterizedTest
@MethodSource("validInputProvider")
void testMatchesShouldWorkRegardlessOfTheInput(final String envName, final String regex, final Object component, final boolean expected) {
    // given
    final MissionHealthCheckMatcher underTest = MissionHealthCheckMatcherBuilder.builder().envVariable(envName).valuePattern(regex).build();
    assertTrue(underTest instanceof EnvironmentMatcher);
    // when
    final boolean actual = underTest.matches(component);
    // then
    assertEquals(expected, 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