diff options
Diffstat (limited to 'node-repository/src/test/java/com/yahoo')
5 files changed, 62 insertions, 37 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 e6873e7118f..28f37546eb6 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 @@ -19,6 +19,7 @@ import com.yahoo.vespa.hosted.provision.NodeRepository; import com.yahoo.vespa.hosted.provision.Nodelike; import com.yahoo.vespa.hosted.provision.provisioning.CapacityPolicies; import com.yahoo.vespa.hosted.provision.provisioning.HostResourcesCalculator; +import org.junit.Ignore; import org.junit.Test; import java.time.Duration; @@ -69,10 +70,18 @@ public class AutoscalingTest { /** Using too many resources for a short period is proof we should scale up regardless of the time that takes. */ @Test - public void test_autoscaling_up_is_fast_TODO() { + public void test_no_autoscaling_with_no_measurements() { var fixture = AutoscalingTester.fixture().build(); - fixture.tester().clock().advance(Duration.ofDays(1)); // TODO: Remove the need for this - fixture.loader().applyLoad(1.0, 1.0, 1.0, 120); // TODO: Make this low + System.out.println(fixture.autoscale()); + assertTrue(fixture.autoscale().target().isEmpty()); + } + + /** Using too many resources for a short period is proof we should scale up regardless of the time that takes. */ + @Test + @Ignore // TODO + public void test_autoscaling_up_is_fast() { + var fixture = AutoscalingTester.fixture().build(); + fixture.loader().applyLoad(1.0, 1.0, 1.0, 1); fixture.tester().assertResources("Scaling up since resource usage is too high", 10, 1, 9.4, 8.5, 92.6, fixture.autoscale()); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModelTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModelTest.java index 516a7a92d04..0b3b8a3ea11 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModelTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/ClusterModelTest.java @@ -27,50 +27,64 @@ public class ClusterModelTest { private static final double delta = 0.001; @Test - public void test_traffic_headroom() { - ManualClock clock = new ManualClock(); - Application application = Application.empty(ApplicationId.from("t1", "a1", "i1")); - ClusterSpec clusterSpec = clusterSpec(); - Cluster cluster = cluster(new NodeResources(1, 10, 100, 1)); - application = application.with(cluster); + public void unit_adjustment_should_cause_no_change() { + var model = clusterModelWithNoData(); // 5 nodes, 1 group + assertEquals(Load.one(), model.loadAdjustment()); + System.out.println("Ideal load: " + model.idealLoad()); + System.out.println("Load without redundancy: " + model.loadWith(5, 1)); + System.out.println("Load with redundancy: " + model.loadWith(4, 1)); + var target = model.loadAdjustment().scaled(resources()); + System.out.println("Target: " + target); + int testingNodes = 5 - 1; + int currentNodes = 5 - 1; + assertEquals(resources(), model.loadWith(testingNodes, 1).scaled(Load.one().divide(model.loadWith(currentNodes, 1)).scaled(target))); + } + @Test + public void test_traffic_headroom() { // No current traffic share: Ideal load is low but capped - var model1 = new ClusterModel(application.with(new Status(0.0, 1.0)), - clusterSpec, cluster, clock, Duration.ofMinutes(10), - timeseries(cluster,100, t -> t == 0 ? 10000.0 : 0.0, t -> 0.0, clock), - ClusterNodesTimeseries.empty()); - assertEquals(0.131, model1.idealLoad().cpu(), delta); + var model1 = clusterModel(new Status(0.0, 1.0), + t -> t == 0 ? 10000.0 : 0.0, t -> 0.0); + assertEquals(0.10672097759674132, model1.idealLoad().cpu(), delta); // Almost no current traffic share: Ideal load is low but capped - var model2 = new ClusterModel(application.with(new Status(0.0001, 1.0)), - clusterSpec, cluster, clock, Duration.ofMinutes(10), - timeseries(cluster,100, t -> t == 0 ? 10000.0 : 0.0, t -> 0.0, clock), - ClusterNodesTimeseries.empty()); - assertEquals(0.131, model2.idealLoad().cpu(), delta); + var model2 = clusterModel(new Status(0.0001, 1.0), + t -> t == 0 ? 10000.0 : 0.0, t -> 0.0); + assertEquals(0.10672097759674132, model2.idealLoad().cpu(), delta); } @Test public void test_growth_headroom() { - ManualClock clock = new ManualClock(); + // No current traffic: Ideal load is low but capped + var model1 = clusterModel(new Status(0.0, 0.0), + t -> t == 0 ? 10000.0 : 0.0, t -> 0.0); + assertEquals(0.2240325865580448, model1.idealLoad().cpu(), delta); + // Almost no current traffic: Ideal load is low but capped + var model2 = clusterModel(new Status(0.0001, 1.0), + t -> t == 0 ? 10000.0 : 0.0001, t -> 0.0); + assertEquals(0.0326530612244898, model2.idealLoad().cpu(), delta); + } + + private ClusterModel clusterModelWithNoData() { + return clusterModel(new Status(0.0, 1.0), t -> 0.0, t -> 0.0); + } + + private ClusterModel clusterModel(Status status, IntFunction<Double> queryRate, IntFunction<Double> writeRate) { + ManualClock clock = new ManualClock(); Application application = Application.empty(ApplicationId.from("t1", "a1", "i1")); ClusterSpec clusterSpec = clusterSpec(); - Cluster cluster = cluster(new NodeResources(1, 10, 100, 1)); + Cluster cluster = cluster(resources()); application = application.with(cluster); - // No current traffic: Ideal load is low but capped - var model1 = new ClusterModel(application, - clusterSpec, cluster, clock, Duration.ofMinutes(10), - timeseries(cluster,100, t -> t == 0 ? 10000.0 : 0.0, t -> 0.0, clock), - ClusterNodesTimeseries.empty()); - assertEquals(0.275, model1.idealLoad().cpu(), delta); + return new ClusterModel(application.with(status), + clusterSpec, cluster, clock, Duration.ofMinutes(10), + timeseries(cluster,100, queryRate, writeRate, clock), + ClusterNodesTimeseries.empty()); + } - // Almost no current traffic: Ideal load is low but capped - var model2 = new ClusterModel(application.with(new Status(0.0001, 1.0)), - clusterSpec, cluster, clock, Duration.ofMinutes(10), - timeseries(cluster,100, t -> t == 0 ? 10000.0 : 0.0001, t -> 0.0, clock), - ClusterNodesTimeseries.empty()); - assertEquals(0.040, model2.idealLoad().cpu(), delta); + private NodeResources resources() { + return new NodeResources(1, 10, 100, 1); } private ClusterSpec clusterSpec() { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Loader.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Loader.java index db4fe917b53..c0203f5f202 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Loader.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Loader.java @@ -33,6 +33,7 @@ public class Loader { * @param count the number of measurements */ public Duration addCpuMeasurements(double value, int count) { + var idealLoad = fixture.clusterModel().idealLoad(); // TODO: Use this NodeList nodes = fixture.nodes(); float oneExtraNodeFactor = (float)(nodes.size() - 1.0) / (nodes.size()); Instant initialTime = fixture.tester().clock().instant(); @@ -88,6 +89,7 @@ public class Loader { * wanting to see the ideal load with one node missing.) */ public void addMemMeasurements(double value, int count) { + var idealLoad = fixture.clusterModel().idealLoad(); // TODO: Use this NodeList nodes = fixture.nodes(); float oneExtraNodeFactor = (float)(nodes.size() - 1.0) / (nodes.size()); for (int i = 0; i < count; i++) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json index 63a604bf4eb..40719153b9e 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application1.json @@ -71,7 +71,7 @@ }, "utilization" : { "cpu" : 0.0, - "idealCpu": 0.275, + "idealCpu": 0.1375, "currentCpu": 0.0, "memory" : 0.0, "idealMemory": 0.65, diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json index eddf9b957a7..41aa4257c00 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/application2.json @@ -45,13 +45,13 @@ }, "utilization" : { "cpu" : 0.0, - "idealCpu": 0.2664285714285714, + "idealCpu": 0.1394913986537023, "currentCpu": 0.0, "memory" : 0.0, - "idealMemory": 0.65, + "idealMemory": 0.325, "currentMemory": 0.0, "disk" : 0.0, - "idealDisk": 0.6, + "idealDisk": 0.3, "currentDisk": 0.0 }, "scalingEvents" : [ |