Search in sources :

Example 6 with VespaModelTester

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

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

Example 8 with VespaModelTester

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

the class ModelProvisioningTest method testClusterMembership.

@Test
public void testClusterMembership() {
    String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + "  <container version='1.0' id='container1'>" + "     <nodes count='1'/>" + "  </container>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(1);
    VespaModel model = tester.createModel(xmlWithNodes, true);
    assertEquals(1, model.getHostSystem().getHosts().size());
    HostResource host = model.getHostSystem().getHosts().iterator().next();
    assertEquals(1, host.clusterMemberships().size());
    ClusterMembership membership = host.clusterMemberships().iterator().next();
    assertEquals("container", membership.cluster().type().name());
    assertEquals("container1", membership.cluster().id().value());
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ClusterMembership(com.yahoo.config.provision.ClusterMembership) VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 9 with VespaModelTester

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

the class ModelProvisioningTest method testNodeCountForContentGroup.

@Test
public void testNodeCountForContentGroup() {
    String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + "\n" + "  <admin version='3.0'>" + "    <nodes count='3'/>" + "  </admin>" + "  <content version='1.0' id='bar'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2'/>" + "   </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    int numberOfHosts = 2;
    tester.addHosts(numberOfHosts);
    int numberOfContentNodes = 2;
    VespaModel model = tester.createModel(xmlWithNodes, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    final Map<String, ContentCluster> contentClusters = model.getContentClusters();
    ContentCluster cluster = contentClusters.get("bar");
    assertThat(cluster.getRootGroup().getNodes().size(), is(numberOfContentNodes));
    int i = 0;
    for (StorageNode node : cluster.getRootGroup().getNodes()) assertEquals(i++, node.getDistributionKey());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) StorageNode(com.yahoo.vespa.model.content.StorageNode) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 10 with VespaModelTester

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

the class ModelProvisioningTest method testGroupsOfSize1.

@Test
public void testGroupsOfSize1() {
    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>1</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='8' groups='8'/>" + "  </content>" + "</services>";
    int numberOfHosts = 18;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check content cluster
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(3, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default02", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default08", clusterControllers.getContainers().get(2).getHostName());
    assertEquals(0, cluster.getRootGroup().getNodes().size());
    assertEquals(8, cluster.getRootGroup().getSubgroups().size());
    assertEquals(8, cluster.distributionBits());
    // first group
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("bar/storage/0"));
    assertEquals("default08", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    // second group
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/1"));
    assertEquals("default07", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    // ... last group
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getIndex(), is("7"));
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getDistributionKey(), is(7));
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getConfigId(), is("bar/storage/7"));
    assertEquals("default01", cluster.getRootGroup().getSubgroups().get(7).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