summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-07-18 14:43:15 +0200
committerJon Bratseth <bratseth@gmail.com>2022-07-18 14:43:15 +0200
commit48f019e7a249bfb1668c49bc9d0cc90b4fb377df (patch)
treee089fcd96c28c842676d727f2750bf790d5e6044
parentdde3daae88460f558060edb9912664de5a062b40 (diff)
Use fixture
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java65
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java1
2 files changed, 33 insertions, 33 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 b512852a5e7..a2eb5fba9f9 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
@@ -563,7 +563,9 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_in_dev() {
- var fixture = AutoscalingTester.fixture().zone(new Zone(Environment.dev, RegionName.from("us-east"))).build();
+ var fixture = AutoscalingTester.fixture()
+ .zone(new Zone(Environment.dev, RegionName.from("us-east")))
+ .build();
fixture.tester().clock().advance(Duration.ofDays(2));
fixture.applyLoad(1.0, 1.0, 1.0, 200);
assertTrue("Not attempting to scale up because policies dictate we'll only get one node",
@@ -573,43 +575,42 @@ public class AutoscalingTest {
/** Same setup as test_autoscaling_in_dev(), just with required = true */
@Test
public void test_autoscaling_in_dev_with_required_resources() {
- NodeResources resources = new NodeResources(1, 4, 50, 1);
- ClusterResources min = new ClusterResources( 1, 1, resources);
- ClusterResources max = new ClusterResources(3, 1, resources);
- Capacity capacity = Capacity.from(min, max, true, true);
-
- AutoscalingTester tester = new AutoscalingTester(Environment.dev, resources.withVcpu(resources.vcpu() * 2));
- ApplicationId application1 = AutoscalingTester.applicationId("application1");
- ClusterSpec cluster1 = AutoscalingTester.clusterSpec(ClusterSpec.Type.container, "cluster1");
+ var requiredCapacity =
+ Capacity.from(new ClusterResources(2, 1,
+ new NodeResources(1, 1, 1, 1, NodeResources.DiskSpeed.any)),
+ new ClusterResources(20, 1,
+ new NodeResources(100, 1000, 1000, 1, NodeResources.DiskSpeed.any)),
+ true,
+ true);
- tester.deploy(application1, cluster1, capacity);
- tester.addQueryRateMeasurements(application1, cluster1.id(),
- 500, t -> 100.0);
- tester.addCpuMeasurements(1.0f, 1f, 10, application1);
- tester.assertResources("We scale up even in dev because resources are required",
- 3, 1, 1.0, 4, 50,
- tester.autoscale(application1, cluster1, capacity));
+ var fixture = AutoscalingTester.fixture()
+ .capacity(requiredCapacity)
+ .zone(new Zone(Environment.dev, RegionName.from("us-east")))
+ .build();
+ fixture.tester().clock().advance(Duration.ofDays(2));
+ fixture.applyLoad(1.0, 1.0, 1.0, 200);
+ fixture.tester().assertResources("We scale even in dev because resources are required",
+ 3, 1, 1.0, 7.7, 83.3,
+ fixture.autoscale());
}
@Test
public void test_autoscaling_in_dev_with_required_unspecified_resources() {
- NodeResources resources = NodeResources.unspecified();
- ClusterResources min = new ClusterResources( 1, 1, resources);
- ClusterResources max = new ClusterResources(3, 1, resources);
- Capacity capacity = Capacity.from(min, max, true, true);
+ var requiredCapacity =
+ Capacity.from(new ClusterResources(1, 1, NodeResources.unspecified()),
+ new ClusterResources(3, 1, NodeResources.unspecified()),
+ true,
+ true);
- AutoscalingTester tester = new AutoscalingTester(Environment.dev,
- new NodeResources(10, 16, 100, 2));
- ApplicationId application1 = AutoscalingTester.applicationId("application1");
- ClusterSpec cluster1 = AutoscalingTester.clusterSpec(ClusterSpec.Type.container, "cluster1");
-
- tester.deploy(application1, cluster1, capacity);
- tester.addQueryRateMeasurements(application1, cluster1.id(),
- 500, t -> 100.0);
- tester.addCpuMeasurements(1.0f, 1f, 10, application1);
- tester.assertResources("We scale up even in dev because resources are required",
- 3, 1, 1.5, 8, 50,
- tester.autoscale(application1, cluster1, capacity));
+ var fixture = AutoscalingTester.fixture()
+ .capacity(requiredCapacity)
+ .zone(new Zone(Environment.dev, RegionName.from("us-east")))
+ .build();
+ fixture.tester().clock().advance(Duration.ofDays(2));
+ fixture.applyLoad(1.0, 1.0, 1.0, 200);
+ fixture.tester().assertResources("We scale even in dev because resources are required",
+ 3, 1, 1.5, 8, 50,
+ fixture.autoscale());
}
/**
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 efdeab4e6ee..896897f45c1 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
@@ -120,7 +120,6 @@ public class Fixture {
new NodeResources(1, 1, 1, 1, NodeResources.DiskSpeed.any)),
new ClusterResources(20, 1,
new NodeResources(100, 1000, 1000, 1, NodeResources.DiskSpeed.any)));
-
ApplicationId application = AutoscalingTester.applicationId("application1");
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("cluster1")).vespaVersion("7").build();
Zone zone = new Zone(Environment.prod, RegionName.from("us-east"));