summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-07-18 13:02:28 +0200
committerJon Bratseth <bratseth@gmail.com>2022-07-18 13:02:28 +0200
commitbef65c951ee5d1ad986e6e6ec8ab2e16726fc34b (patch)
tree0619a8e920a94a9bd9687650334eb6daf1e29a62
parent09ddb0276ba6d7433d932722a4ed49fd02a612f2 (diff)
Use fixture
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java42
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java8
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java4
3 files changed, 22 insertions, 32 deletions
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 59696f7d442..b135d913fde 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
@@ -452,34 +452,28 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_considers_read_share() {
- NodeResources resources = new NodeResources(3, 100, 100, 1);
- ClusterResources min = new ClusterResources( 1, 1, resources);
- ClusterResources max = new ClusterResources(10, 1, resources);
- var capacity = Capacity.from(min, max);
- AutoscalingTester tester = new AutoscalingTester(resources.withVcpu(resources.vcpu() * 2));
-
- ApplicationId application1 = AutoscalingTester.applicationId("application1");
- ClusterSpec cluster1 = AutoscalingTester.clusterSpec(ClusterSpec.Type.container, "cluster1");
-
- tester.deploy(application1, cluster1, 5, 1, resources);
- 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);
+ var min = new ClusterResources( 1, 1, new NodeResources(3, 100, 100, 1));
+ var max = new ClusterResources(10, 1, new NodeResources(3, 100, 100, 1));
+ var fixture = AutoscalingTester.fixture()
+ .capacity(Capacity.from(min, max))
+ .build();
+ fixture.tester.clock().advance(Duration.ofDays(1));
+ fixture.applyCpuLoad(0.25, 120);
// (no read share stored)
- tester.assertResources("Advice to scale up since we set aside for bcp by default",
- 7, 1, 3, 100, 100,
- tester.autoscale(application1, cluster1, capacity));
+ fixture.tester().assertResources("Advice to scale up since we set aside for bcp by default",
+ 7, 1, 3, 100, 100,
+ fixture.autoscale());
- tester.storeReadShare(0.25, 0.5, application1);
- tester.assertResources("Half of global share is the same as the default assumption used above",
- 7, 1, 3, 100, 100,
- tester.autoscale(application1, cluster1, capacity));
+ fixture.storeReadShare(0.25, 0.5);
+ fixture.tester().assertResources("Half of global share is the same as the default assumption used above",
+ 7, 1, 3, 100, 100,
+ fixture.autoscale());
- tester.storeReadShare(0.5, 0.5, application1);
- tester.assertResources("Advice to scale down since we don't need room for bcp",
- 4, 1, 3, 100, 100,
- tester.autoscale(application1, cluster1, capacity));
+ fixture.storeReadShare(0.5, 0.5);
+ fixture.tester().assertResources("Advice to scale down since we don't need room for bcp",
+ 6, 1, 3, 100, 100,
+ fixture.autoscale());
}
@Test
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 e3f85a16c3d..2a052c308b6 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
@@ -57,14 +57,6 @@ class AutoscalingTester {
this(new Zone(environment, RegionName.from("us-east")), hostResources, null);
}
- public AutoscalingTester(Zone zone, NodeResources hostResources) {
- this(zone, hostResources, null);
- }
-
- public AutoscalingTester(Zone zone, NodeResources hostResources, int hostCount) {
- this(zone, hostResources, null, hostCount);
- }
-
public AutoscalingTester(Zone zone, NodeResources hostResources, HostResourcesCalculator resourcesCalculator) {
this(zone, hostResources, resourcesCalculator, 20);
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java
index 751e221f19e..fe291eb6c6b 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java
@@ -104,6 +104,10 @@ public class Fixture {
tester().addQueryRateMeasurements(application, cluster.id(), measurements, samplingInterval, t -> t == 0 ? 20.0 : 10.0); // Query traffic only
}
+ public void storeReadShare(double currentReadShare, double maxReadShare) {
+ tester.storeReadShare(currentReadShare, maxReadShare, application);
+ }
+
public static class Builder {
NodeResources hostResources = new NodeResources(100, 100, 100, 1);