Search in sources :

Example 1 with H2BackedLaunchTelemetryDataSource

use of com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource in project abort-mission by nagyesta.

the class H2StrongbackController method retract.

@Override
public void retract() {
    final LaunchTelemetryDataSource telemetryDataSource = new H2BackedLaunchTelemetryDataSource(dataSource);
    new ReportingHelper().report(telemetryDataSource);
    serverManager.stopServer();
}
Also used : H2BackedLaunchTelemetryDataSource(com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource) LaunchTelemetryDataSource(com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource) H2BackedLaunchTelemetryDataSource(com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource) ReportingHelper(com.github.nagyesta.abortmission.core.telemetry.ReportingHelper)

Example 2 with H2BackedLaunchTelemetryDataSource

use of com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource 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

ReportingHelper (com.github.nagyesta.abortmission.core.telemetry.ReportingHelper)1 StageResult (com.github.nagyesta.abortmission.core.telemetry.StageResult)1 StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)1 CLASS_ONLY (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY)1 ClassTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry)1 LaunchTelemetryDataSource (com.github.nagyesta.abortmission.core.telemetry.stats.LaunchTelemetryDataSource)1 StageLaunchStats (com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats)1 TestRunTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry)1 LaunchStatisticsRepository (com.github.nagyesta.abortmission.strongback.h2.repository.LaunchStatisticsRepository)1 AbstractInMemoryDataSourceIntegrationTest (com.github.nagyesta.abortmission.strongback.h2.server.AbstractInMemoryDataSourceIntegrationTest)1 H2BackedLaunchTelemetryDataSource (com.github.nagyesta.abortmission.strongback.h2.telemetry.H2BackedLaunchTelemetryDataSource)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 Assertions (org.junit.jupiter.api.Assertions)1 Tag (org.junit.jupiter.api.Tag)1 Execution (org.junit.jupiter.api.parallel.Execution)1 ExecutionMode (org.junit.jupiter.api.parallel.ExecutionMode)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1