Search in sources :

Example 1 with ClassTelemetry

use of com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry in project abort-mission by nagyesta.

the class BaseLaunchTelemetryConverter method repartitionByClasses.

/**
 * Creates new partitions based on thy matcher and measurement maps.
 *
 * @param matchersByClassAndMethod The Map containing the Set of matcher names for each method of each class.
 * @param byTestClassAccumulator   The Map containing the time series data per ech class.
 * @return The repartitioned data in {@link ClassTelemetry} format.
 */
protected SortedMap<String, ClassTelemetry> repartitionByClasses(final Map<String, Map<String, Set<String>>> matchersByClassAndMethod, final Map<String, List<StageTimeMeasurement>> byTestClassAccumulator) {
    final SortedMap<String, ClassTelemetry> parsedClasses = new TreeMap<>();
    byTestClassAccumulator.forEach((className, measurementList) -> {
        final Map<String, Set<String>> matcherNames = matchersByClassAndMethod.getOrDefault(className, Collections.emptyMap());
        parsedClasses.put(className, new ClassTelemetry(classConverter, className, measurementList, matcherNames));
    });
    return Collections.unmodifiableSortedMap(parsedClasses);
}
Also used : ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry)

Example 2 with ClassTelemetry

use of com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry in project abort-mission by nagyesta.

the class LaunchTelemetryConverterTest method testProcessClassStatisticsShould.

@Test
void testProcessClassStatisticsShould() {
    // given
    final Map<String, AbortMissionCommandOps> nameSpaces = new HashMap<>();
    final LaunchTelemetryConverter underTest = spy(new LaunchTelemetryConverter());
    final Stream<MissionHealthCheckEvaluator> stream = Stream.<MissionHealthCheckEvaluator>builder().add(new SimpleEvaluator(MATCHER_1, Arrays.asList(FIRST_FAIL_1_10, FIRST_PASS_1_10), Collections.emptyList())).add(new SimpleEvaluator(MATCHER_2, Arrays.asList(FIRST_FAIL_1_10, FIRST_PASS_1_10), Collections.singletonList(SECOND_PASS_2_20))).add(new SimpleEvaluator(MATCHER_3, Collections.emptyList(), Arrays.asList(THIRD_ABORT_5_5, THIRD_PASS_5_5, THIRD_SUPPRESS_5_5))).build();
    doReturn(stream).when(underTest).missionHealthCheckEvaluatorStream(same(nameSpaces));
    // when
    final SortedMap<String, ClassTelemetry> actual = underTest.processClassStatistics(nameSpaces);
    // then
    Assertions.assertNotNull(actual);
    verify(underTest).missionHealthCheckEvaluatorStream(same(nameSpaces));
    Assertions.assertIterableEquals(Collections.singleton(CLASS), actual.keySet());
    final ClassTelemetry classTelemetry = actual.get(CLASS);
    Assertions.assertEquals(CLASS, classTelemetry.getClassName());
    Assertions.assertIterableEquals(Arrays.asList(MATCHER_1, MATCHER_2), classTelemetry.getCountdown().getMatcherNames());
    Assertions.assertIterableEquals(Arrays.asList(MATCHER_2, MATCHER_3), classTelemetry.getLaunches().get(METHOD).getMatcherNames());
}
Also used : ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry) MissionHealthCheckEvaluator(com.github.nagyesta.abortmission.core.healthcheck.MissionHealthCheckEvaluator) AbstractMissionHealthCheckEvaluator(com.github.nagyesta.abortmission.core.healthcheck.impl.AbstractMissionHealthCheckEvaluator) AbortMissionCommandOps(com.github.nagyesta.abortmission.core.AbortMissionCommandOps) AbstractTelemetryTest(com.github.nagyesta.abortmission.core.telemetry.stats.AbstractTelemetryTest) Test(org.junit.jupiter.api.Test)

Example 3 with ClassTelemetry

use of com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry in project abort-mission by nagyesta.

the class RmiBackedLaunchTelemetryDataSourceIntegrationTest method testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled.

