Search in sources :

Example 66 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class DocumentDatabaseTestCase method assertAttributesConfigIndependentOfMode.

private void assertAttributesConfigIndependentOfMode(String mode, List<String> sds, List<String> documentDBConfigIds, Map<String, List<String>> expectedAttributesMap) {
    VespaModel model = new VespaModelCreatorWithMockPkg(vespaHosts, createVespaServices(sds, mode), ApplicationPackageUtils.generateSearchDefinitions(sds)).create();
    ContentSearchCluster contentSearchCluster = model.getContentClusters().get("test").getSearch();
    ProtonConfig proton = getProtonCfg(contentSearchCluster);
    assertEquals(sds.size(), proton.documentdb().size());
    for (int i = 0; i < sds.size(); i++) {
        assertEquals(sds.get(i), proton.documentdb(i).inputdoctypename());
        assertEquals(documentDBConfigIds.get(i), proton.documentdb(i).configid());
        List<String> expectedAttributes = expectedAttributesMap.get(sds.get(i));
        if (expectedAttributes != null) {
            AttributesConfig rac1 = model.getConfig(AttributesConfig.class, proton.documentdb(i).configid());
            assertEquals(expectedAttributes.size(), rac1.attribute().size());
            for (int j = 0; j < expectedAttributes.size(); j++) {
                assertEquals(expectedAttributes.get(j), rac1.attribute(j).name());
            }
        }
    }
}
Also used : ContentSearchCluster(com.yahoo.vespa.model.content.ContentSearchCluster) ProtonConfig(com.yahoo.vespa.config.search.core.ProtonConfig) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) AttributesConfig(com.yahoo.vespa.config.search.AttributesConfig)

Example 67 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class DocumentDatabaseTestCase method requireThatRelevantConfigIsAvailableForClusterSearcher.

@Test
public void requireThatRelevantConfigIsAvailableForClusterSearcher() throws ParseException, IOException, SAXException {
    final List<String> sds = Arrays.asList("type1", "type2");
    VespaModel model = new VespaModelCreatorWithMockPkg(vespaHosts, createVespaServices(sds, "index"), ApplicationPackageUtils.generateSearchDefinitions(sds)).create();
    String searcherId = "container/searchchains/chain/test/component/com.yahoo.prelude.cluster.ClusterSearcher";
    {
        // documentdb-info config
        DocumentdbInfoConfig dcfg = model.getConfig(DocumentdbInfoConfig.class, searcherId);
        assertEquals(2, dcfg.documentdb().size());
        {
            // type1
            DocumentdbInfoConfig.Documentdb db = dcfg.documentdb(0);
            assertEquals("type1", db.name());
            assertEquals(6, db.rankprofile().size());
            assertRankProfile(db, 0, "default", false, false);
            assertRankProfile(db, 1, "unranked", false, false);
            assertRankProfile(db, 2, "staticrank", false, false);
            assertRankProfile(db, 3, "summaryfeatures", true, false);
            assertRankProfile(db, 4, "inheritedsummaryfeatures", true, false);
            assertRankProfile(db, 5, "rankfeatures", false, true);
            assertEquals(2, db.summaryclass().size());
            assertEquals("default", db.summaryclass(0).name());
            assertEquals("attributeprefetch", db.summaryclass(1).name());
            assertSummaryField(db, 0, 0, "f1", "longstring", true);
            assertSummaryField(db, 0, 1, "f2", "integer", false);
        }
        {
            // type2
            DocumentdbInfoConfig.Documentdb db = dcfg.documentdb(1);
            assertEquals("type2", db.name());
        }
    }
    {
        // attributes config
        AttributesConfig acfg = model.getConfig(AttributesConfig.class, searcherId);
        assertEquals(4, acfg.attribute().size());
        assertEquals("f2", acfg.attribute(0).name());
        assertEquals("f2_nfa", acfg.attribute(1).name());
        assertEquals("f4", acfg.attribute(2).name());
        assertEquals("f4_nfa", acfg.attribute(3).name());
    }
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) VespaModel(com.yahoo.vespa.model.VespaModel) AttributesConfig(com.yahoo.vespa.config.search.AttributesConfig) Test(org.junit.Test)

