Search in sources :

Example 71 with Node

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

the class ProvisioningTester method fail.

public void fail(HostSpec host) {
    int beforeFailCount = nodeRepository.getNode(host.hostname(), Node.State.active).get().status().failCount();
    Node failedNode = nodeRepository.fail(host.hostname(), Agent.system, "Failing to unit test");
    assertTrue(nodeRepository.getNodes(NodeType.tenant, Node.State.failed).contains(failedNode));
    assertEquals(beforeFailCount + 1, failedNode.status().failCount());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node)

Example 72 with Node

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

the class ProvisioningTester method makeProvisionedNodes.

List<Node> makeProvisionedNodes(int n, String flavor, NodeType type, int additionalIps) {
    List<Node> nodes = new ArrayList<>(n);
    for (int i = 0; i < n; i++) {
        nextHost++;
        nextIP++;
        // One test involves two provision testers - to detect this we check if the
        // name resolver already contains the next host - if this is the case - bump the indices and move on
        String testIp = String.format("127.0.0.%d", nextIP);
        MockNameResolver nameResolver = (MockNameResolver) nodeRepository().nameResolver();
        if (nameResolver.getHostname(testIp).isPresent()) {
            nextHost += 100;
            nextIP += 100;
        }
        String hostname = String.format("host-%d.yahoo.com", nextHost);
        String ipv4 = String.format("127.0.0.%d", nextIP);
        String ipv6 = String.format("::%d", nextIP);
        nameResolver.addRecord(hostname, ipv4, ipv6);
        HashSet<String> hostIps = new HashSet<>();
        hostIps.add(ipv4);
        hostIps.add(ipv6);
        Set<String> addips = new HashSet<>();
        for (int ipSeq = 1; ipSeq < additionalIps; ipSeq++) {
            nextIP++;
            String ipv6node = String.format("::%d", nextIP);
            addips.add(ipv6node);
            nameResolver.addRecord(String.format("node-%d-of-%s", ipSeq, hostname), ipv6node);
        }
        nodes.add(nodeRepository.createNode(hostname, hostname, hostIps, addips, Optional.empty(), nodeFlavors.getFlavorOrThrow(flavor), type));
    }
    nodes = nodeRepository.addNodes(nodes);
    return nodes;
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Node(com.yahoo.vespa.hosted.provision.Node) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 73 with Node

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

the class VirtualNodeProvisioningTest method fail_when_all_hosts_become_clashing.

@Test
public void fail_when_all_hosts_become_clashing() {
    tester.makeReadyVirtualNodes(1, flavor, "parentHost1");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost2");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost3");
    tester.makeReadyVirtualNodes(1, flavor, "parentHost4");
    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"));
    }
    OutOfCapacityException expected = null;
    try {
        containerHosts = prepare(containerClusterSpec, containerNodeCount, groups);
    } catch (OutOfCapacityException e) {
        expected = e;
    }
    assertNotNull(expected);
}
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 74 with Node

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

the class ReservationExpirerTest method ensure_reservation_times_out.

@Test
public void ensure_reservation_times_out() {
    ManualClock clock = new ManualClock();
    NodeFlavors flavors = FlavorConfigBuilder.createDummies("default");
    NodeRepository nodeRepository = new NodeRepository(flavors, curator, clock, Zone.defaultZone(), new MockNameResolver().mockAnyLookup(), new DockerImage("docker-registry.domain.tld:8080/dist/vespa"), true);
    NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(nodeRepository, flavors, Zone.defaultZone());
    List<Node> nodes = new ArrayList<>(2);
    nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(nodeRepository.createNode(UUID.randomUUID().toString(), UUID.randomUUID().toString(), Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.host));
    nodes = nodeRepository.addNodes(nodes);
    nodes = nodeRepository.setDirty(nodes, Agent.system, getClass().getSimpleName());
    // Reserve 2 nodes
    assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.dirty).size());
    nodeRepository.setReady(nodes, Agent.system, getClass().getSimpleName());
    ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("bar").instanceName("fuz").build();
    ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
    provisioner.prepare(applicationId, cluster, Capacity.fromNodeCount(2), 1, null);
    assertEquals(2, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
    // Reservation times out
    // Reserved but not used time out
    clock.advance(Duration.ofMinutes(14));
    new ReservationExpirer(nodeRepository, clock, Duration.ofMinutes(10), new JobControl(nodeRepository.database())).run();
    // Assert nothing is reserved
    assertEquals(0, nodeRepository.getNodes(NodeType.tenant, Node.State.reserved).size());
    List<Node> dirty = nodeRepository.getNodes(NodeType.tenant, Node.State.dirty);
    assertEquals(2, dirty.size());
    assertFalse(dirty.get(0).allocation().isPresent());
    assertFalse(dirty.get(1).allocation().isPresent());
}
Also used : MockNameResolver(com.yahoo.vespa.hosted.provision.testutils.MockNameResolver) Node(com.yahoo.vespa.hosted.provision.Node) FlavorConfigBuilder(com.yahoo.vespa.hosted.provision.provisioning.FlavorConfigBuilder) NodeRepositoryProvisioner(com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ManualClock(com.yahoo.test.ManualClock) NodeFlavors(com.yahoo.config.provision.NodeFlavors) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) DockerImage(com.yahoo.config.provision.DockerImage) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 75 with Node

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

the class RetireIPv4OnlyNodesTest method testCombinationAddress.

@Test
public void testCombinationAddress() {
    Node node = createNodeWithAddresses("127.0.0.1", "::1", "10.0.0.1", "::2");
    assertFalse(policy.shouldRetire(node).isPresent());
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) 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