use of com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator in project abort-mission by nagyesta.
the class LaunchSequenceTemplateTest method testPreLaunchInitCompleteShouldEvaluateMissionAbortConditionsWhenCalled.
@Test
void testPreLaunchInitCompleteShouldEvaluateMissionAbortConditionsWhenCalled() {
// given
final Set<MissionHealthCheckEvaluator> evaluators = addEvaluatorMockWithSpyLogger(new HashSet<>(), false);
final Set<MissionHealthCheckEvaluator> aborting = new HashSet<>();
addEvaluatorMockWithSpyLogger(aborting, true);
addEvaluatorMockWithSpyLogger(aborting, true);
evaluators.addAll(aborting);
final LaunchSequenceTemplate underTest = underTestWithNullFunctions();
// when
underTest.evaluateLaunchAbort(evaluators, new StageTimeStopwatch(getClass()), () -> false);
// then
evaluators.forEach(evaluator -> {
verify(evaluator).shouldAbort();
verify(evaluator, never()).shouldAbortCountdown();
});
aborting.forEach(evaluator -> {
verify(evaluator, never()).countdownLogger();
verify(evaluator).missionLogger();
verifyOnlyIncrementAbortedCalled(evaluator.missionLogger());
});
}
use of com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator in project abort-mission by nagyesta.
the class LaunchAbortHook method findEvaluators.
private Set<MissionHealthCheckEvaluator> findEvaluators(final Scenario scenario) {
final Optional<String> context = scenario.getSourceTagNames().stream().filter(tag -> tag.startsWith("@AbortMission_Context_")).map(tag -> tag.replaceFirst("^@AbortMission_Context_", "")).findFirst();
final AbortMissionCommandOps commandOps = context.map(MissionControl::commandOps).orElse(MissionControl.commandOps());
return Objects.requireNonNull(commandOps, "Mission context is not found: " + context.orElse("'- DEFAULT - '")).matchingEvaluators(scenario);
}
use of com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator in project lowkey-vault by nagyesta.
the class MissionOutlineDefinition method defineOutline.
@Override
protected Map<String, Consumer<AbortMissionCommandOps>> defineOutline() {
return Map.of(SHARED_CONTEXT, ops -> {
final MissionHealthCheckMatcher integrationTestMatcher = matcher().classNamePattern(".*IntegrationTest").build();
final MissionHealthCheckEvaluator integrationTests = percentageBasedEvaluator(integrationTestMatcher).build();
final MissionHealthCheckEvaluator reportOnly = reportOnlyEvaluator(matcher().anyClass().build()).build();
ops.registerHealthCheck(integrationTests);
ops.registerHealthCheck(reportOnly);
});
}
use of com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator in project lowkey-vault by nagyesta.
the class MissionOutlineDefinition method defineOutline.
@Override
protected Map<String, Consumer<AbortMissionCommandOps>> defineOutline() {
return Map.of(SHARED_CONTEXT, ops -> {
final TagDependencyNameExtractor extractor = new TagDependencyNameExtractor();
Stream.of("Key", "Secret").forEach(type -> {
final MissionHealthCheckMatcher typeMatcher = matcher().dependencyWith(type).extractor(extractor).build();
final MissionHealthCheckEvaluator featurePercentage = percentageBasedEvaluator(typeMatcher).abortThreshold(ABORT_THRESHOLD).burnInTestCount(TOTAL_BURN_IN_TEST_COUNT).build();
ops.registerHealthCheck(featurePercentage);
Stream.of("Create", "Get", "Delete", "List", "Update", "ListDeleted", "Recover", "Purge", "Backup", "Restore").forEach(subtype -> {
final MissionHealthCheckMatcher subTypeMatcher = matcher().dependencyWith(type + subtype).extractor(extractor).build();
final MissionHealthCheckEvaluator subFeaturePercentage = percentageBasedEvaluator(subTypeMatcher).abortThreshold(ABORT_THRESHOLD).burnInTestCount(BURN_IN_TEST_COUNT).build();
ops.registerHealthCheck(subFeaturePercentage);
});
});
Stream.of("CreateVault", "KeyImport", "KeyEncrypt", "KeySign", "RSA", "EC", "OCT").forEach(tag -> {
final MissionHealthCheckMatcher matcher = matcher().dependencyWith(tag).extractor(extractor).build();
final MissionHealthCheckEvaluator tagPercentage = percentageBasedEvaluator(matcher).abortThreshold(ABORT_THRESHOLD).burnInTestCount(BURN_IN_TEST_COUNT).build();
ops.registerHealthCheck(tagPercentage);
});
});
}
Aggregations