Search in sources :

Example 61 with VespaModel

use of com.yahoo.vespa.model.VespaModel 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 62 with VespaModel

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

the class IndexedTest method requireThatIndexingDocprocGetsConfigIdBasedOnDistributionKey.

@Test
public void requireThatIndexingDocprocGetsConfigIdBasedOnDistributionKey() {
    VespaModel model = getIndexedVespaModel();
    ContainerCluster cluster = model.getContainerClusters().get("cluster.test.indexing");
    assertEquals("docproc/cluster.test.indexing/3", cluster.getContainers().get(0).getConfigId());
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Test(org.junit.Test)

Example 63 with VespaModel

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

the class IndexedTest method requireProtonStreamingOnly.

@Test
public void requireProtonStreamingOnly() {
    VespaModel model = getStreamingVespaModel();
    HostResource h = model.getHostSystem().getHosts().get(0);
    String[] expectedServices = { "logserver", "configserver", "adminserver", "slobrok", "logd", "configproxy", "config-sentinel", "qrserver", "storagenode", "searchnode", "distributor", "transactionlogserver" };
    // TODO        DomContentBuilderTest.assertServices(h, expectedServices);
    ContentCluster s = model.getContentClusters().get("test");
    assertFalse(s.getSearch().hasIndexedCluster());
    StorServerConfig.Builder builder = new StorServerConfig.Builder();
    s.getStorageNodes().getConfig(builder);
    s.getStorageNodes().getChildren().get("3").getConfig(builder);
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) VespaModel(com.yahoo.vespa.model.VespaModel) StorServerConfig(com.yahoo.vespa.config.content.core.StorServerConfig) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 64 with VespaModel

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

the class GenericServicesModelTest method test_generic_services_parsing.

@Test
public void test_generic_services_parsing() throws IOException, SAXException {
    final String hosts = "<hosts>" + "<host name=\"localhost\">" + "    <alias>mockhost</alias>" + "  </host> " + "</hosts>";
    String services = "<services version=\"1.0\">" + "<service id=\"me\" name=\"foo\" command=\"/bin/bar\" version=\"1.0\">" + "<node hostalias=\"mockhost\" />" + "</service>" + "</services>";
    VespaModel model = new VespaModel(new MockApplicationPackage.Builder().withHosts(hosts).withServices(services).build());
    GenericServicesModel gsModel = (GenericServicesModel) model.configModelRepo().get("me");
    assertThat(gsModel.serviceClusters().size(), is(1));
    assertThat(gsModel.serviceClusters().get(0).getName(), is("foo"));
    assertThat(gsModel.serviceClusters().get(0).services().size(), is(1));
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 65 with VespaModel

use of com.yahoo.vespa.model.VespaModel 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

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