use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class VespaModelFactoryTest method hostedVespaZoneApplicationAllocatesNodesFromNodeRepo.
@Test
public void hostedVespaZoneApplicationAllocatesNodesFromNodeRepo() {
String hostName = "test-host-name";
String routingClusterName = "routing-cluster";
String hosts = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<hosts>\n" + " <host name='" + hostName + "'>\n" + " <alias>proxy1</alias>\n" + " </host>\n" + "</hosts>";
String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services version='1.0' xmlns:deploy='vespa'>\n" + " <admin version='2.0'>\n" + " <adminserver hostalias='proxy1' />\n" + " </admin>" + " <jdisc id='" + routingClusterName + "' version='1.0'>\n" + " <nodes type='proxy'/>\n" + " </jdisc>\n" + "</services>";
HostProvisioner provisionerToOverride = new HostProvisioner() {
@Override
public HostSpec allocateHost(String alias) {
return new HostSpec(hostName, Collections.emptyList(), ClusterMembership.from(ClusterSpec.from(ClusterSpec.Type.admin, new ClusterSpec.Id(routingClusterName), ClusterSpec.Group.from(0), Version.fromString("6.42"), false), 0));
}
@Override
public List<HostSpec> prepare(ClusterSpec cluster, Capacity capacity, int groups, ProvisionLogger logger) {
return Collections.singletonList(new HostSpec(hostName, Collections.emptyList(), ClusterMembership.from(ClusterSpec.from(ClusterSpec.Type.container, new ClusterSpec.Id(routingClusterName), ClusterSpec.Group.from(0), Version.fromString("6.42"), false), 0)));
}
};
ModelContext modelContext = createMockModelContext(hosts, services, provisionerToOverride);
Model model = new VespaModelFactory(new NullConfigModelRegistry()).createModel(modelContext);
List<HostInfo> allocatedHosts = new ArrayList<>(model.getHosts());
assertThat(allocatedHosts.size(), is(1));
HostInfo hostInfo = allocatedHosts.get(0);
assertThat(hostInfo.getHostname(), is(hostName));
assertTrue("Routing service should run on host " + hostName, hostInfo.getServices().stream().map(ServiceInfo::getConfigId).anyMatch(configId -> configId.contains(routingClusterName)));
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class AclProvisioningTest method allocateNodes.
private List<Node> allocateNodes(Capacity capacity, ApplicationId applicationId) {
ClusterSpec cluster = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("test"), Version.fromString("6.42"), false);
List<HostSpec> prepared = tester.prepare(applicationId, cluster, capacity, 1);
tester.activate(applicationId, new HashSet<>(prepared));
return tester.getNodes(applicationId, Node.State.active).asList();
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class DynamicDockerProvisioningTest method do_not_relocate_nodes_from_spare_if_no_where_to_reloacte_them.
/**
* Test redeployment of nodes that violates spare headroom - but without alternatives
* <p>
* Setup 2 docker hosts and allocate one app with a container on each
* No headroom defined - only 2 spares.
* <p>
* Initial allocation of app 1 --> final allocation:
* <p>
* | | | | | |
* | | | --> | | |
* | 1a | 1b | | 1a | 1b |
*/
@Test
public void do_not_relocate_nodes_from_spare_if_no_where_to_reloacte_them() {
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), flavorsConfig());
tester.makeReadyNodes(2, "host-small", NodeType.host, 32);
deployZoneApp(tester);
List<Node> dockerHosts = tester.nodeRepository().getNodes(NodeType.host, Node.State.active);
Flavor flavor = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-1");
// Application 1
ApplicationId application1 = makeApplicationId("t1", "a1");
ClusterSpec clusterSpec1 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false);
addAndAssignNode(application1, "1a", dockerHosts.get(0).hostname(), flavor, 0, tester);
addAndAssignNode(application1, "1b", dockerHosts.get(1).hostname(), flavor, 1, tester);
// Redeploy both applications (to be agnostic on which hosts are picked as spares)
deployapp(application1, clusterSpec1, flavor, tester, 2);
// Assert that we have two spare nodes (two hosts that are don't have allocations)
Set<String> hostsWithChildren = new HashSet<>();
for (Node node : tester.nodeRepository().getNodes(NodeType.tenant, Node.State.active)) {
if (!isInactiveOrRetired(node)) {
hostsWithChildren.add(node.parentHostname().get());
}
}
Assert.assertEquals(2, hostsWithChildren.size());
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class DynamicDockerProvisioningTest method reloacte_failed_nodes.
/**
* Test an allocation workflow:
* <p>
* 5 Hosts of capacity 3 (2 spares)
* - Allocate app with 3 nodes
* - Allocate app with 2 nodes
* - Fail host and check redistribution
*/
@Test
public void reloacte_failed_nodes() {
ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east")), flavorsConfig());
tester.makeReadyNodes(5, "host-small", NodeType.host, 32);
deployZoneApp(tester);
List<Node> dockerHosts = tester.nodeRepository().getNodes(NodeType.host, Node.State.active);
Flavor flavor = tester.nodeRepository().getAvailableFlavors().getFlavorOrThrow("d-1");
// Application 1
ApplicationId application1 = makeApplicationId("t1", "a1");
ClusterSpec clusterSpec1 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false);
deployapp(application1, clusterSpec1, flavor, tester, 3);
// Application 2
ApplicationId application2 = makeApplicationId("t2", "a2");
ClusterSpec clusterSpec2 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false);
deployapp(application2, clusterSpec2, flavor, tester, 2);
// Application 3
ApplicationId application3 = makeApplicationId("t3", "a3");
ClusterSpec clusterSpec3 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false);
deployapp(application3, clusterSpec3, flavor, tester, 2);
// App 2 and 3 should have been allocated to the same nodes - fail on of the parent hosts from there
String parent = tester.nodeRepository().getNodes(application2).stream().findAny().get().parentHostname().get();
tester.nodeRepository().failRecursively(parent, Agent.system, "Testing");
// Redeploy all applications
deployapp(application1, clusterSpec1, flavor, tester, 3);
deployapp(application2, clusterSpec2, flavor, tester, 2);
deployapp(application3, clusterSpec3, flavor, tester, 2);
Map<Integer, Integer> numberOfChildrenStat = new HashMap<>();
for (Node node : dockerHosts) {
int nofChildren = tester.nodeRepository().getChildNodes(node.hostname()).size();
if (!numberOfChildrenStat.containsKey(nofChildren)) {
numberOfChildrenStat.put(nofChildren, 0);
}
numberOfChildrenStat.put(nofChildren, numberOfChildrenStat.get(nofChildren) + 1);
}
assertEquals(3l, (long) numberOfChildrenStat.get(3));
assertEquals(1l, (long) numberOfChildrenStat.get(0));
assertEquals(1l, (long) numberOfChildrenStat.get(1));
}
use of com.yahoo.config.provision.ClusterSpec in project vespa by vespa-engine.
the class DynamicDockerProvisioningTest method addAndAssignNode.
private Node addAndAssignNode(ApplicationId id, String hostname, String parentHostname, Flavor flavor, int index, ProvisioningTester tester) {
Node node1a = Node.create("open1", Collections.singleton("127.0.0.100"), new HashSet<>(), hostname, Optional.of(parentHostname), flavor, NodeType.tenant);
ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false).with(Optional.of(ClusterSpec.Group.from(0)));
ClusterMembership clusterMembership1 = ClusterMembership.from(clusterSpec, index);
Node node1aAllocation = node1a.allocate(id, clusterMembership1, Instant.now());
tester.nodeRepository().addNodes(Collections.singletonList(node1aAllocation));
NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(tester.getCurator()));
tester.nodeRepository().activate(Collections.singletonList(node1aAllocation), transaction);
transaction.commit();
return node1aAllocation;
}
Aggregations