Search in sources :

Example 11 with VespaModelCreatorWithMockPkg

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

the class IndexedTest method requireMultipleDocumentTypes.

@Test
public void requireMultipleDocumentTypes() {
    VespaModelCreatorWithMockPkg creator = getIndexedVespaModelCreator();
    VespaModel model = creator.create();
    DeployState deployState = creator.deployState;
    IndexedSearchCluster cluster = model.getContentClusters().get("test").getSearch().getIndexed();
    assertEquals(3, cluster.getDocumentDbs().size());
    NewDocumentType type1 = deployState.getDocumentModel().getDocumentManager().getDocumentType("type1");
    NewDocumentType type2 = deployState.getDocumentModel().getDocumentManager().getDocumentType("type2");
    NewDocumentType type3 = deployState.getDocumentModel().getDocumentManager().getDocumentType("type3");
    assertNotNull(type1);
    assertNotNull(type2);
    assertNotNull(type3);
}
Also used : IndexedSearchCluster(com.yahoo.vespa.model.search.IndexedSearchCluster) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Example 12 with VespaModelCreatorWithMockPkg

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

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

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

the class VespaModelTester method createModel.

/**
 * Creates a model using the hosts already added to this
 *
 * @param services the services xml string
 * @param failOnOutOfCapacity whether we should get an exception when not enough hosts of the requested flavor
 *        is available or if we should just silently receive a smaller allocation
 * @return the resulting model
 */
public VespaModel createModel(String services, boolean failOnOutOfCapacity, int startIndexForClusters, String... retiredHostNames) {
    VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
    ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
    HostProvisioner provisioner = hosted ? new InMemoryProvisioner(hostsByFlavor, failOnOutOfCapacity, startIndexForClusters, retiredHostNames) : new SingleNodeProvisioner();
    DeployProperties properties = new DeployProperties.Builder().hostedVespa(hosted).applicationId(applicationId).build();
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
    return modelCreatorWithMockPkg.create(false, deployState, configModelRegistry);
}
Also used : SingleNodeProvisioner(com.yahoo.config.model.provision.SingleNodeProvisioner) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) HostProvisioner(com.yahoo.config.model.api.HostProvisioner)

Example 15 with VespaModelCreatorWithMockPkg

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

the class ModelProvisioningTest method createNonProvisionedMultitenantModel.

private VespaModel createNonProvisionedMultitenantModel(String services) {
    VespaModelCreatorWithMockPkg modelCreatorWithMockPkg = new VespaModelCreatorWithMockPkg(null, services, ApplicationPackageUtils.generateSearchDefinition("type1"));
    ApplicationPackage appPkg = modelCreatorWithMockPkg.appPkg;
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).properties((new DeployProperties.Builder()).multitenant(true).build()).build(true);
    return modelCreatorWithMockPkg.create(false, deployState);
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Aggregations

VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)31 VespaModel (com.yahoo.vespa.model.VespaModel)26 Test (org.junit.Test)22 DeployState (com.yahoo.config.model.deploy.DeployState)5 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)4 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)4 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)4 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)3 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)3 AttributesConfig (com.yahoo.vespa.config.search.AttributesConfig)3 PartitionsConfig (com.yahoo.vespa.config.search.core.PartitionsConfig)3 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)3 IndexedSearchCluster (com.yahoo.vespa.model.search.IndexedSearchCluster)3 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)2 ProtonEngine (com.yahoo.vespa.model.content.engines.ProtonEngine)2 ContentClusterBuilder (com.yahoo.vespa.model.content.utils.ContentClusterBuilder)2