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());
}
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;
}
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);
}
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());
}
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());
}
Aggregations