Search in sources :

Example 1 with StageTimeMeasurement

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

the class LaunchStatisticsServiceIntegrationTest method testInsertStageTimeMeasurementShouldInsertUniqueRecordsWhenCalledWithoutCollision.

@ParameterizedTest
@MethodSource("noCollisionInsertDataProvider")
void testInsertStageTimeMeasurementShouldInsertUniqueRecordsWhenCalledWithoutCollision(final Map<String, List<StageTimeMeasurement>> input) throws RemoteException {
    // given
    final LaunchStatisticsService underTest = RmiServiceProvider.service(RmiServiceProvider.lookupRegistry(port));
    // when
    for (final Map.Entry<String, List<StageTimeMeasurement>> entry : input.entrySet()) {
        final String key = entry.getKey();
        final List<StageTimeMeasurement> measurementList = entry.getValue();
        for (final StageTimeMeasurement measurement : measurementList) {
            final boolean isCountdown = CLASS_ONLY.equals(measurement.getTestCaseId());
            underTest.insertStageTimeMeasurement(contextName, key, isCountdown, new RmiStageTimeMeasurement(measurement));
        }
    }
    // then
    for (final Map.Entry<String, List<StageTimeMeasurement>> entry : input.entrySet()) {
        final String matcherName = entry.getKey();
        final List<StageTimeMeasurement> measurements = entry.getValue();
        final TreeSet<UUID> actual = this.service.fetchAllMeasurementsForMatcher(matcherName).stream().map(RmiStageTimeMeasurement::getLaunchId).collect(Collectors.toCollection(TreeSet::new));
        final TreeSet<UUID> expected = measurements.stream().map(StageTimeMeasurement::getLaunchId).collect(Collectors.toCollection(TreeSet::new));
        Assertions.assertIterableEquals(expected, actual);
    }
}
Also used : RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with StageTimeMeasurement

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

the class RmiBackedLaunchTelemetryDataSourceIntegrationTest method fetchAllMeasurements.

private List<StageTimeMeasurement> fetchAllMeasurements() throws RemoteException {
    final List<StageTimeMeasurement> list = new ArrayList<>();
    final LaunchStatisticsService serviceOuter = service;
    for (final String s : service.fetchAllMatcherNames()) {
        final List<RmiStageTimeMeasurement> rmiStageTimeMeasurements = serviceOuter.fetchAllMeasurementsForMatcher(s);
        for (final RmiStageTimeMeasurement rmiStageTimeMeasurement : rmiStageTimeMeasurements) {
            final StageTimeMeasurement toStageTimeMeasurement = rmiStageTimeMeasurement.toStageTimeMeasurement();
            list.add(toStageTimeMeasurement);
        }
    }
    return list;
}
Also used : RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) LaunchStatisticsService(com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)

Example 3 with StageTimeMeasurement

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

the class LaunchStatisticsRepositoryIntegrationTest method testFetchMeasurementsForMatcherShouldReturnNoMeasurementsWhenCalledWithUnknownMatcher.

@ParameterizedTest
@NullAndEmptySource
@ValueSource(strings = { METHOD_PREFIX, CLASS_NAME, MATCHER_PREFIX })
void testFetchMeasurementsForMatcherShouldReturnNoMeasurementsWhenCalledWithUnknownMatcher(final String lookup) {
    // given
    final StageTimeMeasurement measurement = generateMeasurement(1);
    jdbi.withExtension(LaunchStatisticsRepository.class, insertSingleMeasurementCallback(MATCHER_PREFIX + 1, measurement));
    // when
    final List<StageTimeMeasurement> actual = jdbi.withExtension(LaunchStatisticsRepository.class, dao -> dao.fetchMeasurementsFor(CONTEXT_NAME, lookup, false));
    // then
    Assertions.assertNotNull(actual);
    Assertions.assertIterableEquals(Collections.emptyList(), actual);
}
Also used : StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) NullAndEmptySource(org.junit.jupiter.params.provider.NullAndEmptySource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with StageTimeMeasurement

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

the class H2BackedStageStatisticsCollectorIntegrationTest method testLogAndIncrementShouldSaveMeasurementWhenCalledWithValidInput.

@ParameterizedTest
@MethodSource("measurementProvider")
void testLogAndIncrementShouldSaveMeasurementWhenCalledWithValidInput(final List<StageTimeMeasurement> measurements) {
    // given
    final boolean countdown = false;
    final MissionHealthCheckMatcher matcher = mock(MissionHealthCheckMatcher.class);
    when(matcher.getName()).thenReturn(MATCHER_PREFIX);
    final H2BackedStageStatisticsCollector underTest = new H2BackedStageStatisticsCollector(contextName, matcher, dataSource, countdown);
    // when
    measurements.forEach(underTest::logAndIncrement);
    // then
    verify(matcher, atLeast(measurements.size())).getName();
    final List<StageTimeMeasurement> actual = jdbi.withExtension(LaunchStatisticsRepository.class, dao -> dao.fetchMeasurementsFor(contextName, MATCHER_PREFIX, countdown));
    Collections.sort(actual);
    Collections.sort(measurements);
    Assertions.assertIterableEquals(measurements, actual);
}
Also used : StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) MissionHealthCheckMatcher(com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with StageTimeMeasurement

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

the class AbstractInMemoryDataSourceIntegrationTest method insertAll.

protected void insertAll(final Map<String, List<StageTimeMeasurement>> input) throws RemoteException {
    for (final Map.Entry<String, List<StageTimeMeasurement>> entry : input.entrySet()) {
        final String matcherName = entry.getKey();
        final List<StageTimeMeasurement> measurementList = entry.getValue();
        for (final StageTimeMeasurement measurement : measurementList) {
            final boolean isCountdown = CLASS_ONLY.equals(measurement.getTestCaseId());
            service.insertStageTimeMeasurement(contextName, matcherName, isCountdown, new RmiStageTimeMeasurement(measurement));
        }
    }
}
Also used : RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement) StageTimeMeasurement(com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement) RmiStageTimeMeasurement(com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement)

Aggregations

StageTimeMeasurement (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement)15 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 MethodSource (org.junit.jupiter.params.provider.MethodSource)8 MissionHealthCheckMatcher (com.github.nagyesta.abortmission.core.matcher.MissionHealthCheckMatcher)5 RmiStageTimeMeasurement (com.github.nagyesta.abortmission.strongback.rmi.stats.RmiStageTimeMeasurement)5 Registry (java.rmi.registry.Registry)4 CLASS_ONLY (com.github.nagyesta.abortmission.core.telemetry.StageTimeMeasurement.CLASS_ONLY)3 ClassTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.ClassTelemetry)3 LaunchStatisticsService (com.github.nagyesta.abortmission.strongback.rmi.service.LaunchStatisticsService)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 StageResult (com.github.nagyesta.abortmission.core.telemetry.StageResult)2 ClassTelemetryConverter (com.github.nagyesta.abortmission.core.telemetry.converter.ClassTelemetryConverter)2 StageLaunchStats (com.github.nagyesta.abortmission.core.telemetry.stats.StageLaunchStats)2 TestRunTelemetry (com.github.nagyesta.abortmission.core.telemetry.stats.TestRunTelemetry)2 AbstractInMemoryDataSourceIntegrationTest (com.github.nagyesta.abortmission.strongback.h2.server.AbstractInMemoryDataSourceIntegrationTest)2 RmiServiceProvider (com.github.nagyesta.abortmission.strongback.rmi.server.RmiServiceProvider)2 RemoteException (java.rmi.RemoteException)2 IntStream (java.util.stream.IntStream)2 Stream (java.util.stream.Stream)2