Search in sources :

Example 6 with VespaModelCreatorWithFilePkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.

the class ContainerIncludeTest method include_file_with_wrong_root_element_name.

@Test(expected = IllegalArgumentException.class)
public void include_file_with_wrong_root_element_name() {
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude5/");
    creator.create();
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) Test(org.junit.Test)

Example 7 with VespaModelCreatorWithFilePkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg 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 8 with VespaModelCreatorWithFilePkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.

the class ContainerIncludeTest method includeAbsolutePath.

@Test(expected = IllegalArgumentException.class)
public void includeAbsolutePath() {
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude3/");
    creator.create();
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) Test(org.junit.Test)

Example 9 with VespaModelCreatorWithFilePkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.

the class StreamingValidatorTest method document_references_are_forbidden_in_streaming_search.

@Test
public void document_references_are_forbidden_in_streaming_search() {
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("For streaming search cluster 'content.ad': Attribute 'campaign_ref' has type 'Reference<campaign>'. " + "Document references and imported fields are not allowed in streaming search.");
    new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/document_references_validation/").create();
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) Test(org.junit.Test)

Example 10 with VespaModelCreatorWithFilePkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.

the class RoutingTestCase method assertApplication.

/**
 * Tests whether or not the given application produces the expected output. When creating new tests, create an
 * application directory containing the necessary setup files, and call this method with a TRUE create flag.
 *
 * @param application The application directory.
 */
private static void assertApplication(File application) throws IOException {
    assertTrue(application.isDirectory());
    String applicationName = application.getName();
    Map<String, File> files = new HashMap<>();
    for (File file : application.listFiles(new ContentFilter())) {
        files.put(file.getName(), file);
    }
    String path = null;
    try {
        path = application.getCanonicalPath();
    } catch (IOException e) {
        fail("Could not resolve path for application '" + applicationName + "'.");
    }
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg(path);
    VespaModel model = creator.create();
    List<String> errors = model.getRouting().getErrors();
    if (errors.isEmpty()) {
        if (files.containsKey("errors.txt")) {
            if (WRITE_FILES) {
                files.remove("errors.txt").delete();
            } else {
                fail("Route verification did not fail.");
            }
        }
        MessagebusConfig.Builder mBusB = new MessagebusConfig.Builder();
        model.getConfig(mBusB, "");
        MessagebusConfig mBus = new MessagebusConfig(mBusB);
        assertConfigFileContains(application, files, "messagebus.cfg", mBus);
        DocumentrouteselectorpolicyConfig.Builder drB = new DocumentrouteselectorpolicyConfig.Builder();
        model.getConfig(drB, "");
        DocumentrouteselectorpolicyConfig dr = new DocumentrouteselectorpolicyConfig(drB);
        assertConfigFileContains(application, files, "documentrouteselectorpolicy.cfg", dr);
    } else {
        StringBuilder msg = new StringBuilder();
        for (String error : errors) {
            msg.append(error).append("\n");
        }
        assertFileContains(application, files, "errors.txt", msg.toString());
    }
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) HashMap(java.util.HashMap) DocumentrouteselectorpolicyConfig(com.yahoo.documentapi.messagebus.protocol.DocumentrouteselectorpolicyConfig) MessagebusConfig(com.yahoo.messagebus.MessagebusConfig) VespaModel(com.yahoo.vespa.model.VespaModel)

Aggregations

VespaModelCreatorWithFilePkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg)18 Test (org.junit.Test)16 VespaModel (com.yahoo.vespa.model.VespaModel)5 HashMap (java.util.HashMap)2 ModelConfig (com.yahoo.cloud.config.ModelConfig)1 ComponentId (com.yahoo.component.ComponentId)1 ConfigModelRegistry (com.yahoo.config.model.ConfigModelRegistry)1 MapConfigModelRegistry (com.yahoo.config.model.MapConfigModelRegistry)1 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)1 DocumentrouteselectorpolicyConfig (com.yahoo.documentapi.messagebus.protocol.DocumentrouteselectorpolicyConfig)1 MessagebusConfig (com.yahoo.messagebus.MessagebusConfig)1 Container (com.yahoo.vespa.model.container.Container)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 Component (com.yahoo.vespa.model.container.component.Component)1 DocprocChain (com.yahoo.vespa.model.container.docproc.DocprocChain)1 ProcessingChain (com.yahoo.vespa.model.container.processing.ProcessingChain)1 SearchChain (com.yahoo.vespa.model.container.search.searchchain.SearchChain)1 ApiConfigModel (com.yahoo.vespa.model.test.ApiConfigModel)1 SimpleConfigModel (com.yahoo.vespa.model.test.SimpleConfigModel)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1