Search in sources :

Example 46 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class DockerProvisioningTest method docker_application_deployment_change_to_exclusive_and_back.

/**
 * Test making an application exclusive
 */
@Test
public void docker_application_deployment_change_to_exclusive_and_back() {
    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, false, tester);
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertFalse(node.allocation().get().membership().cluster().isExclusive());
    prepareAndActivate(application1, 2, true, tester);
    assertEquals(setOf("host1", "host2"), hostsOf(tester.getNodes(application1, Node.State.active)));
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertTrue(node.allocation().get().membership().cluster().isExclusive());
    prepareAndActivate(application1, 2, false, tester);
    assertEquals(setOf("host1", "host2"), hostsOf(tester.getNodes(application1, Node.State.active)));
    for (Node node : tester.getNodes(application1, Node.State.active).asList()) assertFalse(node.allocation().get().membership().cluster().isExclusive());
}
Also used : Zone(com.yahoo.config.provision.Zone) Node(com.yahoo.vespa.hosted.provision.Node) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 47 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class NodeTypeProvisioningTest method retire_proxy.

@Test
public void retire_proxy() {
    MockDeployer deployer = new MockDeployer(tester.provisioner(), Collections.singletonMap(application, new MockDeployer.ApplicationContext(application, clusterSpec, capacity, 1)));
    RetiredExpirer retiredExpirer = new RetiredExpirer(tester.nodeRepository(), tester.orchestrator(), deployer, tester.clock(), Duration.ofDays(30), Duration.ofMinutes(10), new JobControl(tester.nodeRepository().database()));
    {
        // Deploy
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals("Reserved all proxies", 11, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals("Activated all proxies", 11, nodes.size());
    }
    Node nodeToRetire = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active).get(5);
    {
        // Pick out a node and retire it
        tester.nodeRepository().write(nodeToRetire.with(nodeToRetire.status().withWantToRetire(true)));
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals(11, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals(11, nodes.size());
        // Verify that wantToRetire has been propagated
        assertTrue(tester.nodeRepository().getNode(nodeToRetire.hostname()).flatMap(Node::allocation).map(allocation -> allocation.membership().retired()).orElseThrow(RuntimeException::new));
    }
    {
        // Redeploying while the node is still retiring has no effect
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals(11, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals(11, nodes.size());
        // Verify that the node is still marked as retired
        assertTrue(tester.nodeRepository().getNode(nodeToRetire.hostname()).flatMap(Node::allocation).map(allocation -> allocation.membership().retired()).orElseThrow(RuntimeException::new));
    }
    {
        tester.advanceTime(Duration.ofMinutes(11));
        retiredExpirer.run();
        List<HostSpec> hosts = deployProxies(application, tester);
        assertEquals(10, hosts.size());
        tester.activate(application, new HashSet<>(hosts));
        List<Node> nodes = tester.nodeRepository().getNodes(NodeType.proxy, Node.State.active);
        assertEquals(10, nodes.size());
        // Verify that the node is now inactive
        assertEquals(Node.State.inactive, tester.nodeRepository().getNode(nodeToRetire.hostname()).orElseThrow(RuntimeException::new).state());
    }
}
Also used : Capacity(com.yahoo.config.provision.Capacity) Version(com.yahoo.component.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) Environment(com.yahoo.config.provision.Environment) NodeType(com.yahoo.config.provision.NodeType) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) ClusterSpec(com.yahoo.config.provision.ClusterSpec) HostSpec(com.yahoo.config.provision.HostSpec) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Node(com.yahoo.vespa.hosted.provision.Node) Collectors(java.util.stream.Collectors) RegionName(com.yahoo.config.provision.RegionName) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) HashSet(java.util.HashSet) RetiredExpirer(com.yahoo.vespa.hosted.provision.maintenance.RetiredExpirer) List(java.util.List) Agent(com.yahoo.vespa.hosted.provision.node.Agent) Duration(java.time.Duration) Zone(com.yahoo.config.provision.Zone) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) Node(com.yahoo.vespa.hosted.provision.Node) JobControl(com.yahoo.vespa.hosted.provision.maintenance.JobControl) List(java.util.List) RetiredExpirer(com.yahoo.vespa.hosted.provision.maintenance.RetiredExpirer) MockDeployer(com.yahoo.vespa.hosted.provision.testutils.MockDeployer) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 48 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class ProvisioningTester method assertRestartCount.

