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