Search in sources :

Example 41 with VespaModel

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");
}
Also used : GenericConfig(com.yahoo.vespa.config.GenericConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) ConfigPayloadBuilder(com.yahoo.vespa.config.ConfigPayloadBuilder) Test(org.junit.Test)

Example 42 with VespaModel

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"));
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) ProcessingChain(com.yahoo.vespa.model.container.processing.ProcessingChain) HashMap(java.util.HashMap) VespaModel(com.yahoo.vespa.model.VespaModel) DocprocChain(com.yahoo.vespa.model.container.docproc.DocprocChain) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SearchChain(com.yahoo.vespa.model.container.search.searchchain.SearchChain) Test(org.junit.Test)

Example 43 with VespaModel

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());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) VespaModel(com.yahoo.vespa.model.VespaModel) QrConfig(com.yahoo.container.QrConfig) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 44 with VespaModel

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());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 45 with VespaModel

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));
}
Also used : MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Aggregations

VespaModel (com.yahoo.vespa.model.VespaModel)153 Test (org.junit.Test)135 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)35 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)26 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)22 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)21 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)18 DeployState (com.yahoo.config.model.deploy.DeployState)18 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)15 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)14 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)13 Matchers.containsString (org.hamcrest.Matchers.containsString)12 File (java.io.File)8 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)6 ValidationTester (com.yahoo.vespa.model.application.validation.ValidationTester)6 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)6 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)5 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)5 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)5 HostResource (com.yahoo.vespa.model.HostResource)5