Search in sources :

Example 11 with VespaModelTester

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

the class ModelProvisioningTest method test2ContentNodesOn2ClustersWithContainerClusterProducesMixedClusterControllerCluster.

// TODO: unignore when feature is enabled again
@Ignore
@Test
public void test2ContentNodesOn2ClustersWithContainerClusterProducesMixedClusterControllerCluster() throws ParseException {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <container version='1.0' id='container'>" + "     <nodes count='3' flavor='container-node'/>" + "  </container>" + "  <content version='1.0' id='content1'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2' flavor='content1-node'/>" + "  </content>" + "  <content version='1.0' id='content2'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2' flavor='content2-node'/>" + "  </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    // use different flavors to make the test clearer
    tester.addHosts("container-node", 3);
    tester.addHosts("content1-node", 2);
    tester.addHosts("content2-node", 2);
    VespaModel model = tester.createModel(services, true);
    ContentCluster cluster1 = model.getContentClusters().get("content1");
    ContainerCluster clusterControllers1 = cluster1.getClusterControllers();
    assertEquals(1, clusterControllers1.getContainers().size());
    assertEquals("content1-node0", clusterControllers1.getContainers().get(0).getHostName());
    assertEquals("content1-node1", clusterControllers1.getContainers().get(1).getHostName());
    assertEquals("container-node0", clusterControllers1.getContainers().get(2).getHostName());
    ContentCluster cluster2 = model.getContentClusters().get("content2");
    ContainerCluster clusterControllers2 = cluster2.getClusterControllers();
    assertEquals(3, clusterControllers2.getContainers().size());
    assertEquals("content2-node0", clusterControllers2.getContainers().get(0).getHostName());
    assertEquals("content2-node1", clusterControllers2.getContainers().get(1).getHostName());
    assertEquals("We do not pick the container used to supplement another cluster", "container-node1", clusterControllers2.getContainers().get(2).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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with VespaModelTester

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

the class ModelProvisioningTest method test2ContentNodesWithContainerClusterProducesMixedClusterControllerCluster.

@Test
public void test2ContentNodesWithContainerClusterProducesMixedClusterControllerCluster() throws ParseException {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <container version='1.0' id='foo'>" + "     <nodes count='3'/>" + "  </container>" + "  <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();
    tester.addHosts(5);
    VespaModel model = tester.createModel(services, true);
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    // TODO: Expected 3 with this feature reactivated
    assertEquals(1, clusterControllers.getContainers().size());
}
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 13 with VespaModelTester

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

the class ModelProvisioningTest method testInvalidCombinedClusterReference.

@Test
public void testInvalidCombinedClusterReference() {
    String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + "  <container version='1.0' id='container1'>" + "     <nodes of='container2'/><!-- invalid; only content clusters can be referenced -->" + "  </container>" + "  <container version='1.0' id='container2'>" + "     <nodes count='2'/>" + "  </container>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(2);
    try {
        tester.createModel(xmlWithNodes, true);
        fail("Expected exception");
    } catch (IllegalArgumentException e) {
        assertEquals("container cluster 'container1' references service 'container2', but that is not a content service", e.getMessage());
    }
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) Test(org.junit.Test)

Example 14 with VespaModelTester

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

the class ModelProvisioningTest method testRequestingSpecificFlavors.

@Test
public void testRequestingSpecificFlavors() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <admin version='4.0'>" + "     <logservers><nodes count='1' dedicated='true' flavor='logserver-flavor'/></logservers>" + "     <slobroks><nodes count='2' dedicated='true' flavor='slobrok-flavor'/></slobroks>" + "  </admin>" + "  <container version='1.0' id='container'>" + "     <nodes count='4' flavor='container-flavor'/>" + "  </container>" + "  <content version='1.0' id='foo'>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <controllers><nodes count='2' dedicated='true' flavor='controller-foo-flavor'/></controllers>" + "     <nodes count='5' flavor='content-foo-flavor'/>" + "  </content>" + "  <content version='1.0' id='bar'>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <controllers><nodes count='3' dedicated='true' flavor='controller-bar-flavor'/></controllers>" + "     <nodes count='6' flavor='content-bar-flavor'/>" + "  </content>" + "</services>";
    int totalHosts = 23;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts("logserver-flavor", 1);
    tester.addHosts("slobrok-flavor", 2);
    tester.addHosts("container-flavor", 4);
    tester.addHosts("controller-foo-flavor", 2);
    tester.addHosts("content-foo-flavor", 5);
    tester.addHosts("controller-bar-flavor", 3);
    tester.addHosts("content-bar-flavor", 6);
    // fails unless the right flavors+counts are requested
    VespaModel model = tester.createModel(services, true, 0);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(totalHosts));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 15 with VespaModelTester

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

the class ModelProvisioningTest method testClusterControllersWithGroupSize2.

@Test
public void testClusterControllersWithGroupSize2() {
    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>" + "     <nodes count='8' groups='4'/>" + "  </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 clusters
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals("We get the closest odd number", 3, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default03", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default08", clusterControllers.getContainers().get(2).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