Example 68 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class VespaModelTestCase method testCommonConfig.

// Verify that common config from plugins is delivered from the root node for any configId, using the Builder based API
@Test
public void testCommonConfig() throws Exception {
    VespaModel model = getVespaModel(TESTDIR + "app_nohosts/");
    LogdConfig.Builder b = new LogdConfig.Builder();
    b = (LogdConfig.Builder) model.getConfig(b, "");
    LogdConfig c = new LogdConfig(b);
    assertEquals(HostName.getLocalhost(), c.logserver().host());
    SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
    sb = (com.yahoo.cloud.config.SlobroksConfig.Builder) model.getConfig(sb, "");
    SlobroksConfig sbc = new SlobroksConfig(sb);
    assertEquals(sbc.slobrok().size(), 1);
    ZookeepersConfig.Builder zb = new ZookeepersConfig.Builder();
    zb = (ZookeepersConfig.Builder) model.getConfig(zb, "");
    ZookeepersConfig zc = new ZookeepersConfig(zb);
    assertEquals(zc.zookeeperserverlist().split(",").length, 2);
    assertTrue(zc.zookeeperserverlist().startsWith(HostName.getLocalhost()));
    ApplicationIdConfig.Builder appIdBuilder = new ApplicationIdConfig.Builder();
    appIdBuilder = (ApplicationIdConfig.Builder) model.getConfig(appIdBuilder, "");
    ApplicationIdConfig applicationIdConfig = new ApplicationIdConfig(appIdBuilder);
    assertEquals(ApplicationId.defaultId().tenant().value(), applicationIdConfig.tenant());
    assertEquals(ApplicationId.defaultId().application().value(), applicationIdConfig.application());
    assertEquals(ApplicationId.defaultId().instance().value(), applicationIdConfig.instance());
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) ApplicationIdConfig(com.yahoo.cloud.config.ApplicationIdConfig) LogdConfig(com.yahoo.cloud.config.log.LogdConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ZookeepersConfig(com.yahoo.cloud.config.ZookeepersConfig) Test(org.junit.Test)

Example 69 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class VespaModelTestCase method testIllegalConfigIdWithBuilders.

@Ignore
@Test(expected = UnknownConfigIdException.class)
public void testIllegalConfigIdWithBuilders() {
    VespaModel model = getVespaModel(TESTDIR + "app_nohosts/");
    DocumentmanagerConfig.Builder db = new DocumentmanagerConfig.Builder();
    model.getConfig(db, "bogus");
}
Also used : DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 70 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class VespaModelTestCase method testCreateFromReaders.

@Test
public void testCreateFromReaders() throws SAXException, IOException {
    VespaModel model = CommonVespaModelSetup.createVespaModelWithMusic(simpleHosts, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<services  version=\"1.0\">" + "<admin  version=\"2.0\">" + "  <adminserver hostalias=\"node0\" />" + "</admin>" + "<container version=\"1.0\">" + "   <nodes>" + "      <node hostalias=\"node0\" />" + "   </nodes>" + "   <search/>" + "   <document-api/>" + "</container>" + "<content id=\"music\" version=\"1.0\">" + "   <redundancy>1</redundancy>" + "   <nodes>" + "      <node hostalias=\"node0\" distribution-key=\"0\"/>" + "   </nodes>" + "   <documents>" + "     <document type=\"music\" mode=\"index\"/>" + "   </documents>" + "</content>" + "</services>");
    MessagebusConfig.Builder mBusB = new MessagebusConfig.Builder();
    model.getConfig(mBusB, "client");
    MessagebusConfig mBus = new MessagebusConfig(mBusB);
    assertEquals(mBus.routingtable().size(), 1);
}
Also used : MessagebusConfig(com.yahoo.messagebus.MessagebusConfig) VespaModel(com.yahoo.vespa.model.VespaModel) 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