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