Search in sources :

Example 1 with Result

use of com.datastax.fallout.components.metrics.json.RangeQueryResult.Result in project fallout by datastax.

the class StableMetricsThresholdArtifactCheckerTest method shouldReturnFalseIfMetricsAreNotWithinRange.

@ParameterizedTest
@MethodSource("metricValueOutOfRange")
public void shouldReturnFalseIfMetricsAreNotWithinRange(Value outOfRangeValue) {
    StableMetricsThresholdArtifactChecker stableMetricsThresholdArtifactChecker = new StableMetricsThresholdArtifactChecker();
    List<Result> metricResults = List.of(new Result(new Metric("metric_a", "123.123.123.134:8080", "some_job"), List.of(new Value(Instant.ofEpochSecond(1612169140), 0L), new Value(Instant.ofEpochSecond(1612169170), 5L))), (new Result(new Metric("metric_a", "123.123.123.135:8084", "some_job"), List.of(outOfRangeValue))));
    RangeQueryResult rangeQueryResult = new RangeQueryResult(new Data(metricResults));
    boolean result = stableMetricsThresholdArtifactChecker.validateIfMetricValuesAreWithinRange(rangeQueryResult, Duration.seconds(0), 0L, 15L);
    assertThat(result).isFalse();
}
Also used : RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) Value(com.datastax.fallout.components.metrics.json.RangeQueryResult.Value) Metric(com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric) Data(com.datastax.fallout.components.metrics.json.RangeQueryResult.Data) Result(com.datastax.fallout.components.metrics.json.RangeQueryResult.Result) RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with Result

use of com.datastax.fallout.components.metrics.json.RangeQueryResult.Result in project fallout by datastax.

the class StableMetricsThresholdArtifactCheckerTest method shouldLoadMetricsFromFile.

@Test
public void shouldLoadMetricsFromFile() {
    String json = ResourceUtils.getResourceAsString(getClass(), "metric_a.json");
    RangeQueryResult rangeQueryResult = JsonUtils.fromJson(json, RangeQueryResult.class);
    List<Result> result = rangeQueryResult.data().result();
    assertThat(result).containsExactly(new Result(new Metric("metric_a", "123.123.123.134:8080", "some_job"), List.of(new Value(Instant.ofEpochSecond(1612169177), 0L), new Value(Instant.ofEpochSecond(1612169192), 5L))), new Result(new Metric("metric_a", "123.123.123.135:8084", "some_job"), List.of(new Value(Instant.ofEpochSecond(1612169177), 15L))));
}
Also used : RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) 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) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with Result

use of com.datastax.fallout.components.metrics.json.RangeQueryResult.Result in project fallout by datastax.

the class StableMetricsThresholdArtifactCheckerTest method shouldIgnoreOutOfRangeMetricIfItIsBeforeWarmupOffset.

@Test
public void shouldIgnoreOutOfRangeMetricIfItIsBeforeWarmupOffset() {
    StableMetricsThresholdArtifactChecker stableMetricsThresholdArtifactChecker = new StableMetricsThresholdArtifactChecker();
    Duration warmupOffset = Duration.seconds(60);
    Instant now = Instant.now();
    List<Result> metricResults = List.of(new Result(new Metric("metric_a", "123.123.123.134:8080", "some_job"), List.of(new Value(now, 100L), new Value(now.plusSeconds(60), 5L))), new Result(new Metric("metric_a", "123.123.123.135:8084", "some_job"), List.of(new Value(now, 15L))));
    RangeQueryResult rangeQueryResult = new RangeQueryResult(new Data(metricResults));
    boolean result = stableMetricsThresholdArtifactChecker.validateIfMetricValuesAreWithinRange(rangeQueryResult, warmupOffset, 0L, 15L);
    assertThat(result).isTrue();
}
Also used : RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) Instant(java.time.Instant) Value(com.datastax.fallout.components.metrics.json.RangeQueryResult.Value) Duration(com.datastax.fallout.util.Duration) Metric(com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric) Data(com.datastax.fallout.components.metrics.json.RangeQueryResult.Data) Result(com.datastax.fallout.components.metrics.json.RangeQueryResult.Result) RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with Result

