use of com.yahoo.config.provision.HostSpec 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.HostSpec in project vespa by vespa-engine.
the class HostsXmlProvisionerTest method assertCorrectNumberOfHosts.
private void assertCorrectNumberOfHosts(Map<String, HostSpec> hostToServiceMap, int expectedHostCount) {
Set<String> hostSet = new HashSet<>();
for (HostSpec host : hostToServiceMap.values()) {
hostSet.add(host.hostname());
}
assertThat(hostSet.size(), is(expectedHostCount));
}
use of com.yahoo.config.provision.HostSpec in project vespa by vespa-engine.
the class SingleNodeProvisionerTest method assertCorrectNumberOfHost.
private void assertCorrectNumberOfHost(Map<String, HostSpec> hostToServiceMap, int expectedHostCount) {
Set<String> hostSet = new HashSet<>();
for (HostSpec host : hostToServiceMap.values()) {
hostSet.add(host.hostname());
}
assertThat(hostSet.size(), is(expectedHostCount));
}
use of com.yahoo.config.provision.HostSpec 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.HostSpec in project vespa by vespa-engine.
the class ProvisioningTest method prepare.
private SystemState prepare(ApplicationId application, int container0Size, int container1Size, int content0Size, int content1Size, boolean required, String flavor, Version wantedVersion, ProvisioningTester tester) {
// "deploy prepare" with a two container clusters and a storage cluster having of two groups
ClusterSpec containerCluster0 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("container0"), wantedVersion, false);
ClusterSpec containerCluster1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("container1"), wantedVersion, false);
ClusterSpec contentCluster0 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("content0"), wantedVersion, false);
ClusterSpec contentCluster1 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("content1"), wantedVersion, false);
Set<HostSpec> container0 = prepare(application, containerCluster0, container0Size, 1, required, flavor, tester);
Set<HostSpec> container1 = prepare(application, containerCluster1, container1Size, 1, required, flavor, tester);
Set<HostSpec> content0 = prepare(application, contentCluster0, content0Size, 1, required, flavor, tester);
Set<HostSpec> content1 = prepare(application, contentCluster1, content1Size, 1, required, flavor, tester);
Set<HostSpec> allHosts = new HashSet<>();
allHosts.addAll(container0);
allHosts.addAll(container1);
allHosts.addAll(content0);
allHosts.addAll(content1);
Function<Integer, Capacity> capacity = count -> Capacity.fromNodeCount(count, Optional.empty(), required);
int expectedContainer0Size = tester.capacityPolicies().decideSize(capacity.apply(container0Size));
int expectedContainer1Size = tester.capacityPolicies().decideSize(capacity.apply(container1Size));
int expectedContent0Size = tester.capacityPolicies().decideSize(capacity.apply(content0Size));
int expectedContent1Size = tester.capacityPolicies().decideSize(capacity.apply(content1Size));
assertEquals("Hosts in each group cluster is disjunct and the total number of unretired nodes is correct", expectedContainer0Size + expectedContainer1Size + expectedContent0Size + expectedContent1Size, tester.nonRetired(allHosts).size());
// Check cluster/group sizes
assertEquals(expectedContainer0Size, tester.nonRetired(container0).size());
assertEquals(expectedContainer1Size, tester.nonRetired(container1).size());
assertEquals(expectedContent0Size, tester.nonRetired(content0).size());
assertEquals(expectedContent1Size, tester.nonRetired(content1).size());
// Check cluster membership
tester.assertMembersOf(containerCluster0, container0);
tester.assertMembersOf(containerCluster1, container1);
tester.assertMembersOf(contentCluster0, content0);
tester.assertMembersOf(contentCluster1, content1);
return new SystemState(allHosts, container0, container1, content0, content1);
}
Aggregations