Search in sources :

Example 21 with Zone

use of com.yahoo.config.provision.Zone 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)));
    }
}
Also used : Capacity(com.yahoo.config.provision.Capacity) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) ClusterMembership(com.yahoo.config.provision.ClusterMembership) ClusterSpec(com.yahoo.config.provision.ClusterSpec) Node(com.yahoo.vespa.hosted.provision.Node) ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) Function(java.util.function.Function) RegionName(com.yahoo.config.provision.RegionName) NameResolver(com.yahoo.vespa.hosted.provision.persistence.NameResolver) TenantName(com.yahoo.config.provision.TenantName) Curator(com.yahoo.vespa.curator.Curator) HashSet(java.util.HashSet) ReservationExpirer(com.yahoo.vespa.hosted.provision.maintenance.ReservationExpirer) History(com.yahoo.vespa.hosted.provision.node.History) NestedTransaction(com.yahoo.transaction.NestedTransaction) Duration(java.time.Duration) NodeList(com.yahoo.vespa.hosted.provision.NodeList) Assert.fail(org.junit.Assert.fail) NodeFlavors(com.yahoo.config.provision.NodeFlavors) Iterator(java.util.Iterator) Environment(com.yahoo.config.provision.Environment) Predicate(java.util.function.Predicate) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) HostSpec(com.yahoo.config.provision.HostSpec) FlavorsConfig(com.yahoo.config.provisioning.FlavorsConfig) MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) HostFilter(com.yahoo.config.provision.HostFilter) List(java.util.List) Agent(com.yahoo.vespa.hosted.provision.node.Agent) Ignore(org.junit.Ignore) Flavor(com.yahoo.config.provision.Flavor) Assert.assertFalse(org.junit.Assert.assertFalse) Zone(com.yahoo.config.provision.Zone) Optional(java.util.Optional) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Zone(com.yahoo.config.provision.Zone) NodeList(com.yahoo.vespa.hosted.provision.NodeList) List(java.util.List) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 22 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_constant_application_size.

@Test
public void application_deployment_constant_application_size() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    ApplicationId application2 = tester.makeApplicationId();
    tester.makeReadyNodes(21, "default");
    // deploy
    SystemState state1 = prepare(application1, 2, 2, 3, 3, "default", tester);
    tester.activate(application1, state1.allHosts);
    // redeploy
    SystemState state2 = prepare(application1, 2, 2, 3, 3, "default", tester);
    state2.assertEquals(state1);
    tester.activate(application1, state2.allHosts);
    // deploy another application
    SystemState state1App2 = prepare(application2, 2, 2, 3, 3, "default", tester);
    assertFalse("Hosts to different apps are disjunct", state1App2.allHosts.removeAll(state1.allHosts));
    tester.activate(application2, state1App2.allHosts);
    // prepare twice
    SystemState state3 = prepare(application1, 2, 2, 3, 3, "default", tester);
    SystemState state4 = prepare(application1, 2, 2, 3, 3, "default", tester);
    state3.assertEquals(state2);
    state4.assertEquals(state3);
    tester.activate(application1, state4.allHosts);
    // remove nodes before deploying
    SystemState state5 = prepare(application1, 2, 2, 3, 3, "default", tester);
    HostSpec removed = tester.removeOne(state5.allHosts);
    tester.activate(application1, state5.allHosts);
    assertEquals(removed.hostname(), tester.nodeRepository().getNodes(application1, Node.State.inactive).get(0).hostname());
    // remove some of the clusters
    SystemState state6 = prepare(application1, 0, 2, 0, 3, "default", tester);
    tester.activate(application1, state6.allHosts);
    assertEquals(5, tester.getNodes(application1, Node.State.active).size());
    assertEquals(5, tester.getNodes(application1, Node.State.inactive).size());
    // delete app
    NestedTransaction removeTransaction = new NestedTransaction();
    tester.provisioner().remove(removeTransaction, application1);
    removeTransaction.commit();
    assertEquals(tester.toHostNames(state1.allHosts), tester.toHostNames(tester.nodeRepository().getNodes(application1, Node.State.inactive)));
    assertEquals(0, tester.getNodes(application1, Node.State.active).size());
    // other application is unaffected
    assertEquals(state1App2.hostNames(), tester.toHostNames(tester.nodeRepository().getNodes(application2, Node.State.active)));
    // fail a node from app2 and make sure it does not get inactive nodes from first
    HostSpec failed = tester.removeOne(state1App2.allHosts);
    tester.fail(failed);
    assertEquals(9, tester.getNodes(application2, Node.State.active).size());
    SystemState state2App2 = prepare(application2, 2, 2, 3, 3, "default", tester);
    assertFalse("Hosts to different apps are disjunct", state2App2.allHosts.removeAll(state1.allHosts));
    assertEquals("A new node was reserved to replace the failed one", 10, state2App2.allHosts.size());
    assertFalse("The new host is not the failed one", state2App2.allHosts.contains(failed));
    tester.activate(application2, state2App2.allHosts);
    // deploy first app again
    SystemState state7 = prepare(application1, 2, 2, 3, 3, "default", tester);
    state7.assertEquals(state1);
    tester.activate(application1, state7.allHosts);
    assertEquals(0, tester.getNodes(application1, Node.State.inactive).size());
    // restart
    HostFilter allFilter = HostFilter.all();
    HostFilter hostFilter = HostFilter.hostname(state6.allHosts.iterator().next().hostname());
    HostFilter clusterTypeFilter = HostFilter.clusterType(ClusterSpec.Type.container);
    HostFilter clusterIdFilter = HostFilter.clusterId(ClusterSpec.Id.from("container1"));
    tester.provisioner().restart(application1, allFilter);
    tester.provisioner().restart(application1, hostFilter);
    tester.provisioner().restart(application1, clusterTypeFilter);
    tester.provisioner().restart(application1, clusterIdFilter);
    tester.assertRestartCount(application1, allFilter, hostFilter, clusterTypeFilter, clusterIdFilter);
}
Also used : Zone(com.yahoo.config.provision.Zone) NestedTransaction(com.yahoo.transaction.NestedTransaction) HostFilter(com.yahoo.config.provision.HostFilter) ApplicationId(com.yahoo.config.provision.ApplicationId) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Example 23 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method application_deployment_with_inplace_downsize.