use of com.datastax.fallout.components.metrics.json.RangeQueryResult.Result in project fallout by datastax.

the class StableMetricsThresholdArtifactCheckerTest method shouldReturnTrueIfMetricsAreWithinRange.

@ParameterizedTest
@MethodSource("metricsWithinRange")
public void shouldReturnTrueIfMetricsAreWithinRange(Value inRangeValue) {
    StableMetricsThresholdArtifactChecker stableMetricsThresholdArtifactChecker = new StableMetricsThresholdArtifactChecker();
    List<Result> metricResults = List.of(new Result(new Metric("metric_a", "123.123.123.134:8080", "some_job"), List.of(new Value(Instant.ofEpochSecond(1612169192), 0L), inRangeValue)), new Result(new Metric("metric_a", "123.123.123.135:8084", "some_job"), List.of(new Value(Instant.ofEpochSecond(1612169140), 15L))));
    RangeQueryResult rangeQueryResult = new RangeQueryResult(new Data(metricResults));
    boolean result = stableMetricsThresholdArtifactChecker.validateIfMetricValuesAreWithinRange(rangeQueryResult, Duration.seconds(0), 0L, 15L);
    assertThat(result).isTrue();
}
Also used : RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) Value(com.datastax.fallout.components.metrics.json.RangeQueryResult.Value) Metric(com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric) Data(com.datastax.fallout.components.metrics.json.RangeQueryResult.Data) Result(com.datastax.fallout.components.metrics.json.RangeQueryResult.Result) RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 5 with Result

use of com.datastax.fallout.components.metrics.json.RangeQueryResult.Result in project fallout by datastax.

the class StableMetricsThresholdArtifactCheckerTest method shouldCatchOutOfRangeMetricWhenUsingWarmupOffset.

@Test
public void shouldCatchOutOfRangeMetricWhenUsingWarmupOffset() {
    StableMetricsThresholdArtifactChecker stableMetricsThresholdArtifactChecker = new StableMetricsThresholdArtifactChecker();
    Duration warmupOffset = Duration.seconds(60);
    Instant now = Instant.now();
    List<Result> metricResults = List.of(new Result(new Metric("metric_a", "123.123.123.134:8080", "some_job"), List.of(new Value(now, 100L), new Value(now.plusSeconds(60), 33L))), new Result(new Metric("metric_a", "123.123.123.135:8084", "some_job"), List.of(new Value(now, 100L))));
    RangeQueryResult rangeQueryResult = new RangeQueryResult(new Data(metricResults));
    boolean result = stableMetricsThresholdArtifactChecker.validateIfMetricValuesAreWithinRange(rangeQueryResult, warmupOffset, 0L, 15L);
    assertThat(result).isFalse();
}
Also used : RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) Instant(java.time.Instant) Value(com.datastax.fallout.components.metrics.json.RangeQueryResult.Value) Duration(com.datastax.fallout.util.Duration) Metric(com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric) Data(com.datastax.fallout.components.metrics.json.RangeQueryResult.Data) Result(com.datastax.fallout.components.metrics.json.RangeQueryResult.Result) RangeQueryResult(com.datastax.fallout.components.metrics.json.RangeQueryResult) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

RangeQueryResult (com.datastax.fallout.components.metrics.json.RangeQueryResult)6 Metric (com.datastax.fallout.components.metrics.json.RangeQueryResult.Metric)6 Result (com.datastax.fallout.components.metrics.json.RangeQueryResult.Result)6 Value (com.datastax.fallout.components.metrics.json.RangeQueryResult.Value)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Data (com.datastax.fallout.components.metrics.json.RangeQueryResult.Data)4 Instant (java.time.Instant)3 Test (org.junit.jupiter.api.Test)3 Duration (com.datastax.fallout.util.Duration)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 VisibleForTesting (com.datastax.fallout.cassandra.shaded.com.google.common.annotations.VisibleForTesting)1