use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class VespaDomBuilderTest method testUserConfigsWithNamespace.
@Test
public void testUserConfigsWithNamespace() throws Exception {
VespaModel model = createModel(hosts, servicesWithNamespace);
GenericConfig.GenericConfigBuilder builder = new GenericConfig.GenericConfigBuilder(new ConfigDefinitionKey("testnamespace", "foo"), new ConfigPayloadBuilder());
model.getConfig(builder, "admin");
assertEquals(builder.getPayload().toString(), "{\n" + " \"basicStruct\": {\n" + " \"stringVal\": \"default\"\n" + " }\n" + "}\n");
model = createModel(hosts, servicesWithNamespace2);
builder = new GenericConfig.GenericConfigBuilder(new ConfigDefinitionKey("testnamespace", "foo"), new ConfigPayloadBuilder());
model.getConfig(builder, "admin");
assertEquals(builder.getPayload().toString(), "{\n" + " \"basicStruct\": {\n" + " \"stringVal\": \"default\"\n" + " }\n" + "}\n");
}
use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class ContainerIncludeTest method include.
@Test
public void include() {
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude/");
VespaModel model = creator.create();
assertThat(model.getContainerClusters().size(), is(1));
ContainerCluster cluster = model.getContainerClusters().values().iterator().next();
assertThat(cluster.getSearchChains(), notNullValue());
Map<String, SearchChain> searchChainMap = new HashMap<>();
for (SearchChain searchChain : cluster.getSearchChains().allChains().allComponents()) {
searchChainMap.put(searchChain.getId().stringValue(), searchChain);
}
assertThat(searchChainMap.get("searchchain1"), notNullValue());
assertThat(searchChainMap.get("searchchain1").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher1"));
assertThat(searchChainMap.get("searchchain2"), notNullValue());
assertThat(searchChainMap.get("searchchain2").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher2"));
assertThat(searchChainMap.get("searchchain3"), notNullValue());
assertThat(searchChainMap.get("searchchain3").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain3").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher3"));
assertThat(searchChainMap.get("searchchain4"), notNullValue());
assertThat(searchChainMap.get("searchchain4").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain4").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher4"));
assertThat(cluster.getDocprocChains(), notNullValue());
Map<String, DocprocChain> docprocChainMap = new HashMap<>();
for (DocprocChain docprocChain : cluster.getDocprocChains().allChains().allComponents()) {
docprocChainMap.put(docprocChain.getId().stringValue(), docprocChain);
}
assertThat(docprocChainMap.get("docprocchain1"), notNullValue());
assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().size(), is(1));
assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor1"));
assertThat(docprocChainMap.get("docprocchain2"), notNullValue());
assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().size(), is(1));
assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor2"));
assertThat(cluster.getProcessingChains(), notNullValue());
Map<String, ProcessingChain> processingChainMap = new HashMap<>();
for (ProcessingChain processingChain : cluster.getProcessingChains().allChains().allComponents()) {
processingChainMap.put(processingChain.getId().stringValue(), processingChain);
}
assertThat(processingChainMap.get("processingchain1"), notNullValue());
assertThat(processingChainMap.get("processingchain1").getInnerComponents().size(), is(1));
assertThat(processingChainMap.get("processingchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor1"));
assertThat(processingChainMap.get("processingchain2"), notNullValue());
assertThat(processingChainMap.get("processingchain2").getInnerComponents().size(), is(1));
assertThat(processingChainMap.get("processingchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor2"));
}
use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class ContainerModelBuilderTest method qrconfig_is_produced.
@Test
public void qrconfig_is_produced() throws IOException, SAXException {
String servicesXml = "<services>" + "<admin version='3.0'>" + " <nodes count='1'/>" + "</admin>" + "<jdisc id ='default' version='1.0'>" + " <nodes>" + " <node hostalias='node1' />" + " </nodes>" + "</jdisc>" + "</services>";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().applicationPackage(applicationPackage).properties(new DeployProperties.Builder().build()).build(true));
// Using the same way of getting hostname as filedistribution model
String hostname = HostName.getLocalhost();
QrConfig config = model.getConfig(QrConfig.class, "default/container.0");
assertEquals("default.container.0", config.discriminator());
assertEquals(19102, config.rpc().port());
assertEquals("vespa/service/default/container.0", config.rpc().slobrokId());
assertEquals(true, config.rpc().enabled());
assertEquals("", config.rpc().host());
assertEquals(false, config.restartOnDeploy());
assertEquals(false, config.coveragereports());
assertEquals("filedistribution/" + hostname, config.filedistributor().configid());
}
use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class ContainerModelBuilderTest method singlenode_servicespec_is_used_with_hosted_vespa.
@Test
public void singlenode_servicespec_is_used_with_hosted_vespa() throws IOException, SAXException {
String servicesXml = "<jdisc id='default' version='1.0' />";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com", "host2.yahoo.com")).applicationPackage(applicationPackage).properties(new DeployProperties.Builder().multitenant(true).hostedVespa(true).build()).build(true));
assertEquals(1, model.getHostSystem().getHosts().size());
}
use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.
the class ContainerModelBuilderTest method singlenode_servicespec_is_used_with_hosts_xml.
@Test
public void singlenode_servicespec_is_used_with_hosts_xml() throws IOException, SAXException {
String servicesXml = "<jdisc id='default' version='1.0' />";
String hostsXml = "<hosts>\n" + " <host name=\"test1.yahoo.com\">\n" + " <alias>node1</alias>\n" + " </host>\n" + "</hosts>";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withHosts(hostsXml).withServices(servicesXml).build();
VespaModel model = new VespaModel(applicationPackage);
assertThat(model.getHostSystem().getHosts().size(), is(1));
}
Aggregations