summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-11-14 14:18:37 +0100
committerJon Bratseth <bratseth@gmail.com>2022-11-14 14:18:37 +0100
commit8e1caf787e82fceadcf308e74f0cf088373f573e (patch)
treeaab41b8ae91dce179beac6d86464aff6c757df0c /node-repository
parent60e0c807988226eba418e9c80da2fd0b8f5e9015 (diff)
Use dynamic provisioning in AWS tests
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/HostProvisioner.java4
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java3
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingIntegrationTest.java1
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java48
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java5
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/Fixture.java12
6 files changed, 50 insertions, 23 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/HostProvisioner.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/HostProvisioner.java
index eb0877be4d7..95d10557e3a 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/HostProvisioner.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/HostProvisioner.java
@@ -24,6 +24,7 @@ import java.util.function.Consumer;
public interface HostProvisioner {
enum HostSharing {
+
/** The host must be provisioned exclusively for the applicationId */
exclusive,
@@ -32,6 +33,7 @@ public interface HostProvisioner {
/** The client has no requirements on whether the host must be provisioned exclusively or shared. */
any
+
}
/**
@@ -39,7 +41,7 @@ public interface HostProvisioner {
*
* @param provisionIndices list of unique provision indices which will be used to generate the node hostnames
* on the form of <code>[prefix][index].[domain]</code>
- * @param hostType The host type to provision
+ * @param hostType the host type to provision
* @param resources the resources needed per node - the provisioned host may be significantly larger
* @param applicationId id of the application that will own the provisioned host
* @param osVersion the OS version to use. If this version does not exist, implementations may choose a suitable
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java
index 76e16e9fbaf..aa4c763fcdc 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockHostProvisioner.java
@@ -65,7 +65,8 @@ public class MockHostProvisioner implements HostProvisioner {
ApplicationId applicationId, Version osVersion, HostSharing sharing,
Optional<ClusterSpec.Type> clusterType, CloudAccount cloudAccount,
Consumer<List<ProvisionedHost>> provisionedHostsConsumer) {
- Flavor hostFlavor = this.hostFlavor.orElseGet(() -> flavors.stream().filter(f -> compatible(f, resources))
+ Flavor hostFlavor = this.hostFlavor.orElseGet(() -> flavors.stream()
+ .filter(f -> compatible(f, resources))
.findFirst()
.orElseThrow(() -> new NodeAllocationException("No host flavor matches " + resources, true)));
List<ProvisionedHost> hosts = new ArrayList<>();
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingIntegrationTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingIntegrationTest.java
index 290f7c3bbaf..c65ebae9b3b 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingIntegrationTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingIntegrationTest.java
@@ -23,6 +23,7 @@ public class AutoscalingIntegrationTest {
@Test
public void testComponentIntegration() {
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.hostFlavors(new NodeResources(3, 20, 200, 1))
.initialResources(Optional.of(new ClusterResources(2, 1,
new NodeResources(1, 10, 100, 1))))
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 25c5b772655..79c524c3ceb 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
@@ -2,7 +2,6 @@
package com.yahoo.vespa.hosted.provision.autoscale;
import com.yahoo.config.provision.Capacity;
-import com.yahoo.config.provision.Cloud;
import com.yahoo.config.provision.ClusterResources;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Environment;
@@ -19,7 +18,6 @@ import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.hosted.provision.NodeRepository;
import com.yahoo.vespa.hosted.provision.Nodelike;
-import com.yahoo.vespa.hosted.provision.autoscale.awsnodes.AwsHostResourcesCalculatorImpl;
import com.yahoo.vespa.hosted.provision.provisioning.CapacityPolicies;
import com.yahoo.vespa.hosted.provision.provisioning.HostResourcesCalculator;
import org.junit.Test;
@@ -37,7 +35,7 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_single_content_group() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.loader().applyCpuLoad(0.7f, 10);
ClusterResources scaledResources = fixture.tester().assertResources("Scaling up since resource usage is too high",
@@ -65,14 +63,14 @@ 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_no_autoscaling_with_no_measurements() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
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
public void test_autoscaling_up_is_fast() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.loader().applyLoad(new Load(1.0, 1.0, 1.0), 3);
fixture.tester().assertResources("Scaling up since resource usage is too high",
10, 1, 7.2, 8.5, 92.6,
@@ -82,7 +80,7 @@ public class AutoscalingTest {
/** When scaling up, disregard underutilized dimensions (memory here) */
@Test
public void test_only_autoscaling_up_quickly() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.loader().applyLoad(new Load(1.0, 0.1, 1.0), 10);
fixture.tester().assertResources("Scaling up (only) since resource usage is too high",
10, 1, 8.6, 4.4, 92.6,
@@ -92,7 +90,7 @@ public class AutoscalingTest {
/** When ok to scale down, scale in both directions simultaneously (compare to test_only_autoscaling_up_quickly) */
@Test
public void test_scale_in_both_directions_when_ok_to_scale_down() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.tester.clock().advance(Duration.ofDays(2));
fixture.loader().applyLoad(new Load(1.0, 0.1, 1.0), 10);
fixture.tester().assertResources("Scaling up (only) since resource usage is too high",
@@ -102,7 +100,7 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_uses_peak() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.loader().applyCpuLoad(0.01, 100);
fixture.loader().applyCpuLoad(0.70, 1);
fixture.loader().applyCpuLoad(0.01, 100);
@@ -131,7 +129,7 @@ public class AutoscalingTest {
/** We prefer fewer nodes for container clusters as (we assume) they all use the same disk and memory */
@Test
public void test_autoscaling_single_container_group() {
- var fixture = AutoscalingTester.fixture().clusterType(ClusterSpec.Type.container).build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).clusterType(ClusterSpec.Type.container).build();
fixture.loader().applyCpuLoad(0.25f, 120);
ClusterResources scaledResources = fixture.tester().assertResources("Scaling cpu up",
@@ -149,6 +147,7 @@ public class AutoscalingTest {
public void autoscaling_handles_disk_setting_changes() {
var resources = new NodeResources(3, 100, 100, 1, slow);
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.hostFlavors(resources)
.initialResources(Optional.of(new ClusterResources(5, 1, resources)))
.capacity(Capacity.from(new ClusterResources(5, 1, resources)))
@@ -183,6 +182,7 @@ public class AutoscalingTest {
new ClusterResources( 10, 1, resources.with(DiskSpeed.any)));
var fixture = AutoscalingTester.fixture()
.capacity(capacity)
+ .hostCount(20)
.initialResources(Optional.empty())
.build();
@@ -204,6 +204,7 @@ public class AutoscalingTest {
var now = new ClusterResources(5, 1, new NodeResources(1.9, 70, 70, 1));
var max = new ClusterResources( 6, 1, new NodeResources(2.4, 78, 79, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max)).build();
@@ -218,7 +219,7 @@ public class AutoscalingTest {
public void autoscaling_respects_lower_limit() {
var min = new ClusterResources( 4, 1, new NodeResources(1.8, 7.4, 8.5, 1));
var max = new ClusterResources( 6, 1, new NodeResources(2.4, 78, 79, 1));
- var fixture = AutoscalingTester.fixture().capacity(Capacity.from(min, max)).build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).capacity(Capacity.from(min, max)).build();
// deploy
fixture.tester().clock().advance(Duration.ofDays(2));
@@ -233,6 +234,7 @@ public class AutoscalingTest {
var min = new ClusterResources( 2, 1, NodeResources.unspecified());
var max = new ClusterResources( 6, 1, NodeResources.unspecified());
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.empty())
.capacity(Capacity.from(min, max))
.build();
@@ -257,6 +259,7 @@ public class AutoscalingTest {
var now = new ClusterResources(5, 5, new NodeResources(3.0, 10, 10, 1));
var max = new ClusterResources(18, 6, new NodeResources(100, 1000, 1000, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max))
.build();
@@ -270,7 +273,7 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_limits_when_min_equals_max() {
ClusterResources min = new ClusterResources( 2, 1, new NodeResources(1, 1, 1, 1));
- var fixture = AutoscalingTester.fixture().capacity(Capacity.from(min, min)).build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).capacity(Capacity.from(min, min)).build();
// deploy
fixture.tester().clock().advance(Duration.ofDays(1));
@@ -327,7 +330,7 @@ public class AutoscalingTest {
@Test
public void suggestions_ignores_limits() {
ClusterResources min = new ClusterResources( 2, 1, new NodeResources(1, 1, 1, 1));
- var fixture = AutoscalingTester.fixture().capacity(Capacity.from(min, min)).build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).capacity(Capacity.from(min, min)).build();
fixture.tester().clock().advance(Duration.ofDays(2));
fixture.loader().applyCpuLoad(1.0, 120);
fixture.tester().assertResources("Suggesting above capacity limit",
@@ -337,7 +340,7 @@ public class AutoscalingTest {
@Test
public void not_using_out_of_service_measurements() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.tester().clock().advance(Duration.ofDays(2));
fixture.loader().applyLoad(new Load(0.9, 0.6, 0.7), 1, false, true, 120);
assertTrue("Not scaling up since nodes were measured while cluster was out of service",
@@ -346,7 +349,7 @@ public class AutoscalingTest {
@Test
public void not_using_unstable_measurements() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.tester().clock().advance(Duration.ofDays(2));
fixture.loader().applyLoad(new Load(0.9, 0.6, 0.7), 1, true, false, 120);
assertTrue("Not scaling up since nodes were measured while cluster was unstable",
@@ -359,6 +362,7 @@ public class AutoscalingTest {
var now = new ClusterResources(5, 5, new NodeResources(3, 100, 100, 1));
var max = new ClusterResources(20, 20, new NodeResources(10, 1000, 1000, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max))
.build();
@@ -375,6 +379,7 @@ public class AutoscalingTest {
var now = new ClusterResources(6, 2, new NodeResources(3, 100, 100, 1));
var max = new ClusterResources(21, 7, new NodeResources(100, 1000, 1000, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max))
.build();
@@ -394,6 +399,7 @@ public class AutoscalingTest {
var now = new ClusterResources(6, 2, new NodeResources(3, 100, 100, 1));
var max = new ClusterResources(21, 7, new NodeResources(100, 1000, 1000, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max))
.build();
@@ -412,6 +418,7 @@ public class AutoscalingTest {
var now = new ClusterResources(6, 2, new NodeResources(10, 100, 100, 1));
var max = new ClusterResources(30, 30, new NodeResources(100, 100, 1000, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max))
.build();
@@ -428,6 +435,7 @@ public class AutoscalingTest {
var now = new ClusterResources(6, 1, new NodeResources(3, 100, 100, 1));
var max = new ClusterResources(20, 1, new NodeResources(100, 1000, 1000, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.initialResources(Optional.of(now))
.capacity(Capacity.from(min, max))
.build();
@@ -440,7 +448,7 @@ public class AutoscalingTest {
@Test
public void scaling_down_only_after_delay() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.loader().applyCpuLoad(0.02, 120);
assertTrue("Too soon after initial deployment", fixture.autoscale().target().isEmpty());
fixture.tester().clock().advance(Duration.ofDays(2));
@@ -454,6 +462,7 @@ public class AutoscalingTest {
public void test_autoscaling_considers_real_resources() {
{ // No memory tax
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.resourceCalculator(new OnlySubtractingWhenForecastingCalculator(0))
.build();
fixture.loader().applyLoad(new Load(1.0, 1.0, 0.7), 1000);
@@ -464,6 +473,7 @@ public class AutoscalingTest {
{
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.resourceCalculator(new OnlySubtractingWhenForecastingCalculator(3))
.build();
fixture.loader().applyLoad(new Load(1.0, 1.0, 0.7), 1000);
@@ -508,6 +518,7 @@ public class AutoscalingTest {
var min = new ClusterResources( 1, 1, new NodeResources(3, 100, 100, 1));
var max = new ClusterResources(10, 1, new NodeResources(3, 100, 100, 1));
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.capacity(Capacity.from(min, max))
.build();
@@ -534,7 +545,7 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_considers_growth_rate() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.tester().clock().advance(Duration.ofDays(2));
Duration timeAdded = fixture.loader().addLoadMeasurements(100, t -> t == 0 ? 20.0 : 10.0, t -> 0.0);
@@ -568,7 +579,7 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_considers_query_vs_write_rate() {
- var fixture = AutoscalingTester.fixture().build();
+ var fixture = AutoscalingTester.fixture().hostCount(20).build();
fixture.loader().addCpuMeasurements(0.4, 220);
@@ -620,6 +631,7 @@ public class AutoscalingTest {
@Test
public void test_autoscaling_in_dev() {
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.zone(new Zone(Environment.dev, RegionName.from("us-east")))
.build();
fixture.tester().clock().advance(Duration.ofDays(2));
@@ -640,6 +652,7 @@ public class AutoscalingTest {
true);
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.capacity(requiredCapacity)
.zone(new Zone(Environment.dev, RegionName.from("us-east")))
.build();
@@ -659,6 +672,7 @@ public class AutoscalingTest {
true);
var fixture = AutoscalingTester.fixture()
+ .hostCount(20)
.capacity(requiredCapacity)
.zone(new Zone(Environment.dev, RegionName.from("us-east")))
.build();
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 917e49bc561..254b03194ad 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
@@ -259,7 +259,10 @@ class AutoscalingTester {
&& resources.diskGb() <= flavorResources.diskGb())
flavorResources = flavorResources.withDiskGb(resources.diskGb());
- return flavorResources.justNumbers().equals(resources.justNumbers());
+ if (flavorResources.bandwidthGbps() >= resources.bandwidthGbps())
+ flavorResources = flavorResources.withBandwidthGbps(resources.bandwidthGbps());
+
+ return flavorResources.compatibleWith(resources);
}
}
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 d3aa5a849a1..fba060b5f07 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
@@ -40,11 +40,11 @@ public class Fixture {
final Capacity capacity;
final Loader loader;
- public Fixture(Fixture.Builder builder, Optional<ClusterResources> initialResources) {
+ public Fixture(Fixture.Builder builder, Optional<ClusterResources> initialResources, int hostCount) {
applicationId = builder.application;
clusterSpec = builder.cluster;
capacity = builder.capacity;
- tester = new AutoscalingTester(builder.zone, builder.resourceCalculator, builder.hostFlavors, 20);
+ tester = new AutoscalingTester(builder.zone, builder.resourceCalculator, builder.hostFlavors, hostCount);
var deployCapacity = initialResources.isPresent() ? Capacity.from(initialResources.get()) : capacity;
tester.deploy(builder.application, builder.cluster, deployCapacity);
this.loader = new Loader(this);
@@ -132,6 +132,7 @@ public class Fixture {
new ClusterResources(20, 1,
new NodeResources(100, 1000, 1000, 1, NodeResources.DiskSpeed.any)));
HostResourcesCalculator resourceCalculator = new AutoscalingTester.MockHostResourcesCalculator(zone, 0);
+ int hostCount = 0;
public Fixture.Builder zone(Zone zone) {
this.zone = zone;
@@ -202,8 +203,13 @@ public class Fixture {
return this;
}
+ public Fixture.Builder hostCount(int hostCount) { // TODO: Remove all usage of this
+ this.hostCount = hostCount;
+ return this;
+ }
+
public Fixture build() {
- return new Fixture(this, initialResources);
+ return new Fixture(this, initialResources, hostCount);
}
}