summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-11-30 14:03:36 +0100
committerJon Bratseth <bratseth@gmail.com>2020-11-30 14:03:36 +0100
commit7ad2fca1417f807ebd81a716a2fbfdc458397927 (patch)
tree350d1d6e2ec034fbcadac1d43d45afe8e096cefa /node-repository
parent9a2bce1b48ebcaa807e79ce7bb048ff2e93c6473 (diff)
Add tests
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java34
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java11
2 files changed, 42 insertions, 3 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 5393aa7cfb8..a821bde5b26 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
@@ -225,6 +225,40 @@ public class AutoscalingTest {
}
@Test
+ public void not_using_out_of_service_measurements() {
+ NodeResources resources = new NodeResources(3, 100, 100, 1);
+ ClusterResources min = new ClusterResources(2, 1, new NodeResources(1, 1, 1, 1));
+ ClusterResources max = new ClusterResources(5, 1, new NodeResources(100, 1000, 1000, 1));
+ AutoscalingTester tester = new AutoscalingTester(resources.withVcpu(resources.vcpu() * 2));
+
+ ApplicationId application1 = tester.applicationId("application1");
+ ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.container, "cluster1");
+
+ // deploy
+ tester.deploy(application1, cluster1, 2, 1, resources);
+ tester.addMeasurements(0.5f, 0.6f, 0.7f, 1, false, true, 120, application1);
+ assertTrue("Not scaling up since nodes were measured while cluster was unstable",
+ tester.autoscale(application1, cluster1.id(), min, max).isEmpty());
+ }
+
+ @Test
+ public void not_using_unstable_measurements() {
+ NodeResources resources = new NodeResources(3, 100, 100, 1);
+ ClusterResources min = new ClusterResources(2, 1, new NodeResources(1, 1, 1, 1));
+ ClusterResources max = new ClusterResources(5, 1, new NodeResources(100, 1000, 1000, 1));
+ AutoscalingTester tester = new AutoscalingTester(resources.withVcpu(resources.vcpu() * 2));
+
+ ApplicationId application1 = tester.applicationId("application1");
+ ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.container, "cluster1");
+
+ // deploy
+ tester.deploy(application1, cluster1, 2, 1, resources);
+ tester.addMeasurements(0.5f, 0.6f, 0.7f, 1, true, false, 120, application1);
+ assertTrue("Not scaling up since nodes were measured while cluster was unstable",
+ tester.autoscale(application1, cluster1.id(), min, max).isEmpty());
+ }
+
+ @Test
public void test_autoscaling_group_size_1() {
NodeResources resources = new NodeResources(3, 100, 100, 1);
ClusterResources min = new ClusterResources( 2, 2, new NodeResources(1, 1, 1, 1));
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 783aabcd412..e6a921d055e 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
@@ -175,7 +175,12 @@ class AutoscalingTester {
}
}
- public void addMeasurements(float cpu, float memory, float disk, int generation, int count, ApplicationId applicationId) {
+ public void addMeasurements(float cpu, float memory, float disk, int generation, int count, ApplicationId applicationId) {
+ addMeasurements(cpu, memory, disk, generation, true, true, count, applicationId);
+ }
+
+ public void addMeasurements(float cpu, float memory, float disk, int generation, boolean inService, boolean stable,
+ int count, ApplicationId applicationId) {
List<Node> nodes = nodeRepository().getNodes(applicationId, Node.State.active);
for (int i = 0; i < count; i++) {
clock().advance(Duration.ofMinutes(1));
@@ -185,8 +190,8 @@ class AutoscalingTester {
memory,
disk,
generation,
- true,
- true))));
+ inService,
+ stable))));
}
}
}