Search in sources :

Example 1 with VisibleForTesting

use of com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting in project fallout by datastax.

the class MetricsCollectionConfigurationManager method createMetricsArtifactDirectory.

@VisibleForTesting
void createMetricsArtifactDirectory() {
    Path metricsArtifactsPath = StableMetricsThresholdArtifactChecker.getMetricsArtifactsPath(getNodeGroup());
    FileUtils.createDirs(metricsArtifactsPath);
}
Also used : Path(java.nio.file.Path) VisibleForTesting(com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting)

Example 2 with VisibleForTesting

use of com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting in project fallout by datastax.

the class StableMetricsThresholdArtifactChecker method validateIfMetricValuesAreWithinRange.

@VisibleForTesting
boolean validateIfMetricValuesAreWithinRange(RangeQueryResult rangeQueryResult, Duration warmupOffset, Long lowerThreshold, Long upperThreshold) {
    for (Result result : rangeQueryResult.data().result()) {
        // this is executed per-node
        Metric metric = result.metric();
        Instant metricStartTime = null;
        for (Value value : result.values()) {
            // if it is not present, take the first timestamp and use it as the first one.
            if (metricStartTime == null) {
                metricStartTime = value.timestamp();
            }
            if (metricIsAfterWarmup(metricStartTime, warmupOffset, value.timestamp()) && (value.value() < lowerThreshold || value.value() > upperThreshold)) {
                logger().error("The value: {} for metric: {} is not within threshold ({}-{})", value.value(), metric, lowerThreshold, upperThreshold);
                return false;
            }
        }
    }
    return true;
}
Also used : Instant(java.time.Instant) Value(com.datastax.fallout.components.metrics.json.RangeQueryResult.Value) Metric(com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric) Result(com.datastax.fallout.components.metrics.json.RangeQueryResult.Result) RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) VisibleForTesting(com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting)

Example 3 with VisibleForTesting

use of com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting in project fallout by datastax.

the class TestRunReaper method checkForTestRunsPastTTL.

@VisibleForTesting
public static void checkForTestRunsPastTTL(TestRunDAO testRunDAO, PerformanceReportDAO reportDAO, TestDAO testDAO, UserMessenger httpMessenger, UserMessenger slackUserMessenger, String externalUrl, BooleanSupplier isPaused) {
    logger.withScopedInfo("Checking for test runs older than three years").run(() -> {
        final Instant lowerBound = Instant.now().minus(THREE_YEARS);
        Map<String, List<TestRun>> testRunsByUser = new HashMap<>();
        testRunDAO.getAll().takeWhile(ignored -> !isPaused.getAsBoolean()).filter(testRun -> testRunCanBeDeleted(testRun, lowerBound, reportDAO)).forEach(testRun -> testRunsByUser.computeIfAbsent(testRun.getOwner(), k -> new ArrayList<>()).add(testRun));
        testRunsByUser.forEach((owner, testRuns) -> deleteTestRunsAndNotifyOwner(owner, testRuns, testDAO, httpMessenger, slackUserMessenger, externalUrl));
    });
}
Also used : UserGroupMapper(com.datastax.fallout.service.db.UserGroupMapper) ReentrantLock(java.util.concurrent.locks.ReentrantLock) MustacheFactoryWithoutHTMLEscaping.renderWithScopes(com.datastax.fallout.util.MustacheFactoryWithoutHTMLEscaping.renderWithScopes) HashMap(java.util.HashMap) VisibleForTesting(com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting) DateUtils(com.datastax.fallout.util.DateUtils) Instant(java.time.Instant) ScopedLogger(com.datastax.fallout.util.ScopedLogger) ArrayList(java.util.ArrayList) BooleanSupplier(java.util.function.BooleanSupplier) List(java.util.List) TestDAO(com.datastax.fallout.service.db.TestDAO) TestRunDAO(com.datastax.fallout.service.db.TestRunDAO) TreeMap(java.util.TreeMap) Map(java.util.Map) HashedWheelTimer(io.netty.util.HashedWheelTimer) Optional(java.util.Optional) UserMessenger(com.datastax.fallout.util.UserMessenger) Comparator(java.util.Comparator) PerformanceReportDAO(com.datastax.fallout.service.db.PerformanceReportDAO) LinkedTestRuns(com.datastax.fallout.service.views.LinkedTestRuns) ResourceUtils(com.datastax.fallout.util.ResourceUtils) Duration(com.datastax.fallout.util.Duration) HashMap(java.util.HashMap) Instant(java.time.Instant) ArrayList(java.util.ArrayList) List(java.util.List) VisibleForTesting(com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting)3 Instant (java.time.Instant)2 RangeQueryResult (com.datastax.fallout.components.metrics.json.RangeQueryResult)1 Metric (com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric)1 Result (com.datastax.fallout.components.metrics.json.RangeQueryResult.Result)1 Value (com.datastax.fallout.components.metrics.json.RangeQueryResult.Value)1 PerformanceReportDAO (com.datastax.fallout.service.db.PerformanceReportDAO)1 TestDAO (com.datastax.fallout.service.db.TestDAO)1 TestRunDAO (com.datastax.fallout.service.db.TestRunDAO)1 UserGroupMapper (com.datastax.fallout.service.db.UserGroupMapper)1 LinkedTestRuns (com.datastax.fallout.service.views.LinkedTestRuns)1 DateUtils (com.datastax.fallout.util.DateUtils)1 Duration (com.datastax.fallout.util.Duration)1 MustacheFactoryWithoutHTMLEscaping.renderWithScopes (com.datastax.fallout.util.MustacheFactoryWithoutHTMLEscaping.renderWithScopes)1 ResourceUtils (com.datastax.fallout.util.ResourceUtils)1 ScopedLogger (com.datastax.fallout.util.ScopedLogger)1 UserMessenger (com.datastax.fallout.util.UserMessenger)1 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1