aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/test
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-04 11:49:26 +0100
committerJon Bratseth <bratseth@gmail.com>2023-01-04 11:49:26 +0100
commit679652383a8e2461be0af85c3a46d77db2bfbda5 (patch)
tree007a94f8a2643b079be2da1f923615d28854e8f2 /node-repository/src/test
parent20a6b5041b179a382a90ca37382a0b6ba3f963f7 (diff)
Don't replace measurements by empty
Diffstat (limited to 'node-repository/src/test')
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java4
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java30
2 files changed, 32 insertions, 2 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 077675b4f0d..4ce07d53ea9 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
@@ -730,12 +730,14 @@ public class AutoscalingTest {
fixture.currentResources().advertisedResources());
fixture.tester().deploy(fixture.applicationId(), clusterSpec(false), fixture.capacity());
+ fixture.loader().applyLoad(new Load(0.1, 0.1, 0.1), 100);
fixture.tester().assertResources("With non-exclusive nodes, a better solution is " +
"50% more nodes with half the cpu",
- 3, 1, 1, 4, 145.6,
+ 3, 1, 1, 4, 100.0,
fixture.autoscale());
fixture.tester().deploy(fixture.applicationId(), clusterSpec(true), fixture.capacity());
+ fixture.loader().applyLoad(new Load(0.1, 0.1, 0.1), 100);
fixture.tester().assertResources("Reverts to the initial resources",
2, 1, 2, 4, 100,
fixture.currentResources().advertisedResources());
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java
index 00cad5183eb..3084ce9215a 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/AutoscalingMaintainerTest.java
@@ -16,6 +16,7 @@ import com.yahoo.vespa.hosted.provision.NodeRepository;
import com.yahoo.vespa.hosted.provision.applications.Cluster;
import com.yahoo.vespa.hosted.provision.applications.ScalingEvent;
import com.yahoo.vespa.hosted.provision.autoscale.ClusterModel;
+import com.yahoo.vespa.hosted.provision.autoscale.Load;
import com.yahoo.vespa.hosted.provision.node.Agent;
import com.yahoo.vespa.hosted.provision.node.History;
import com.yahoo.vespa.hosted.provision.testutils.MockDeployer;
@@ -28,6 +29,7 @@ import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -53,7 +55,6 @@ public class AutoscalingMaintainerTest {
new MockDeployer.ApplicationContext(app1, cluster1, Capacity.from(new ClusterResources(2, 1, lowResources))),
new MockDeployer.ApplicationContext(app2, cluster2, Capacity.from(new ClusterResources(2, 1, highResources))));
-
tester.maintainer().maintain(); // noop
assertTrue(tester.deployer().lastDeployTime(app1).isEmpty());
assertTrue(tester.deployer().lastDeployTime(app2).isEmpty());
@@ -299,6 +300,33 @@ public class AutoscalingMaintainerTest {
.size());
}
+ @Test
+ public void empty_autoscaling_is_ignored() {
+ ApplicationId app1 = AutoscalingMaintainerTester.makeApplicationId("app1");
+ ClusterSpec cluster1 = AutoscalingMaintainerTester.containerClusterSpec();
+ NodeResources resources = new NodeResources(4, 4, 10, 1);
+ ClusterResources min = new ClusterResources(2, 1, resources);
+ ClusterResources max = new ClusterResources(20, 1, resources);
+ var capacity = Capacity.from(min, max);
+ var tester = new AutoscalingMaintainerTester(new MockDeployer.ApplicationContext(app1, cluster1, capacity));
+
+ // Add a scaling event
+ tester.deploy(app1, cluster1, capacity);
+ tester.addMeasurements(1.0f, 0.3f, 0.3f, 0, 4, app1, cluster1.id());
+ tester.maintainer().maintain();
+ assertEquals("Scale up: " + tester.cluster(app1, cluster1).target().status(),
+ 1,
+ tester.cluster(app1, cluster1).lastScalingEvent().get().generation());
+ Load peak = tester.cluster(app1, cluster1).target().peak();
+ assertNotEquals(Load.zero(), peak);
+
+ // Old measurements go out of scope and no new ones are made
+ tester.clock().advance(Duration.ofDays(1));
+ tester.maintainer().maintain();
+ Load newPeak = tester.cluster(app1, cluster1).target().peak();
+ assertEquals("Old measurements are retained", peak, newPeak);
+ }
+
private void autoscale(boolean down, Duration completionTime, Duration expectedWindow,
ManualClock clock, ApplicationId application, ClusterSpec cluster,
AutoscalingMaintainerTester tester) {