@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled(final Map<String, List<StageTimeMeasurement>> input) throws RemoteException {
    // given
    final Registry registry = RmiServiceProvider.lookupRegistry(port);
    insertAll(input);
    final RmiBackedLaunchTelemetryDataSource underTest = new RmiBackedLaunchTelemetryDataSource(registry);
    // when
    final SortedMap<String, ClassTelemetry> actual = underTest.fetchClassStatistics();
    // then
    final Map<String, StageLaunchStats> actualLaunchStatsMap = toLaunches(actual);
    final Set<String> actualMethods = new TreeSet<>(actualLaunchStatsMap.keySet());
    final List<StageTimeMeasurement> allMeasurements = fetchAllMeasurements();
    final List<String> expectedMethods = mapToMethodNames(allMeasurements);
    Assertions.assertIterableEquals(expectedMethods, actualMethods);
    expectedMethods.forEach(method -> {
        final StageLaunchStats actualLaunch = actualLaunchStatsMap.get(method);
        final List<TestRunTelemetry> expectedMeasurements = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(method)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
        Assertions.assertIterableEquals(expectedMeasurements, actualLaunch.getTimeMeasurements());
        final Map<StageResult, Integer> actualResultCount = actualLaunch.getStats().getResultCount();
        final Map<StageResult, Integer> expectedResultCount = countResults(expectedMeasurements);
        Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
    });
    final StageLaunchStats actualCountdown = toCountdown(actual);
    final List<TestRunTelemetry> expectedCountdowns = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(CLASS_ONLY)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
    Assertions.assertIterableEquals(expectedCountdowns, actualCountdown.getTimeMeasurements());
    final Map<StageResult, Integer> actualResultCount = actualCountdown.getStats().getResultCount();
    final Map<StageResult, Integer> expectedResultCount = countResults(expectedCountdowns);
    Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
}
Also used : StageResult(com.github.nagyesta.abortmission.core.telemetry.StageResult) IntStream(java.util.stream.IntStream) java.util(java.util) ExecutionMode(org.junit.jupiter.api.parallel.ExecutionMode) StageLaunchStats(com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) Arguments(org.junit.jupiter.params.provider.Arguments) Registry(java.rmi.registry.Registry) Collectors(java.util.stream.Collectors) TestRunTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry) RemoteException(java.rmi.RemoteException) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TestInstance(org.junit.jupiter.api.TestInstance) Stream(java.util.stream.Stream) AbstractInMemoryDataSourceIntegrationTest(com.github.nagyesta.abortmission.strongback.rmi.service.AbstractInMemoryDataSourceIntegrationTest) CLASS_ONLY(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY) Assertions(org.junit.jupiter.api.Assertions) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService) Tag(org.junit.jupiter.api.Tag) Execution(org.junit.jupiter.api.parallel.Execution) RmiServiceProvider(com.github.nagyesta.abortmission.strongback.rmi.server.RmiServiceProvider) MethodSource(org.junit.jupiter.params.provider.MethodSource) StageResult(com.github.nagyesta.abortmission.core.telemetry.StageResult) Registry(java.rmi.registry.Registry) ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry) StageLaunchStats(com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) TestRunTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with ClassTelemetry

use of com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry in project abort-mission by nagyesta.

the class H2BackedLaunchTelemetryDataSourceIntegrationTest method testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled.

