diff options
Diffstat (limited to 'node-repository/src/test/java/com/yahoo/vespa')
6 files changed, 76 insertions, 7 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 4236f7ac968..830ff170a90 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 @@ -462,12 +462,12 @@ public class AutoscalingTest { fixture.tester().clock().advance(Duration.ofDays(2)); fixture.loader().applyLoad(new Load(0.01, 0.01, 0.01, 0, 0), 120); - Autoscaling suggestion = fixture.suggest(); + List<Autoscaling> suggestions = fixture.suggest(); fixture.tester().assertResources("Choosing the remote disk flavor as it has less disk", 2, 1, 3.0, 100.0, 10.0, - suggestion); + suggestions); assertEquals("Choosing the remote disk flavor as it has less disk", - StorageType.remote, suggestion.resources().get().nodeResources().storageType()); + StorageType.remote, suggestions.stream().findFirst().flatMap(Autoscaling::resources).get().nodeResources().storageType()); } @Test 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 df85ca4865f..4ce909fece3 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 @@ -108,7 +108,7 @@ public class Fixture { } /** Compute an autoscaling suggestion for this. */ - public Autoscaling suggest() { + public List<Autoscaling> suggest() { return tester().suggest(applicationId, clusterSpec.id(), capacity.minResources(), capacity.maxResources()); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java index f8be27300fe..51297a88cad 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/ScalingSuggestionsMaintainerTest.java @@ -78,6 +78,12 @@ public class ScalingSuggestionsMaintainerTest { assertEquals("7 nodes with [vcpu: 4.1, memory: 5.3 Gb, disk: 16.5 Gb, bandwidth: 0.1 Gbps, architecture: any]", suggestionOf(app2, cluster2, tester).resources().get().toString()); + // Secondary suggestions + assertEquals("7 nodes with [vcpu: 3.7, memory: 4.5 Gb, disk: 10.0 Gb, bandwidth: 0.1 Gbps, architecture: any]", + suggestionsOf(app1, cluster1, tester).get(1).resources().get().toString()); + assertEquals("8 nodes with [vcpu: 3.6, memory: 4.7 Gb, disk: 14.2 Gb, bandwidth: 0.1 Gbps, architecture: any]", + suggestionsOf(app2, cluster2, tester).get(1).resources().get().toString()); + // Utilization goes way down tester.clock().advance(Duration.ofHours(13)); addMeasurements(0.10f, 0.10f, 0.10f, 0, 500, app1, tester.nodeRepository()); @@ -97,7 +103,7 @@ public class ScalingSuggestionsMaintainerTest { tester.clock().advance(Duration.ofDays(3)); addMeasurements(0.7f, 0.7f, 0.7f, 0, 500, app1, tester.nodeRepository()); maintainer.maintain(); - var suggested = tester.nodeRepository().applications().get(app1).get().cluster(cluster1.id()).get().suggested().resources().get(); + var suggested = tester.nodeRepository().applications().get(app1).get().cluster(cluster1.id()).get().suggestions().stream().findFirst().flatMap(Autoscaling::resources).get(); tester.deploy(app1, cluster1, Capacity.from(suggested, suggested, IntRange.empty(), false, true, Optional.empty(), ClusterInfo.empty())); tester.clock().advance(Duration.ofDays(2)); @@ -121,7 +127,11 @@ public class ScalingSuggestionsMaintainerTest { } private Autoscaling suggestionOf(ApplicationId app, ClusterSpec cluster, ProvisioningTester tester) { - return tester.nodeRepository().applications().get(app).get().cluster(cluster.id()).get().suggested(); + return suggestionsOf(app, cluster, tester).get(0); + } + + private List<Autoscaling> suggestionsOf(ApplicationId app, ClusterSpec cluster, ProvisioningTester tester) { + return tester.nodeRepository().applications().get(app).get().cluster(cluster.id()).get().suggestions(); } private boolean shouldSuggest(ApplicationId app, ClusterSpec cluster, ProvisioningTester tester) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/ApplicationSerializerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/ApplicationSerializerTest.java index 918a9043c93..90af6dca090 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/ApplicationSerializerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/ApplicationSerializerTest.java @@ -41,6 +41,7 @@ public class ApplicationSerializerTest { IntRange.empty(), true, Autoscaling.empty(), + List.of(), Autoscaling.empty(), ClusterInfo.empty(), BcpGroupInfo.empty(), @@ -60,6 +61,14 @@ public class ApplicationSerializerTest { new Load(0.1, 0.2, 0.3, 0.4, 0.5), new Load(0.4, 0.5, 0.6, 0.7, 0.8), new Autoscaling.Metrics(0.7, 0.8, 0.9)), + List.of(new Autoscaling(Autoscaling.Status.unavailable, + "", + Optional.of(new ClusterResources(20, 10, + new NodeResources(0.5, 4, 14, 16))), + Instant.ofEpochMilli(1234L), + new Load(0.1, 0.2, 0.3, 0.4, 0.5), + new Load(0.4, 0.5, 0.6, 0.7, 0.8), + new Autoscaling.Metrics(0.7, 0.8, 0.9))), new Autoscaling(Autoscaling.Status.insufficient, "Autoscaling status", Optional.of(new ClusterResources(10, 5, @@ -98,6 +107,7 @@ public class ApplicationSerializerTest { assertEquals(originalCluster.groupSize(), serializedCluster.groupSize()); assertEquals(originalCluster.required(), serializedCluster.required()); assertEquals(originalCluster.suggested(), serializedCluster.suggested()); + assertEquals(originalCluster.suggestions(), serializedCluster.suggestions()); assertEquals(originalCluster.target(), serializedCluster.target()); assertEquals(originalCluster.clusterInfo(), serializedCluster.clusterInfo()); assertEquals(originalCluster.bcpGroupInfo(), serializedCluster.bcpGroupInfo()); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java index be2b2ca896a..6b6ef49fa5d 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTester.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Optional; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -143,6 +144,7 @@ public class DynamicProvisioningTester { cluster.groupSize(), cluster.required(), cluster.suggested(), + cluster.suggestions(), cluster.target(), cluster.clusterInfo(), cluster.bcpGroupInfo(), @@ -165,7 +167,7 @@ public class DynamicProvisioningTester { nodeRepository().nodes().list(Node.State.active).owner(applicationId)); } - public Autoscaling suggest(ApplicationId applicationId, ClusterSpec.Id clusterId, + public List<Autoscaling> suggest(ApplicationId applicationId, ClusterSpec.Id clusterId, ClusterResources min, ClusterResources max) { Application application = nodeRepository().applications().get(applicationId).orElse(Application.empty(applicationId)) .withCluster(clusterId, false, Capacity.from(min, max)); @@ -199,6 +201,14 @@ public class DynamicProvisioningTester { public ClusterResources assertResources(String message, int nodeCount, int groupCount, double approxCpu, double approxMemory, double approxDisk, + List<Autoscaling> autoscaling) { + assertFalse(autoscaling.isEmpty()); + return assertResources(message, nodeCount, groupCount, approxCpu, approxMemory, approxDisk, autoscaling.get(0)); + } + + public ClusterResources assertResources(String message, + int nodeCount, int groupCount, + double approxCpu, double approxMemory, double approxDisk, Autoscaling autoscaling) { assertTrue("Resources should be present: " + message + " (" + autoscaling + ": " + autoscaling.status() + ")", autoscaling.resources().isPresent()); 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 d5bbc648ed8..e74e705e1aa 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 @@ -82,6 +82,45 @@ "cpuCostPerQuery" : 0.0 } }, + "suggestions": [ + { + "at": 123, + "description": "", + "ideal": { + "cpu": 0.0, + "disk": 0.0, + "gpu": 0.0, + "gpuMemory": 0.0, + "memory": 0.0 + }, + "metrics": { + "cpuCostPerQuery": 0.0, + "growthRateHeadroom": 0.0, + "queryRate": 0.0 + }, + "peak": { + "cpu": 0.0, + "disk": 0.0, + "gpu": 0.0, + "gpuMemory": 0.0, + "memory": 0.0 + }, + "resources": { + "groups": 2, + "nodes": 6, + "resources": { + "architecture": "any", + "bandwidthGbps": 1.0, + "diskGb": 100.0, + "diskSpeed": "fast", + "memoryGb": 20.0, + "storageType": "any", + "vcpu": 3.0 + } + }, + "status": "unavailable" + } + ], "target" : { "status" : "unavailable", "description" : "", |