diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-03-17 21:12:11 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-03-17 21:12:11 +0100 |
commit | dc5d6a5388052919bc9abf221a6a455a28f22574 (patch) | |
tree | 2eada54510fb89703fc0dd1b9e3cedde6e63df82 /node-repository | |
parent | a165f9d46c0b223534bb0332f762222c9a19ebf5 (diff) |
Normalize to rate in measurement window
Diffstat (limited to 'node-repository')
5 files changed, 82 insertions, 51 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java index bd9bd47b30a..e12e5442c52 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseries.java @@ -85,8 +85,7 @@ public class ClusterTimeseries { else return 0.0; // ... because load is stable } - // OptionalDouble queryRate = queryRate(window, clock); TODO - OptionalDouble queryRate = snapshots.isEmpty() ? OptionalDouble.empty() : OptionalDouble.of(queryRateAt(snapshots.size() - 1)); + OptionalDouble queryRate = queryRate(window, clock); if (queryRate.orElse(0) == 0) return 0.1; // Growth not expressible as a fraction of the current rate return maxGrowthRate / queryRate.getAsDouble(); } @@ -99,23 +98,13 @@ public class ClusterTimeseries { if (snapshots.isEmpty()) return 0.5; var max = snapshots.stream().mapToDouble(ClusterMetricSnapshot::queryRate).max().getAsDouble(); if (max == 0) return 1.0; - var average = queryRateTemp(window, clock); + var average = queryRate(window, clock); if (average.isEmpty()) return 0.5; // No measurements in the relevant time period return average.getAsDouble() / max; } /** Returns the average query rate in the given window, or empty if there are no measurements in it */ - public OptionalDouble queryRateTemp(Duration window, Clock clock) { // TODO - Instant oldest = clock.instant().minus(window); - return snapshots.stream() - .filter(snapshot -> ! snapshot.at().isBefore(oldest)) - .mapToDouble(snapshot -> snapshot.queryRate()) - .average(); - } - - /** Returns the average query rate in the given window, or empty if there are no measurements in it */ public OptionalDouble queryRate(Duration window, Clock clock) { - if (1==1) return snapshots.isEmpty() ? OptionalDouble.empty() : OptionalDouble.of(queryRateAt(snapshots.size() - 1)); // TODO Instant oldest = clock.instant().minus(window); return snapshots.stream() .filter(snapshot -> ! snapshot.at().isBefore(oldest)) @@ -125,7 +114,6 @@ public class ClusterTimeseries { /** Returns the average query rate in the given window, or empty if there are no measurements in it */ public OptionalDouble writeRate(Duration window, Clock clock) { - if (1==1) return snapshots.isEmpty() ? OptionalDouble.empty() : OptionalDouble.of(writeRateAt(snapshots.size() - 1)); // TODO Instant oldest = clock.instant().minus(window); return snapshots.stream() .filter(snapshot -> ! snapshot.at().isBefore(oldest)) diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java index b15d8d06d8e..17ae36b3636 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java @@ -53,10 +53,11 @@ public class AutoscalingTest { assertTrue("Too few measurements -> No change", tester.autoscale(application1, cluster1.id(), min, max).isEmpty()); tester.clock().advance(Duration.ofDays(1)); - tester.addQueryRateMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only ClusterResources scaledResources = tester.assertResources("Scaling up since resource usage is too high", - 14, 1, 1.4, 30.8, 30.8, + 15, 1, 1.2, 28.6, 28.6, tester.autoscale(application1, cluster1.id(), min, max).target()); tester.deploy(application1, cluster1, scaledResources); @@ -66,15 +67,21 @@ public class AutoscalingTest { tester.clock().advance(Duration.ofDays(2)); tester.addCpuMeasurements(0.8f, 1f, 3, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only assertTrue("Load change is large, but insufficient measurements for new config -> No change", tester.autoscale(application1, cluster1.id(), min, max).isEmpty()); tester.addCpuMeasurements(0.19f, 1f, 100, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only assertEquals("Load change is small -> No change", Optional.empty(), tester.autoscale(application1, cluster1.id(), min, max).target()); tester.addCpuMeasurements(0.1f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling down to minimum since usage has gone down significantly", - 15, 1, 1.0, 28.6, 28.6, + 7, 1, 1.0, 66.7, 66.7, tester.autoscale(application1, cluster1.id(), min, max).target()); var events = tester.nodeRepository().applications().get(application1).get().cluster(cluster1.id()).get().scalingEvents(); @@ -93,9 +100,9 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 5, 1, resources); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only - tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only ClusterResources scaledResources = tester.assertResources("Scaling up since cpu usage is too high", 7, 1, 2.5, 80.0, 80.0, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -104,6 +111,8 @@ public class AutoscalingTest { tester.deactivateRetired(application1, cluster1, scaledResources); tester.addCpuMeasurements(0.1f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling down since cpu usage has gone down", 4, 1, 2.5, 68.6, 68.6, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -183,8 +192,9 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 5, 1, new NodeResources(1.9, 70, 70, 1)); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addMeasurements(0.25f, 0.95f, 0.95f, 0, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up to limit since resource usage is too high", 6, 1, 2.4, 78.0, 79.0, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -220,8 +230,9 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 5, 5, new NodeResources(3.0, 10, 10, 1)); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addCpuMeasurements( 0.3f, 1f, 240, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up since resource usage is too high", 6, 6, 3.6, 8.0, 10.0, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -256,8 +267,9 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 5, 1, resources); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up since resource usage is too high", 7, 1, 2.5, 80.0, 80.0, tester.suggest(application1, cluster1.id(), min, max).target()); @@ -309,8 +321,9 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 5, 5, resources); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up since resource usage is too high", 7, 7, 2.5, 80.0, 80.0, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -328,8 +341,9 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 6, 2, resources); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up since resource usage is too high, changing to 1 group is cheaper", 8, 1, 2.7, 83.3, 83.3, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -348,10 +362,11 @@ public class AutoscalingTest { // deploy tester.deploy(application1, cluster1, 6, 2, new NodeResources(10, 100, 100, 1)); tester.clock().advance(Duration.ofDays(1)); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addMemMeasurements(1.0f, 1f, 1000, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Increase group size to reduce memory load", - 8, 2, 13.6, 89.3, 62.5, + 8, 2, 12.4, 89.3, 62.5, tester.autoscale(application1, cluster1.id(), min, max).target()); } @@ -386,17 +401,20 @@ public class AutoscalingTest { ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.content, "cluster1"); tester.deploy(application1, cluster1, 6, 1, hostResources.withVcpu(hostResources.vcpu() / 2)); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only // No autoscaling as it is too soon to scale down after initial deploy (counting as a scaling event) tester.addMemMeasurements(0.02f, 0.95f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only assertTrue(tester.autoscale(application1, cluster1.id(), min, max).target().isEmpty()); // Trying the same later causes autoscaling tester.clock().advance(Duration.ofDays(2)); tester.addMemMeasurements(0.02f, 0.95f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling down", - 6, 1, 2.9, 4.0, 95.0, + 6, 1, 1.4, 4.0, 95.0, tester.autoscale(application1, cluster1.id(), min, max).target()); } @@ -413,10 +431,11 @@ public class AutoscalingTest { ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.content, "cluster1"); tester.deploy(application1, cluster1, min); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addMeasurements(1.0f, 1.0f, 0.7f, 0, 1000, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up", - 4, 1, 7.4, 20, 200, + 4, 1, 6.7, 20, 200, tester.autoscale(application1, cluster1.id(), min, max).target()); } @@ -427,10 +446,11 @@ public class AutoscalingTest { ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.content, "cluster1"); tester.deploy(application1, cluster1, min); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addMeasurements(1.0f, 1.0f, 0.7f, 0, 1000, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling up", - 4, 1, 7.4, 34, 200, + 4, 1, 6.7, 34, 200, tester.autoscale(application1, cluster1.id(), min, max).target()); } } @@ -467,10 +487,11 @@ public class AutoscalingTest { tester.deactivateRetired(application1, cluster1, scaledResources); tester.clock().advance(Duration.ofDays(2)); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.addMemMeasurements(0.3f, 0.6f, 1000, application1); + tester.clock().advance(Duration.ofMinutes(-10 * 5)); + tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only tester.assertResources("Scaling down since resource usage has gone down", - 6, 1, 3, 83, 28.8, + 5, 1, 3, 83, 36.0, tester.autoscale(application1, cluster1.id(), min, max).target()); } @@ -485,8 +506,9 @@ public class AutoscalingTest { ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.container, "cluster1"); tester.deploy(application1, cluster1, 5, 1, resources); - tester.addQueryRateMeasurements(application1, cluster1.id(), 10, t -> t == 0 ? 20.0 : 10.0); // Query traffic only - tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.addQueryRateMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 20.0 : 10.0); // Query traffic only + tester.clock().advance(Duration.ofMinutes(-100 * 5)); + tester.addCpuMeasurements(0.25f, 1f, 100, application1); // (no read share stored) tester.assertResources("Advice to scale up since we set aside for bcp by default", @@ -519,7 +541,8 @@ public class AutoscalingTest { tester.deploy(application1, cluster1, 5, 1, midResources); tester.addQueryRateMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 20.0 : 10.0); - tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); + tester.addCpuMeasurements(0.25f, 1f, 100, application1); // (no query rate data) tester.assertResources("Scale up since we assume we need 2x cpu for growth when no data scaling time data", @@ -530,7 +553,8 @@ public class AutoscalingTest { tester.addQueryRateMeasurements(application1, cluster1.id(), 100, t -> 10.0 + (t < 50 ? t : 100 - t)); - tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); + tester.addCpuMeasurements(0.25f, 1f, 100, application1); tester.assertResources("Scale down since observed growth is slower than scaling time", 5, 1, 3.4, 100, 100, tester.autoscale(application1, cluster1.id(), min, max).target()); @@ -541,9 +565,10 @@ public class AutoscalingTest { tester.addQueryRateMeasurements(application1, cluster1.id(), 100, t -> 10.0 + (t < 50 ? t * t * t : 125000 - (t - 49) * (t - 49) * (t - 49))); - tester.addCpuMeasurements(0.25f, 1f, 120, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); + tester.addCpuMeasurements(0.25f, 1f, 100, application1); tester.assertResources("Scale up since observed growth is faster than scaling time", - 5, 1, 6.6, 100, 100, + 5, 1, 10.0, 100, 100, tester.autoscale(application1, cluster1.id(), min, max).target()); } @@ -565,26 +590,36 @@ public class AutoscalingTest { // Why twice the query rate at time = 0? // This makes headroom for queries doubling, which we want to observe the effect of here + tester.addCpuMeasurements(0.4f, 1f, 100, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); tester.addLoadMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 20.0 : 10.0, t -> 10.0); tester.assertResources("Query and write load is equal -> scale up somewhat", 5, 1, 7.3, 100, 100, tester.autoscale(application1, cluster1.id(), min, max).target()); + tester.addCpuMeasurements(0.4f, 1f, 100, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); tester.addLoadMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 80.0 : 40.0, t -> 10.0); tester.assertResources("Query load is 4x write load -> scale up more", - 5, 1, 9.1, 100, 100, + 5, 1, 9.5, 100, 100, tester.autoscale(application1, cluster1.id(), min, max).target()); + tester.addCpuMeasurements(0.4f, 1f, 100, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); tester.addLoadMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 20.0 : 10.0, t -> 100.0); tester.assertResources("Write load is 10x query load -> scale down", - 5, 1, 3.7, 100, 100, + 5, 1, 3.8, 100, 100, tester.autoscale(application1, cluster1.id(), min, max).target()); + tester.addCpuMeasurements(0.4f, 1f, 100, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); tester.addLoadMeasurements(application1, cluster1.id(), 100, t -> t == 0 ? 20.0 : 10.0, t-> 0.0); tester.assertResources("Query only -> largest possible", 5, 1, 10.0, 100, 100, tester.autoscale(application1, cluster1.id(), min, max).target()); + tester.addCpuMeasurements(0.4f, 1f, 100, application1); + tester.clock().advance(Duration.ofMinutes(-100 * 5)); tester.addLoadMeasurements(application1, cluster1.id(), 100, t -> 0.0, t -> 10.0); tester.assertResources("Write only -> smallest possible", 5, 1, 2.1, 100, 100, diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java index b49a50cb26f..cc3eeb47073 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java @@ -138,7 +138,7 @@ class AutoscalingTester { NodeList nodes = nodeRepository().nodes().list(Node.State.active).owner(applicationId); float oneExtraNodeFactor = (float)(nodes.size() - 1.0) / (nodes.size()); for (int i = 0; i < count; i++) { - clock().advance(Duration.ofMinutes(1)); + clock().advance(Duration.ofMinutes(5)); for (Node node : nodes) { float cpu = value * oneExtraNodeFactor; float memory = (float) Resource.memory.idealAverageLoad() * otherResourcesLoad * oneExtraNodeFactor; @@ -241,10 +241,9 @@ class AutoscalingTester { int measurements, IntFunction<Double> queryRate, IntFunction<Double> writeRate) { - Instant time = clock().instant(); for (int i = 0; i < measurements; i++) { - db.addClusterMetrics(application, Map.of(cluster, new ClusterMetricSnapshot(time, queryRate.apply(i), writeRate.apply(i)))); - time = time.plus(Duration.ofMinutes(5)); + db.addClusterMetrics(application, Map.of(cluster, new ClusterMetricSnapshot(clock().instant(), queryRate.apply(i), writeRate.apply(i)))); + clock().advance(Duration.ofMinutes(5)); } } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseriesTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseriesTest.java index 988edb71684..c56e65ebbba 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseriesTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterTimeseriesTest.java @@ -71,7 +71,7 @@ public class ClusterTimeseriesTest { var snapshots = new ArrayList<ClusterMetricSnapshot>(); snapshots.addAll(queryRate(100, clock, t -> (double)t)); snapshots.addAll(queryRate(100, clock, t -> 100.0 - t)); - assertEquals(1/5.0, new ClusterTimeseries(cluster, snapshots).maxQueryGrowthRate(Duration.ofMinutes(1), clock), delta); + assertEquals(1/5.0, new ClusterTimeseries(cluster, snapshots).maxQueryGrowthRate(Duration.ofMinutes(5), clock), delta); } @Test diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java index f292ab8ccf1..b0b3f8c3ed8 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java @@ -161,10 +161,19 @@ public class AutoscalingMaintainerTest { tester.clock().advance(Duration.ofDays(1)); - if (i % 2 == 0) // high load - tester.addMeasurements(0.9f, 0.9f, 0.9f, i, 200, app1); - else // low load - tester.addMeasurements(0.1f, 0.1f, 0.1f, i, 200, app1); + if (i % 2 == 0) { // high load + for (int j = 0; j < 200; j++ ) { + tester.addMeasurements(0.99f, 0.99f, 0.99f, i, 1, app1); + tester.clock().advance(Duration.ofMinutes(1)); + } + } + else { // low load + for (int j = 0; j < 200; j++ ) { + tester.addMeasurements(0.2f, 0.2f, 0.2f, i, 1, app1); + tester.clock().advance(Duration.ofMinutes(1)); + } + } + tester.addQueryRateMeasurements(app1, cluster1.id(), 2, t -> (t == 0 ? 20.0 : 10.0 )); tester.maintainer().maintain(); } |