// TODO: Enable when this feature is re-enabled
@Ignore
@Test
public void application_deployment_with_inplace_downsize() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    ApplicationId application1 = tester.makeApplicationId();
    tester.makeReadyNodes(14, "dockerLarge");
    // deploy
    SystemState state1 = prepare(application1, 2, 2, 4, 4, "dockerLarge", tester);
    tester.activate(application1, state1.allHosts);
    // redeploy with smaller docker flavor - causes in-place flavor change
    SystemState state2 = prepare(application1, 2, 2, 4, 4, "dockerSmall", tester);
    tester.activate(application1, state2.allHosts);
    assertEquals(12, tester.getNodes(application1, Node.State.active).asList().size());
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertEquals("Node changed flavor in place", "dockerSmall", node.flavor().name());
    assertEquals("No nodes are retired", 0, tester.getNodes(application1, Node.State.active).retired().size());
}
Also used : Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) ApplicationId(com.yahoo.config.provision.ApplicationId) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class ProvisioningTest method out_of_capacity.

@Test
public void out_of_capacity() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    // need 2+2+3+3=10
    tester.makeReadyNodes(9, "default");
    ApplicationId application = tester.makeApplicationId();
    try {
        prepare(application, 2, 2, 3, 3, "default", tester);
        fail("Expected exception");
    } catch (OutOfCapacityException e) {
        assertTrue(e.getMessage().startsWith("Could not satisfy request"));
    }
}
Also used : Zone(com.yahoo.config.provision.Zone) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 25 with Zone

use of com.yahoo.config.provision.Zone in project vespa by vespa-engine.

the class DockerProvisioningTest method docker_application_deployment_with_exclusive_app_causing_allocation_failure.

/**
 * Non-exclusive app first, then an exclusive: Should give the same result as above
 */
@Test
public void docker_application_deployment_with_exclusive_app_causing_allocation_failure() {
    ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")));
    for (int i = 1; i <= 4; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host1");
    for (int i = 5; i <= 8; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host2");
    for (int i = 9; i <= 12; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host3");
    for (int i = 13; i <= 16; i++) tester.makeReadyVirtualNode(i, dockerFlavor, "host4");
    ApplicationId application1 = tester.makeApplicationId();
    prepareAndActivate(application1, 2, true, tester);
    assertEquals(setOf("host1", "host2"), hostsOf(tester.getNodes(application1, Node.State.active)));
    try {
        ApplicationId application2 = tester.makeApplicationId();
        prepareAndActivate(application2, 3, false, tester);
        fail("Expected allocation failure");
    } catch (Exception e) {
        assertEquals("No room for 3 nodes as 2 of 4 hosts are exclusive", "Could not satisfy request for 3 nodes of flavor 'dockerSmall' for container cluster 'myContainer' group 0 6.39: Not enough nodes available due to host exclusivity constraints.", e.getMessage());
    }
    // Adding 3 nodes of another application for the same tenant works
    ApplicationId application3 = ApplicationId.from(application1.tenant(), ApplicationName.from("app3"), InstanceName.from("default"));
    prepareAndActivate(application3, 2, true, tester);
}
Also used : Zone(com.yahoo.config.provision.Zone) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

Zone (com.yahoo.config.provision.Zone)71 Test (org.junit.Test)64 ApplicationId (com.yahoo.config.provision.ApplicationId)51 Node (com.yahoo.vespa.hosted.provision.Node)17 Flavor (com.yahoo.config.provision.Flavor)15 ClusterSpec (com.yahoo.config.provision.ClusterSpec)13 HostSpec (com.yahoo.config.provision.HostSpec)12 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)10 HashSet (java.util.HashSet)8 DeployState (com.yahoo.config.model.deploy.DeployState)6 NestedTransaction (com.yahoo.transaction.NestedTransaction)6 Curator (com.yahoo.vespa.curator.Curator)6 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)6 NodeList (com.yahoo.vespa.hosted.provision.NodeList)6 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)6 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)5 Version (com.yahoo.component.Version)5 RegionName (com.yahoo.config.provision.RegionName)5 TenantName (com.yahoo.config.provision.TenantName)5 FlavorsConfig (com.yahoo.config.provisioning.FlavorsConfig)5