aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java')
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java189
1 files changed, 4 insertions, 185 deletions
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java
index 3be56131a05..223a8bc83b0 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicDockerProvisioningTest.java
@@ -45,57 +45,10 @@ import static org.junit.Assert.fail;
public class DynamicDockerProvisioningTest {
/**
- * Test relocation of nodes that violate headroom.
- * <p>
- * Setup 4 docker hosts and allocate one container on each (from two different applications)
- * No spares - only headroom (4xd-2)
- * <p>
- * One application is now violating headroom and need relocation
- * <p>
- * Initial allocation of app 1 and 2 --> final allocation (headroom marked as H):
- * <p>
- * | H | H | H | H | | | | | |
- * | H | H | H1a | H1b | --> | | | | |
- * | | | 2a | 2b | | 1a | 1b | 2a | 2b |
- */
- @Test
- public void relocate_nodes_from_headroom_hosts() {
- ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.perf, RegionName.from("us-east")), flavorsConfig(true));
- tester.makeReadyNodes(4, "host-small", NodeType.host, 32);
- deployZoneApp(tester);
- List<Node> dockerHosts = tester.nodeRepository().getNodes(NodeType.host, Node.State.active);
- Flavor flavor = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-1");
-
- // Application 1
- ApplicationId application1 = makeApplicationId("t1", "a1");
- ClusterSpec clusterSpec1 = clusterSpec("myContent.t1.a1");
- addAndAssignNode(application1, "1a", dockerHosts.get(2).hostname(), clusterSpec1, flavor, 0, tester);
- addAndAssignNode(application1, "1b", dockerHosts.get(3).hostname(), clusterSpec1, flavor, 1, tester);
-
- // Application 2
- ApplicationId application2 = makeApplicationId("t2", "a2");
- ClusterSpec clusterSpec2 = clusterSpec("myContent.t2.a2");
- addAndAssignNode(application2, "2a", dockerHosts.get(2).hostname(), clusterSpec2, flavor, 0, tester);
- addAndAssignNode(application2, "2b", dockerHosts.get(3).hostname(), clusterSpec2, flavor, 1, tester);
-
- // Redeploy one of the applications
- deployapp(application1, clusterSpec1, flavor, tester, 2);
-
- // Assert that the nodes are spread across all hosts (to allow headroom)
- Set<String> hostsWithChildren = new HashSet<>();
- for (Node node : tester.nodeRepository().getNodes(NodeType.tenant, Node.State.active)) {
- if (!isInactiveOrRetired(node)) {
- hostsWithChildren.add(node.parentHostname().get());
- }
- }
- Assert.assertEquals(4, hostsWithChildren.size());
- }
-
- /**
* Test relocation of nodes from spare hosts.
* <p>
* Setup 4 docker hosts and allocate one container on each (from two different applications)
- * No headroom defined - only getSpareCapacityProd() spares.
+ * getSpareCapacityProd() spares.
* <p>
* Check that it relocates containers away from the getSpareCapacityProd() spares
* <p>
@@ -141,132 +94,6 @@ public class DynamicDockerProvisioningTest {
}
/**
- * Test that new docker nodes that will result in headroom violations are
- * correctly marked as this.
- * <p>
- * When redeploying app1 - should not do anything (as moving app1 to host 0 and 1 would violate headroom).
- * Then redeploy app 2 - should cause a relocation.
- * <p>
- * | H | H | H2a | H2b | | H | H | H | H |
- * | H | H | H1a | H1b | --> | H | H | H1a | H1b |
- * | | | 1a | 1b | | 2a | 2b | 1a | 1b |
- */
- @Test
- public void new_docker_nodes_are_marked_as_headroom_violations() {
- ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.perf, RegionName.from("us-east")), flavorsConfig(true));
- tester.makeReadyNodes(4, "host-small", NodeType.host, 32);
- deployZoneApp(tester);
- List<Node> dockerHosts = tester.nodeRepository().getNodes(NodeType.host, Node.State.active);
- Flavor flavorD2 = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-2");
- Flavor flavorD1 = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-1");
-
- // Application 1
- ApplicationId application1 = makeApplicationId("t1", "1");
- ClusterSpec clusterSpec1 = clusterSpec("myContent.t1.a1");
- String hostParent2 = dockerHosts.get(2).hostname();
- String hostParent3 = dockerHosts.get(3).hostname();
- addAndAssignNode(application1, "1a", hostParent2, clusterSpec1, flavorD2, 0, tester);
- addAndAssignNode(application1, "1b", hostParent3, clusterSpec1, flavorD2, 1, tester);
-
- // Application 2
- ApplicationId application2 = makeApplicationId("t2", "2");
- ClusterSpec clusterSpec2 = clusterSpec("myContent.t2.a2");
- addAndAssignNode(application2, "2a", hostParent2, clusterSpec2, flavorD1, 0, tester);
- addAndAssignNode(application2, "2b", hostParent3, clusterSpec2, flavorD1, 1, tester);
-
- // Assert allocation placement - prior to re-deployment
- assertApplicationHosts(tester.nodeRepository().getNodes(application1), hostParent2, hostParent3);
- assertApplicationHosts(tester.nodeRepository().getNodes(application2), hostParent2, hostParent3);
-
- // Redeploy application 1
- deployapp(application1, clusterSpec1, flavorD2, tester, 2);
-
- // Re-assert allocation placement
- assertApplicationHosts(tester.nodeRepository().getNodes(application1), hostParent2, hostParent3);
- assertApplicationHosts(tester.nodeRepository().getNodes(application2), hostParent2, hostParent3);
-
- // Redeploy application 2
- deployapp(application2, clusterSpec2, flavorD1, tester, 2);
-
- // Now app2 should have re-located
- assertApplicationHosts(tester.nodeRepository().getNodes(application1), hostParent2, hostParent3);
- assertApplicationHosts(tester.nodeRepository().getNodes(application2), dockerHosts.get(0).hostname(), dockerHosts.get(1).hostname());
- }
-
- /**
- * Test that we only relocate the smallest nodes from a host to free up headroom.
- * <p>
- * The reason we want to do this is that it is an cheap approximation for the optimal solution as we
- * pick headroom to be on the hosts were we are closest to fulfill the headroom requirement.
- *
- * Both applications could be moved here to free up headroom - but we want app2 (which is smallest) to be moved.
- * <p>
- * | H | H | H2a | H2b | | H | H | H | H |
- * | H | H | H1a | H1b | --> | H | H | H | H |
- * | | | 1a | 1b | | 2a | 2b | 1a | 1b |
- * | | | | | | | | 1a | 1b |
- */
- @Test
- public void only_preferred_container_is_moved_from_hosts_with_headroom_violations() {
- ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.perf, RegionName.from("us-east")), flavorsConfig(true));
- tester.makeReadyNodes(4, "host-medium", NodeType.host, 32);
- deployZoneApp(tester);
- List<Node> dockerHosts = tester.nodeRepository().getNodes(NodeType.host, Node.State.active);
- Flavor flavorD2 = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-2");
- Flavor flavorD1 = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-1");
-
- // Application 1
- ApplicationId application1 = makeApplicationId("t1", "1");
- ClusterSpec clusterSpec1 = clusterSpec("myContent.t1.a1");
- String hostParent2 = dockerHosts.get(2).hostname();
- String hostParent3 = dockerHosts.get(3).hostname();
- addAndAssignNode(application1, "1a", hostParent2, clusterSpec1, flavorD2, 0, tester);
- addAndAssignNode(application1, "1b", hostParent3, clusterSpec1, flavorD2, 1, tester);
-
- // Application 2
- ApplicationId application2 = makeApplicationId("t2", "2");
- ClusterSpec clusterSpec2 = clusterSpec("myContent.t2.a2");
- addAndAssignNode(application2, "2a", hostParent2, clusterSpec2, flavorD1, 0, tester);
- addAndAssignNode(application2, "2b", hostParent3, clusterSpec2, flavorD1, 1, tester);
-
- // Assert allocation placement - prior to re-deployment
- assertApplicationHosts(tester.nodeRepository().getNodes(application1), hostParent2, hostParent3);
- assertApplicationHosts(tester.nodeRepository().getNodes(application2), hostParent2, hostParent3);
-
- // Redeploy application 1
- deployapp(application1, clusterSpec1, flavorD2, tester, 2);
-
- // Re-assert allocation placement
- assertApplicationHosts(tester.nodeRepository().getNodes(application1), hostParent2, hostParent3);
- assertApplicationHosts(tester.nodeRepository().getNodes(application2), hostParent2, hostParent3);
-
- // Redeploy application 2
- deployapp(application2, clusterSpec2, flavorD1, tester, 2);
-
- // Now app2 should have re-located
- assertApplicationHosts(tester.nodeRepository().getNodes(application1), hostParent2, hostParent3);
- assertApplicationHosts(tester.nodeRepository().getNodes(application2), dockerHosts.get(0).hostname(), dockerHosts.get(1).hostname());
- }
-
- private void assertApplicationHosts(List<Node> nodes, String... parents) {
- for (Node node : nodes) {
- // Ignore retired and non-active nodes
- if (!node.state().equals(Node.State.active) ||
- node.allocation().get().membership().retired()) {
- continue;
- }
- boolean found = false;
- for (String parent : parents) {
- if (node.parentHostname().get().equals(parent)) {
- found = true;
- break;
- }
- }
- Assert.assertTrue(found);
- }
- }
-
- /**
* Test an allocation workflow:
* <p>
* 5 Hosts of capacity 3 (2 spares)
@@ -323,8 +150,7 @@ public class DynamicDockerProvisioningTest {
/**
* Test redeployment of nodes that violates spare headroom - but without alternatives
* <p>
- * Setup 2 docker hosts and allocate one app with a container on each
- * No headroom defined - only 2 spares.
+ * Setup 2 docker hosts and allocate one app with a container on each. 2 spares
* <p>
* Initial allocation of app 1 --> final allocation:
* <p>
@@ -333,7 +159,7 @@ public class DynamicDockerProvisioningTest {
* | 1a | 1b | | 1a | 1b |
*/
@Test
- public void do_not_relocate_nodes_from_spare_if_no_where_to_reloacte_them() {
+ public void do_not_relocate_nodes_from_spare_if_no_where_to_relocate_them() {
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), flavorsConfig());
tester.makeReadyNodes(2, "host-small", NodeType.host, 32);
deployZoneApp(tester);
@@ -475,16 +301,13 @@ public class DynamicDockerProvisioningTest {
.collect(Collectors.toList());
}
- private FlavorsConfig flavorsConfig(boolean includeHeadroom) {
+ private FlavorsConfig flavorsConfig() {
FlavorConfigBuilder b = new FlavorConfigBuilder();
b.addFlavor("host-large", 6., 6., 6, Flavor.Type.BARE_METAL);
b.addFlavor("host-small", 3., 3., 3, Flavor.Type.BARE_METAL);
b.addFlavor("host-medium", 4., 4., 4, Flavor.Type.BARE_METAL);
b.addFlavor("d-1", 1, 1., 1, Flavor.Type.DOCKER_CONTAINER);
b.addFlavor("d-2", 2, 2., 2, Flavor.Type.DOCKER_CONTAINER);
- if (includeHeadroom) {
- b.addFlavor("d-2-4", 2, 2., 2, Flavor.Type.DOCKER_CONTAINER, 4);
- }
b.addFlavor("d-3", 3, 3., 3, Flavor.Type.DOCKER_CONTAINER);
b.addFlavor("d-3-disk", 3, 3., 5, Flavor.Type.DOCKER_CONTAINER);
b.addFlavor("d-3-mem", 3, 5., 3, Flavor.Type.DOCKER_CONTAINER);
@@ -492,10 +315,6 @@ public class DynamicDockerProvisioningTest {
return b.build();
}
- private FlavorsConfig flavorsConfig() {
- return flavorsConfig(false);
- }
-
private void deployZoneApp(ProvisioningTester tester) {
ApplicationId applicationId = tester.makeApplicationId();
List<HostSpec> list = tester.prepare(applicationId,