Search in sources :

Example 1 with StageLaunchStats

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

the class ClassTelemetryConverter method processLaunchStats.

/**
 * Processes statistical information of all test methods in the class based on partitioned data.
 *
 * @param matcherNames The names of matchers partitioned per method name.
 * @param byMethods    The time series information per method name.
 * @return The parsed statistics of each method.
 */
public Map<String, StageLaunchStats> processLaunchStats(final Map<String, Set<String>> matcherNames, final Map<String, List<StageTimeMeasurement>> byMethods) {
    Objects.requireNonNull(matcherNames, "MatcherNames cannot be null.");
    Objects.requireNonNull(byMethods, "ByMethods cannot be null.");
    final Map<String, StageLaunchStats> methodStats = new TreeMap<String, StageLaunchStats>();
    byMethods.forEach((method, measurementList) -> {
        if (StageTimeMeasurement.CLASS_ONLY.equals(method)) {
            return;
        }
        final Set<String> names = matcherNames.getOrDefault(method, Collections.emptySet());
        methodStats.put(method, new StageLaunchStats(AggregatedLaunchStats.filter(measurementList), names));
    });
    return Collections.unmodifiableMap(methodStats);
}
Also used : StageLaunchStats(com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats)

Example 2 with StageLaunchStats

use of com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats 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 3 with StageLaunchStats

use of com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats 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)

Aggregations

StageLaunchStats (com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats)3 StageResult (com.github.nagyesta.abortmission.core.telemetry.StageResult)2 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)2 CLASS_ONLY (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY)2 ClassTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry)2 TestRunTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)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 Arguments (org.junit.jupiter.params.provider.Arguments)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 LaunchStatisticsRepository (com.github.nagyesta.abortmission.strongback.h2.repository.LaunchStatisticsRepository)1 AbstractInMemoryDataSourceIntegrationTest (com.github.nagyesta.abortmission.strongback.h2.server.AbstractInMemoryDataSourceIntegrationTest)1 RmiServiceProvider (com.github.nagyesta.abortmission.strongback.rmi.server.RmiServiceProvider)1