use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class DynamicDockerProvisioningTest method spare_capacity_used_only_when_replacement.
@Test
public void spare_capacity_used_only_when_replacement() {
// Use spare capacity only when replacement (i.e one node is failed)
// Test should allocate as much capacity as possible, verify that it is not possible to allocate one more unit
// Verify that there is still capacity (available spare)
// Fail one node and redeploy, Verify that one less node is empty.
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), flavorsConfig());
// Only run test if there _is_ spare capacity
if (tester.provisioner().getSpareCapacityProd() == 0) {
return;
}
// Setup test
ApplicationId application1 = tester.makeApplicationId();
tester.makeReadyNodes(5, "host-small", NodeType.host, 32);
deployZoneApp(tester);
Flavor flavor = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-3");
// Deploy initial state (can max deploy 3 nodes due to redundancy requirements)
List<HostSpec> hosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false), 3, 1, flavor.canonicalName());
tester.activate(application1, ImmutableSet.copyOf(hosts));
DockerHostCapacity capacity = new DockerHostCapacity(tester.nodeRepository().getNodes(Node.State.values()));
assertThat(capacity.freeCapacityInFlavorEquivalence(flavor), greaterThan(0));
List<Node> initialSpareCapacity = findSpareCapacity(tester);
assertThat(initialSpareCapacity.size(), is(2));
try {
hosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false), 4, 1, flavor.canonicalName());
fail("Was able to deploy with 4 nodes, should not be able to use spare capacity");
} catch (OutOfCapacityException e) {
}
tester.fail(hosts.get(0));
hosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false), 3, 1, flavor.canonicalName());
tester.activate(application1, ImmutableSet.copyOf(hosts));
List<Node> finalSpareCapacity = findSpareCapacity(tester);
assertThat(finalSpareCapacity.size(), is(1));
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class DynamicDockerProvisioningTest method non_prod_do_not_have_spares.
@Test
public void non_prod_do_not_have_spares() {
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.perf, RegionName.from("us-east")), flavorsConfig());
tester.makeReadyNodes(3, "host-small", NodeType.host, 32);
deployZoneApp(tester);
Flavor flavor = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-3");
ApplicationId application1 = tester.makeApplicationId();
List<HostSpec> hosts = tester.prepare(application1, ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false), 3, 1, flavor.canonicalName());
tester.activate(application1, ImmutableSet.copyOf(hosts));
List<Node> initialSpareCapacity = findSpareCapacity(tester);
assertThat(initialSpareCapacity.size(), is(0));
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class NodePrioritizerTest method relocated_nodes_are_preferred.
@Test
public void relocated_nodes_are_preferred() {
List<Node> nodes = new ArrayList<>();
Node parent = createParent("parent");
Node b = createNode(parent, "b", "d2");
nodes.add(b);
// Only one node - should be obvious what to prefer
Assert.assertTrue(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, b, parent));
// Two equal nodes - choose lexically
Node a = createNode(parent, "a", "d2");
nodes.add(a);
Assert.assertTrue(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, a, parent));
Assert.assertFalse(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, b, parent));
// Smallest node should be preferred
Node c = createNode(parent, "c", "d1");
nodes.add(c);
Assert.assertTrue(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, c, parent));
// Unallocated over allocated
ClusterSpec spec = ClusterSpec.from(ClusterSpec.Type.content, ClusterSpec.Id.from("mycluster"), ClusterSpec.Group.from(0), Version.fromString("6.142.22"), false);
c = c.allocate(ApplicationId.defaultId(), ClusterMembership.from(spec, 0), Instant.now());
nodes.remove(c);
nodes.add(c);
Node d = createNode(parent, "d", "d1");
nodes.add(d);
Assert.assertTrue(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, d, parent));
Assert.assertFalse(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, c, parent));
// Container over content
ClusterSpec spec2 = ClusterSpec.from(ClusterSpec.Type.container, ClusterSpec.Id.from("mycluster"), ClusterSpec.Group.from(0), Version.fromString("6.142.22"), false);
d = d.allocate(ApplicationId.defaultId(), ClusterMembership.from(spec2, 0), Instant.now());
nodes.remove(d);
nodes.add(d);
Assert.assertFalse(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, c, parent));
Assert.assertTrue(NodePrioritizer.isPreferredNodeToBeReloacted(nodes, d, parent));
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class ProvisioningTest method application_deployment_is_not_given_unallocated_nodes_having_retired_flavor.
@Test
public void application_deployment_is_not_given_unallocated_nodes_having_retired_flavor() {
String flavorToRetire = "default";
String replacementFlavor = "new-default";
FlavorConfigBuilder b = new FlavorConfigBuilder();
b.addFlavor(flavorToRetire, 1., 1., 10, Flavor.Type.BARE_METAL).cost(2).retired(true);
FlavorsConfig.Flavor.Builder newDefault = b.addFlavor(replacementFlavor, 2., 2., 20, Flavor.Type.BARE_METAL).cost(2);
b.addReplaces(flavorToRetire, newDefault);
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), b.build());
ApplicationId application = tester.makeApplicationId();
// Add nodes
tester.makeReadyNodes(4, flavorToRetire);
tester.makeReadyNodes(4, replacementFlavor);
SystemState state = prepare(application, 2, 0, 2, 0, flavorToRetire, tester);
tester.activate(application, state.allHosts);
List<Node> nodes = tester.getNodes(application).asList();
assertTrue("Allocated nodes have flavor " + replacementFlavor, nodes.stream().allMatch(n -> n.flavor().name().equals(replacementFlavor)));
}
use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.
the class ProvisioningTest method application_deployment_retires_nodes_that_want_to_retire.
@Test
public void application_deployment_retires_nodes_that_want_to_retire() {
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
ApplicationId application = tester.makeApplicationId();
tester.makeReadyNodes(10, "default");
// Deploy application
{
SystemState state = prepare(application, 2, 0, 2, 0, "default", tester);
tester.activate(application, state.allHosts);
assertEquals(4, tester.getNodes(application, Node.State.active).size());
}
// Retire some nodes and redeploy
{
List<Node> nodesToRetire = tester.getNodes(application, Node.State.active).asList().subList(0, 2);
nodesToRetire.forEach(node -> tester.patchNode(node.with(node.status().withWantToRetire(true))));
SystemState state = prepare(application, 2, 0, 2, 0, "default", tester);
tester.activate(application, state.allHosts);
List<Node> retiredNodes = tester.getNodes(application).retired().asList();
assertEquals(2, retiredNodes.size());
assertTrue("Nodes are retired by system", retiredNodes.stream().allMatch(retiredBy(Agent.system)));
}
}
Aggregations