Search in sources :

Example 21 with VespaModel

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

the class ModelProvisioningTest method testSlobroksAreSpreadOverAllContainerClustersExceptNodeAdmin.

@Test
public void testSlobroksAreSpreadOverAllContainerClustersExceptNodeAdmin() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <admin version='4.0'/>" + "  <container version='1.0' id='routing'>" + "     <nodes count='10'/>" + "  </container>" + "  <container version='1.0' id='node-admin'>" + "     <nodes count='3'/>" + "  </container>" + "</services>";
    int numberOfHosts = 13;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    tester.setApplicationId("hosted-vespa", "routing", "default");
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    Set<String> routingHosts = getClusterHostnames(model, "routing");
    assertEquals(10, routingHosts.size());
    Set<String> nodeAdminHosts = getClusterHostnames(model, "node-admin");
    assertEquals(3, nodeAdminHosts.size());
    Set<String> slobrokHosts = model.getAdmin().getSlobroks().stream().map(AbstractService::getHostName).collect(Collectors.toSet());
    assertEquals(3, slobrokHosts.size());
    assertThat(slobrokHosts, everyItem(isIn(routingHosts)));
    assertThat(slobrokHosts, everyItem(not(isIn(nodeAdminHosts))));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 22 with VespaModel

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

the class ModelProvisioningTest method testUsingNodesCountAttributesAndGettingJustOneNode.

@Test
public void testUsingNodesCountAttributesAndGettingJustOneNode() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <admin version='3.0'>" + // Ignored
    "    <nodes count='3'/>" + "  </admin>" + "  <content version='1.0' id='bar'>" + "     <redundancy reply-after='8'>12</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='24'/>" + "     <engine><proton><searchable-copies>5</searchable-copies></proton></engine>" + "     <dispatch><num-dispatch-groups>7</num-dispatch-groups></dispatch>" + "  </content>" + "</services>";
    int numberOfHosts = 1;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, false);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    ContentCluster cluster = model.getContentClusters().get("bar");
    assertEquals(1, cluster.redundancy().effectiveInitialRedundancy());
    assertEquals(1, cluster.redundancy().effectiveFinalRedundancy());
    assertEquals(1, cluster.redundancy().effectiveReadyCopies());
    assertEquals(1, cluster.getSearch().getIndexed().getDispatchSpec().getGroups().size());
    assertFalse(cluster.getRootGroup().getPartitions().isPresent());
    assertEquals(1, cluster.getRootGroup().getNodes().size());
    assertEquals(0, cluster.getRootGroup().getSubgroups().size());
    assertThat(cluster.getRootGroup().getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getNodes().get(0).getDistributionKey(), is(0));
    assertThat(cluster.getRootGroup().getNodes().get(0).getConfigId(), is("bar/storage/0"));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 23 with VespaModel

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

the class ModelProvisioningTest method testThatTldConfigIdsAreDeterministic.

@Test
public void testThatTldConfigIdsAreDeterministic() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <admin version='4.0'/>" + "  <jdisc version='1.0' id='jdisc0'>" + "     <search/>" + "     <nodes count='2'/>" + "  </jdisc>" + "  <jdisc version='1.0' id='jdisc1'>" + "     <search/>" + "     <nodes count='2'/>" + "  </jdisc>" + "  <content version='1.0' id='content0'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2'/>" + "  </content>" + "  <content version='1.0' id='content1'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2'/>" + "  </content>" + "</services>";
    int numberOfHosts = 8;
    {
        VespaModelTester tester = new VespaModelTester();
        tester.addHosts(numberOfHosts);
        // Nodes used will be default0, default1, .. and so on.
        VespaModel model = tester.createModel(services, true);
        assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
        Map<String, ContentCluster> contentClusters = model.getContentClusters();
        assertEquals(2, contentClusters.size());
        checkThatTldAndContainerRunningOnSameHostHaveSameId(model.getContainerClusters().values(), model.getContentClusters().values(), 0);
    }
    {
        VespaModelTester tester = new VespaModelTester();
        tester.addHosts(numberOfHosts + 1);
        // Start numbering nodes with index 1 and retire first node
        // Nodes used will be default1, default2, .. and so on. Containers will start with index 1, not 0 as they are in the test above
        VespaModel model = tester.createModel(services, true, 1, "default0");
        assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
        Map<String, ContentCluster> contentClusters = model.getContentClusters();
        assertEquals(2, contentClusters.size());
        checkThatTldAndContainerRunningOnSameHostHaveSameId(model.getContainerClusters().values(), model.getContentClusters().values(), 1);
    }
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Map(java.util.Map) Test(org.junit.Test)