/**
 * Asserts that each active node in this application has a restart count equaling the
 * number of matches to the given filters
 */
void assertRestartCount(ApplicationId application, HostFilter... filters) {
    for (Node node : nodeRepository.getNodes(application, Node.State.active)) {
        int expectedRestarts = 0;
        for (HostFilter filter : filters) if (NodeHostFilter.from(filter).matches(node))
            expectedRestarts++;
        assertEquals(expectedRestarts, node.allocation().get().restartGeneration().wanted());
    }
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) NodeHostFilter(com.yahoo.vespa.hosted.provision.node.filter.NodeHostFilter) HostFilter(com.yahoo.config.provision.HostFilter)

Example 49 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class VirtualNodeProvisioningTest method will_retire_clashing_active.

@Test
public void will_retire_clashing_active() {
    tester.makeReadyVirtualNodes(1, flavor, "parentHost1");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost2");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost3");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost4");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost5");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost6");
    int containerNodeCount = 2;
    int contentNodeCount = 2;
    int groups = 1;
    List<HostSpec> containerHosts = prepare(containerClusterSpec, containerNodeCount, groups);
    List<HostSpec> contentHosts = prepare(contentClusterSpec, contentNodeCount, groups);
    activate(containerHosts, contentHosts);
    List<Node> nodes = getNodes(applicationId);
    assertEquals(4, nodes.size());
    assertDistinctParentHosts(nodes, ClusterSpec.Type.container, containerNodeCount);
    assertDistinctParentHosts(nodes, ClusterSpec.Type.content, contentNodeCount);
    for (Node n : nodes) {
        tester.patchNode(n.withParentHostname("clashing"));
    }
    containerHosts = prepare(containerClusterSpec, containerNodeCount, groups);
    contentHosts = prepare(contentClusterSpec, contentNodeCount, groups);
    activate(containerHosts, contentHosts);
    nodes = getNodes(applicationId);
    assertEquals(6, nodes.size());
    assertEquals(2, nodes.stream().filter(n -> n.allocation().get().membership().retired()).count());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Example 50 with Node

use of com.yahoo.vespa.hosted.provision.Node in project vespa by vespa-engine.

the class VirtualNodeProvisioningTest method indistinct_distribution_with_known_ready_nodes.

@Test
public void indistinct_distribution_with_known_ready_nodes() {
    tester.makeReadyVirtualNodes(3, flavor, Optional.empty());
    final int contentNodeCount = 3;
    final int groups = 1;
    final List<HostSpec> contentHosts = prepare(contentClusterSpec, contentNodeCount, groups);
    activate(contentHosts);
    List<Node> nodes = getNodes(applicationId);
    assertEquals(3, nodes.size());
    // Set indistinct parents
    tester.patchNode(nodes.get(0).withParentHostname("parentHost1"));
    tester.patchNode(nodes.get(1).withParentHostname("parentHost1"));
    tester.patchNode(nodes.get(2).withParentHostname("parentHost2"));
    nodes = getNodes(applicationId);
    assertEquals(3, nodes.stream().filter(n -> n.parentHostname().isPresent()).count());
    tester.makeReadyVirtualNodes(1, flavor, "parentHost1");
    tester.makeReadyVirtualNodes(2, flavor, "parentHost2");
    OutOfCapacityException expectedException = null;
    try {
        prepare(contentClusterSpec, contentNodeCount, groups);
    } catch (OutOfCapacityException e) {
        expectedException = e;
    }
    assertNotNull(expectedException);
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Aggregations

Node (com.yahoo.vespa.hosted.provision.Node)121 Test (org.junit.Test)67 ApplicationId (com.yahoo.config.provision.ApplicationId)40 ClusterSpec (com.yahoo.config.provision.ClusterSpec)33 List (java.util.List)26 ArrayList (java.util.ArrayList)23 Zone (com.yahoo.config.provision.Zone)22 Flavor (com.yahoo.config.provision.Flavor)21 HashSet (java.util.HashSet)19 Collectors (java.util.stream.Collectors)19 Optional (java.util.Optional)18 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)16 Duration (java.time.Duration)16 HostSpec (com.yahoo.config.provision.HostSpec)15 NodeType (com.yahoo.config.provision.NodeType)15 Agent (com.yahoo.vespa.hosted.provision.node.Agent)13 Map (java.util.Map)13 HashMap (java.util.HashMap)12 Collections (java.util.Collections)11 Set (java.util.Set)11