@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testFetchClassStatisticsShouldFetchStatisticsGroupedByClassWhenCalled(final Map<String, List<StageTimeMeasurement>> input) {
    // given
    jdbi.withExtension(LaunchStatisticsRepository.class, insertAllCallback(input));
    final H2BackedLaunchTelemetryDataSource underTest = new H2BackedLaunchTelemetryDataSource(dataSource);
    // when
    final SortedMap<String, ClassTelemetry> actual = underTest.fetchClassStatistics();
    // then
    final Map<String, StageLaunchStats> actualLaunchStatsMap = toLaunches(actual);
    final Set<String> actualMethods = new TreeSet<>(actualLaunchStatsMap.keySet());
    final List<StageTimeMeasurement> allMeasurements = fetchAllMeasurements();
    final List<String> expectedMethods = mapToMethodNames(allMeasurements);
    Assertions.assertIterableEquals(expectedMethods, actualMethods);
    expectedMethods.forEach(method -> {
        final StageLaunchStats actualLaunch = actualLaunchStatsMap.get(method);
        final List<TestRunTelemetry> expectedMeasurements = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(method)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
        Assertions.assertIterableEquals(expectedMeasurements, actualLaunch.getTimeMeasurements());
        final Map<StageResult, Integer> actualResultCount = actualLaunch.getStats().getResultCount();
        final Map<StageResult, Integer> expectedResultCount = countResults(expectedMeasurements);
        Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
    });
    final StageLaunchStats actualCountdown = toCountdown(actual);
    final List<TestRunTelemetry> expectedCountdowns = allMeasurements.stream().filter(s -> s.getTestCaseId().equals(CLASS_ONLY)).map(TestRunTelemetry::new).sorted().collect(Collectors.toList());
    Assertions.assertIterableEquals(expectedCountdowns, actualCountdown.getTimeMeasurements());
    final Map<StageResult, Integer> actualResultCount = actualCountdown.getStats().getResultCount();
    final Map<StageResult, Integer> expectedResultCount = countResults(expectedCountdowns);
    Assertions.assertIterableEquals(expectedResultCount.entrySet(), actualResultCount.entrySet());
}
Also used : StageResult(com.github.nagyesta.abortmission.core.telemetry.StageResult) IntStream(java.util.stream.IntStream) java.util(java.util) ExecutionMode(org.junit.jupiter.api.parallel.ExecutionMode) StageLaunchStats(com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) TestRunTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractInMemoryDataSourceIntegrationTest(com.github.nagyesta.abortmission.strongback.h2.server.AbstractInMemoryDataSourceIntegrationTest) Stream(java.util.stream.Stream) CLASS_ONLY(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY) Assertions(org.junit.jupiter.api.Assertions) Tag(org.junit.jupiter.api.Tag) Execution(org.junit.jupiter.api.parallel.Execution) LaunchStatisticsRepository(com.github.nagyesta.abortmission.strongback.h2.repository.LaunchStatisticsRepository) MethodSource(org.junit.jupiter.params.provider.MethodSource) StageResult(com.github.nagyesta.abortmission.core.telemetry.StageResult) ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry) StageLaunchStats(com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) TestRunTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with ClassTelemetry

use of com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry in project abort-mission by nagyesta.

the class RmiBackedLaunchTelemetryDataSource method doFetchStatistics.

private SortedMap<String, ClassTelemetry> doFetchStatistics() throws RemoteException {
    final LaunchStatisticsService service = RmiServiceProvider.service(registry);
    final List<String> matcherName = service.fetchAllMatcherNames();
    final Map<String, List<StageTimeMeasurement>> measurementsPerMatcher = matcherName.stream().collect(Collectors.toMap(Function.identity(), name -> fetchByMatcherName(service, name)));
    return processFetchedRecords(measurementsPerMatcher);
}
Also used : java.util(java.util) BaseLaunchTelemetryConverter(com.github.nagyesta.abortmission.core.telemetry.converter.BaseLaunchTelemetryConverter) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) ClassTelemetry(com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) Registry(java.rmi.registry.Registry) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) StrongbackException(com.github.nagyesta.abortmission.strongback.base.StrongbackException) RemoteException(java.rmi.RemoteException) CLASS_ONLY(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService) ClassTelemetryConverter(com.github.nagyesta.abortmission.core.telemetry.converter.ClassTelemetryConverter) RmiServiceProvider(com.github.nagyesta.abortmission.strongback.rmi.server.RmiServiceProvider) LaunchTelemetryDataSource(com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)

Aggregations

ClassTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry)5 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)3 CLASS_ONLY (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 StageResult (com.github.nagyesta.abortmission.core.telemetry.StageResult)2 StageLaunchStats (com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats)2 TestRunTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry)2 RmiServiceProvider (com.github.nagyesta.abortmission.strongback.rmi.server.RmiServiceProvider)2 LaunchStatisticsService (com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)2 RmiStageTimeMeasurement (com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement)2 RemoteException (java.rmi.RemoteException)2 Registry (java.rmi.registry.Registry)2 IntStream (java.util.stream.IntStream)2 Stream (java.util.stream.Stream)2 Assertions (org.junit.jupiter.api.Assertions)2 Tag (org.junit.jupiter.api.Tag)2 Execution (org.junit.jupiter.api.parallel.Execution)2 ExecutionMode (org.junit.jupiter.api.parallel.ExecutionMode)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2