Example 24 with VespaModel

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

the class ClusterTest method testEndToEndOneNode.

@Test
public void testEndToEndOneNode() throws Exception {
    String services = "<?xml version='1.0' encoding='UTF-8' ?>" + "<services version='1.0'>" + "  <admin version='2.0'>" + "    <adminserver hostalias='node1'/>" + "  </admin>" + "   <jdisc id='default' version='1.0'>" + "     <search/>" + "     <nodes>" + "       <node hostalias='node1'/>" + "     </nodes>" + "   </jdisc>" + "   <content id='storage' version='1.0'>" + "     <redundancy>2</redundancy>" + "     <group>" + "       <node distribution-key='0' hostalias='node1'/>" + "       <node distribution-key='1' hostalias='node1'/>" + "     </group>" + "     <tuning>" + "       <cluster-controller>" + "         <transition-time>0</transition-time>" + "       </cluster-controller>" + "     </tuning>" + "     <documents>" + "       <document mode='store-only' type='type1'/>" + "     </documents>" + "     <engine>" + "       <proton/>" + "     </engine>" + "   </content>" + " </services>";
    List<String> sds = ApplicationPackageUtils.generateSearchDefinitions("type1");
    VespaModel model = (new VespaModelCreatorWithMockPkg(null, services, sds)).create();
    assertEquals(1, model.getContentClusters().get("storage").getDocumentDefinitions().size());
    ContainerCluster cluster = model.getAdmin().getClusterControllers();
    assertEquals(1, cluster.getContainers().size());
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Test(org.junit.Test)

Example 25 with VespaModel

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

the class ClusterTest method testSearchTuning.

@Test
public void testSearchTuning() throws Exception {
    String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<services>\n" + "\n" + "  <admin version=\"2.0\">\n" + "    <adminserver hostalias=\"node0\" />\n" + "    <cluster-controllers>\n" + "      <cluster-controller hostalias=\"node0\"/>" + "    </cluster-controllers>\n" + "  </admin>\n" + "  <content version='1.0' id='bar'>" + "     <redundancy>1</redundancy>\n" + "     <documents>" + "       <document type=\"type1\" mode='index'/>\n" + "       <document type=\"type2\" mode='index'/>\n" + "     </documents>\n" + "     <group>" + "       <node hostalias='node0' distribution-key='0'/>" + "     </group>" + "    <tuning>\n" + "      <cluster-controller>" + "        <init-progress-time>34567</init-progress-time>" + "      </cluster-controller>" + "    </tuning>" + "   </content>" + "\n" + "</services>";
    List<String> sds = ApplicationPackageUtils.generateSearchDefinitions("type1", "type2");
    VespaModel model = new VespaModelCreatorWithMockPkg(getHosts(), xml, sds).create();
    assertTrue(model.getContentClusters().get("bar").getPersistence() instanceof ProtonEngine.Factory);
    {
        StorDistributormanagerConfig.Builder builder = new StorDistributormanagerConfig.Builder();
        model.getConfig(builder, "bar/distributor/0");
        StorDistributormanagerConfig config = new StorDistributormanagerConfig(builder);
        assertEquals(false, config.inlinebucketsplitting());
    }
    {
        StorFilestorConfig.Builder builder = new StorFilestorConfig.Builder();
        model.getConfig(builder, "bar/storage/0");
        StorFilestorConfig config = new StorFilestorConfig(builder);
        assertEquals(false, config.enable_multibit_split_optimalization());
    }
}
Also used : StorDistributormanagerConfig(com.yahoo.vespa.config.content.core.StorDistributormanagerConfig) StorFilestorConfig(com.yahoo.vespa.config.content.StorFilestorConfig) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) SearchDefinitionBuilder(com.yahoo.vespa.model.content.utils.SearchDefinitionBuilder) ContentClusterBuilder(com.yahoo.vespa.model.content.utils.ContentClusterBuilder) ProtonEngine(com.yahoo.vespa.model.content.engines.ProtonEngine) 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