Search in sources :

Example 1 with VespaModelTester

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

the class ModelProvisioningTest method testUsingNodesCountAttributesAndGettingTooFewNodes.

@Test
public void testUsingNodesCountAttributesAndGettingTooFewNodes() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>" + "<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 = 4;
    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(4, cluster.redundancy().effectiveInitialRedundancy());
    assertEquals(4, cluster.redundancy().effectiveFinalRedundancy());
    assertEquals(4, cluster.redundancy().effectiveReadyCopies());
    assertEquals(4, cluster.getSearch().getIndexed().getDispatchSpec().getGroups().size());
    assertFalse(cluster.getRootGroup().getPartitions().isPresent());
    assertEquals(4, cluster.getRootGroup().getNodes().size());
    assertEquals(0, cluster.getRootGroup().getSubgroups().size());
    assertThat(cluster.getRootGroup().getNodes().size(), is(4));
    assertThat(cluster.getRootGroup().getNodes().get(0).getDistributionKey(), is(0));
    assertThat(cluster.getRootGroup().getNodes().get(0).getConfigId(), is("bar/storage/0"));
    assertThat(cluster.getRootGroup().getNodes().get(1).getDistributionKey(), is(1));
    assertThat(cluster.getRootGroup().getNodes().get(1).getConfigId(), is("bar/storage/1"));
    assertThat(cluster.getRootGroup().getNodes().get(2).getDistributionKey(), is(2));
    assertThat(cluster.getRootGroup().getNodes().get(2).getConfigId(), is("bar/storage/2"));
    assertThat(cluster.getRootGroup().getNodes().get(3).getDistributionKey(), is(3));
    assertThat(cluster.getRootGroup().getNodes().get(3).getConfigId(), is("bar/storage/3"));
}
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 2 with VespaModelTester

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

the class ModelProvisioningTest method testThatStandaloneSyntaxWorksOnHostedVespa.

@Test
public void testThatStandaloneSyntaxWorksOnHostedVespa() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>" + "<jdisc id='foo' version='1.0'>" + "  <http>" + "    <server id='server1' port='" + getDefaults().vespaWebServicePort() + "' />" + "  </http>" + "</jdisc>";
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(1);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getHosts().size(), is(1));
    assertThat(model.getContainerClusters().size(), is(1));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 3 with VespaModelTester

use of com.yahoo.vespa.model.test.VespaModelTester 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 4 with VespaModelTester

use of com.yahoo.vespa.model.test.VespaModelTester 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 5 with VespaModelTester

use of com.yahoo.vespa.model.test.VespaModelTester 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)

Aggregations

VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)38 Test (org.junit.Test)38 VespaModel (com.yahoo.vespa.model.VespaModel)35 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)15 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)11 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)2 ClusterMembership (com.yahoo.config.provision.ClusterMembership)1 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)1 HostResource (com.yahoo.vespa.model.HostResource)1 Admin (com.yahoo.vespa.model.admin.Admin)1 Container (com.yahoo.vespa.model.container.Container)1 StorageNode (com.yahoo.vespa.model.content.StorageNode)1 Map (java.util.Map)1 Ignore (org.junit.Ignore)1