Search in sources :

Example 16 with HostSpec

use of com.yahoo.config.provision.HostSpec 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 17 with HostSpec

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

the class ProvisioningTester method assertMembersOf.

void assertMembersOf(ClusterSpec requestedCluster, Collection<HostSpec> hosts) {
    Set<Integer> indices = new HashSet<>();
    for (HostSpec host : hosts) {
        ClusterSpec nodeCluster = host.membership().get().cluster();
        assertTrue(requestedCluster.equalsIgnoringGroupAndVespaVersion(nodeCluster));
        if (requestedCluster.group().isPresent())
            assertEquals(requestedCluster.group(), nodeCluster.group());
        else
            assertEquals(0, nodeCluster.group().get().index());
        indices.add(host.membership().get().index());
    }
    assertEquals("Indexes in " + requestedCluster + " are disjunct", hosts.size(), indices.size());
}
Also used : ClusterSpec(com.yahoo.config.provision.ClusterSpec) HostSpec(com.yahoo.config.provision.HostSpec) HashSet(java.util.HashSet)

Example 18 with HostSpec

use of com.yahoo.config.provision.HostSpec 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 19 with HostSpec

use of com.yahoo.config.provision.HostSpec 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)

Example 20 with HostSpec

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

the class HostSpecTest method testEquals.

@Test
public void testEquals() {
    HostSpec h1 = new HostSpec("foo", Collections.<String>emptyList());
    HostSpec h2 = new HostSpec("foo", Collections.<String>emptyList());
    HostSpec h3 = new HostSpec("foo", Arrays.asList("my", "alias"));
    HostSpec h4 = new HostSpec("bar", Collections.<String>emptyList());
    assertTrue(h1.equals(h1));
    assertTrue(h1.equals(h2));
    assertTrue(h1.equals(h3));
    assertFalse(h1.equals(h4));
    assertTrue(h2.equals(h1));
    assertTrue(h2.equals(h2));
    assertTrue(h2.equals(h3));
    assertFalse(h2.equals(h4));
    assertTrue(h3.equals(h1));
    assertTrue(h3.equals(h2));
    assertTrue(h3.equals(h3));
    assertFalse(h3.equals(h4));
    assertFalse(h4.equals(h1));
    assertFalse(h4.equals(h2));
    assertFalse(h4.equals(h3));
    assertTrue(h4.equals(h4));
}
Also used : HostSpec(com.yahoo.config.provision.HostSpec) Test(org.junit.Test)

Aggregations

HostSpec (com.yahoo.config.provision.HostSpec)33 Test (org.junit.Test)18 Zone (com.yahoo.config.provision.Zone)14 ApplicationId (com.yahoo.config.provision.ApplicationId)13 Node (com.yahoo.vespa.hosted.provision.Node)12 ClusterSpec (com.yahoo.config.provision.ClusterSpec)10 HashSet (java.util.HashSet)7 NestedTransaction (com.yahoo.transaction.NestedTransaction)6 Version (com.yahoo.component.Version)5 Capacity (com.yahoo.config.provision.Capacity)5 Flavor (com.yahoo.config.provision.Flavor)5 List (java.util.List)5 ClusterMembership (com.yahoo.config.provision.ClusterMembership)4 Environment (com.yahoo.config.provision.Environment)4 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)4 Collections (java.util.Collections)4 RegionName (com.yahoo.config.provision.RegionName)3 NodeList (com.yahoo.vespa.hosted.provision.NodeList)3 JobControl (com.yahoo.vespa.hosted.provision.maintenance.JobControl)3 Agent (com.yahoo.vespa.hosted.provision.node.Agent)3