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