Search in sources :

Example 6 with VespaModel

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

the class ModelProvisioningTest method testUsingNodesAndGroupCountAttributesAndGettingJustOneNode.

@Test
public void testUsingNodesAndGroupCountAttributesAndGettingJustOneNode() throws ParseException {
    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='3'>4</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='24' groups='3'/>" + "     <engine><proton><searchable-copies>3</searchable-copies></proton></engine>" + "  </content>" + "</services>";
    // We only have 1 content node -> 1 groups with redundancy 1
    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");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(1, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    // Reduced from 3*3
    assertEquals(1, cluster.redundancy().effectiveInitialRedundancy());
    // Reduced from 3*4
    assertEquals(1, cluster.redundancy().effectiveFinalRedundancy());
    // Reduced from 3*3
    assertEquals(1, cluster.redundancy().effectiveReadyCopies());
    // 1 group - > flattened -> no distribution
    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) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 7 with VespaModel

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

the class ModelProvisioningTest method testCombinedCluster.

@Test
public void testCombinedCluster() {
    String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + "  <container version='1.0' id='container1'>" + "     <search/>" + "     <nodes of='content1'/>" + "  </container>" + "  <content version='1.0' id='content1'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2'/>" + "   </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(2);
    VespaModel model = tester.createModel(xmlWithNodes, true);
    assertEquals("Nodes in content1", 2, model.getContentClusters().get("content1").getRootGroup().getNodes().size());
    assertEquals("Nodes in container1", 2, model.getContainerClusters().get("container1").getContainers().size());
    assertEquals("Heap size is lowered with combined clusters", 17, physicalMemoryPercentage(model.getContainerClusters().get("container1")));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 8 with VespaModel

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

the class ModelProvisioningTest method testExplicitNonDedicatedClusterControllers.

@Test
public void testExplicitNonDedicatedClusterControllers() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <admin version='4.0'/>" + "  <container version='1.0' id='foo'>" + "     <nodes count='10'/>" + "  </container>" + "  <content version='1.0' id='bar'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <controllers><nodes dedicated='false' count='6'/></controllers>" + "     <nodes count='9' groups='3'/>" + "  </content>" + "</services>";
    int numberOfHosts = 19;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check content clusters
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(8, cluster.distributionBits());
    assertEquals("We get the closest odd number", 5, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default02", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default04", clusterControllers.getContainers().get(2).getHostName());
    assertEquals("default05", clusterControllers.getContainers().get(3).getHostName());
    assertEquals("default07", clusterControllers.getContainers().get(4).getHostName());
    assertEquals("default09", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    assertEquals("default08", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getHostName());
    assertEquals("default06", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    assertEquals("default03", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 9 with VespaModel

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

the class ModelProvisioningTest method testNoNodeTagMeans1NodeNoContent.

@Test
public void testNoNodeTagMeans1NodeNoContent() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <jdisc id='foo' version='1.0'>" + "    <search/>" + "    <document-api/>" + "  </jdisc>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(1);
    VespaModel model = tester.createModel(services, true);
    assertEquals(1, model.getRoot().getHostSystem().getHosts().size());
    assertEquals(1, model.getAdmin().getSlobroks().size());
    assertEquals(1, model.getContainerClusters().get("foo").getContainers().size());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 10 with VespaModel

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

the class ModelProvisioningTest method testSingleNodeNonHosted.

@Test
public void testSingleNodeNonHosted() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <jdisc id='foo' version='1.0'>" + "    <search/>" + "    <document-api/>" + "    <nodes><node hostalias='foo'/></nodes>" + "  </jdisc>" + "  <content version='1.0' id='bar'>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "    <nodes><node hostalias='foo' distribution-key='0'/></nodes>" + "  </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    tester.setHosted(false);
    tester.addHosts(1);
    VespaModel model = tester.createModel(services, true);
    assertEquals(1, model.getRoot().getHostSystem().getHosts().size());
    assertEquals(1, model.getAdmin().getSlobroks().size());
    assertEquals(1, model.getContainerClusters().get("foo").getContainers().size());
    assertEquals(1, model.getContentClusters().get("bar").getRootGroup().countNodes());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) 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