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);
}
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());
}
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());
}
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());
}
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);
}
Aggregations