Search in sources :

Example 91 with VespaModel

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

the class ModelProvisioningTest method testUsingNodesAndGroupCountAttributes.

@Test
public void testUsingNodesAndGroupCountAttributes() {
    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='27' groups='9'/>" + "  </content>" + "  <content version='1.0' id='baz'>" + "     <redundancy>1</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='27' groups='27'/>" + "   </content>" + "</services>";
    int numberOfHosts = 64;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check container cluster
    assertEquals(1, model.getContainerClusters().size());
    Set<com.yahoo.vespa.model.Host> containerHosts = model.getContainerClusters().get("foo").getContainers().stream().map(Container::getHost).collect(Collectors.toSet());
    assertEquals(10, containerHosts.size());
    // Check admin clusters
    Admin admin = model.getAdmin();
    Set<com.yahoo.vespa.model.Host> slobrokHosts = admin.getSlobroks().stream().map(Slobrok::getHost).collect(Collectors.toSet());
    assertEquals(3, slobrokHosts.size());
    assertTrue("Slobroks are assigned from container nodes", containerHosts.containsAll(slobrokHosts));
    assertTrue("Logserver is assigned from container nodes", containerHosts.contains(admin.getLogserver().getHost()));
    assertEquals("No in-cluster config servers in a hosted environment", 0, admin.getConfigservers().size());
    assertEquals("No admin cluster controller when multitenant", null, admin.getClusterControllers());
    // Check content clusters
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(3, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default28", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default31", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default54", clusterControllers.getContainers().get(2).getHostName());
    assertEquals(0, cluster.getRootGroup().getNodes().size());
    assertEquals(9, cluster.getRootGroup().getSubgroups().size());
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(3));
    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("default54", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getDistributionKey(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getConfigId(), is("bar/storage/1"));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getDistributionKey(), is(2));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getConfigId(), is("bar/storage/2"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/3"));
    assertEquals("default51", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getDistributionKey(), is(4));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getConfigId(), is("bar/storage/4"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getDistributionKey(), is(5));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getConfigId(), is("bar/storage/5"));
    // ...
    assertEquals("default48", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
    // ...
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getIndex(), is("8"));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().size(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getDistributionKey(), is(24));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getConfigId(), is("bar/storage/24"));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getDistributionKey(), is(25));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getConfigId(), is("bar/storage/25"));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getDistributionKey(), is(26));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getConfigId(), is("bar/storage/26"));
    cluster = model.getContentClusters().get("baz");
    clusterControllers = cluster.getClusterControllers();
    assertEquals(3, clusterControllers.getContainers().size());
    assertEquals("baz-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default02", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default27", clusterControllers.getContainers().get(2).getHostName());
    assertEquals(0, cluster.getRootGroup().getNodes().size());
    assertEquals(27, cluster.getRootGroup().getSubgroups().size());
    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("baz/storage/0"));
    assertEquals("default27", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    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("baz/storage/1"));
    assertEquals("default26", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    // ...
    assertEquals("default25", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
    // ...
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getIndex(), is("26"));
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getDistributionKey(), is(26));
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getConfigId(), is("baz/storage/26"));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Admin(com.yahoo.vespa.model.admin.Admin) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 92 with VespaModel

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

the class ModelProvisioningTest method require_that_config_override_and_explicit_proton_tuning_have_precedence_over_default_node_flavor_tuning.

@Test
public void require_that_config_override_and_explicit_proton_tuning_have_precedence_over_default_node_flavor_tuning() {
    String services = joinLines("<?xml version='1.0' encoding='utf-8' ?>", "<services>", "  <content version='1.0' id='test'>", "    <config name='vespa.config.search.core.proton'>", "      <flush><memory><maxtlssize>2000</maxtlssize></memory></flush>", "    </config>", "    <documents>", "      <document type='type1' mode='index'/>", "    </documents>", "    <nodes count='1' flavor='content-test-flavor'/>", "    <engine>", "      <proton>", "        <tuning>", "          <searchnode>", "            <flushstrategy>", "              <native>", "                <total>", "                  <maxmemorygain>1000</maxmemorygain>", "                </total>", "              </native>", "            </flushstrategy>", "          </searchnode>", "        </tuning>", "      </proton>", "    </engine>", "  </content>", "</services>");
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts("default", 1);
    tester.addHosts(createFlavorFromMemoryAndDisk("content-test-flavor", 128, 100), 1);
    VespaModel model = tester.createModel(services, true, 0);
    ContentSearchCluster cluster = model.getContentClusters().get("test").getSearch();
    ProtonConfig cfg = getProtonConfig(model, cluster.getSearchNodes().get(0).getConfigId());
    // from config override
    assertEquals(2000, cfg.flush().memory().maxtlssize());
    // from explicit tuning
    assertEquals(1000, cfg.flush().memory().maxmemory());
    // from default node flavor tuning
    assertEquals((long) 16 * GB, cfg.flush().memory().each().maxmemory());
}
Also used : ContentSearchCluster(com.yahoo.vespa.model.content.ContentSearchCluster) ProtonConfig(com.yahoo.vespa.config.search.core.ProtonConfig) VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 93 with VespaModel

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

the class ModelProvisioningTest method testSlobroksClustersAreExpandedToIncludeRetiredNodes.

@Test
public void testSlobroksClustersAreExpandedToIncludeRetiredNodes() {
    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>" + "</services>";
    int numberOfHosts = 10;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true, "default09");
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check slobroks clusters
    assertEquals("Includes retired node", 1 + 3, model.getAdmin().getSlobroks().size());
    assertEquals("default01", model.getAdmin().getSlobroks().get(0).getHostName());
    assertEquals("default02", model.getAdmin().getSlobroks().get(1).getHostName());
    assertEquals("default10", model.getAdmin().getSlobroks().get(2).getHostName());
    assertEquals("Included in addition because it is retired", "default09", model.getAdmin().getSlobroks().get(3).getHostName());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 94 with VespaModel

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

the class ModelProvisioningTest method testMultitenantButNotHosted.

/**
 * Recreate the combination used in some factory tests
 */
@Test
public void testMultitenantButNotHosted() {
    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>";
    VespaModel model = createNonProvisionedMultitenantModel(services);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(1));
    ContentCluster content = model.getContentClusters().get("storage");
    assertEquals(2, content.getRootGroup().getNodes().size());
    ContainerCluster controller = content.getClusterControllers();
    assertEquals(1, controller.getContainers().size());
}
Also used : 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 95 with VespaModel

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

the class ModelProvisioningTest method test2ContentNodesProduces1ClusterController.

@Test
public void test2ContentNodesProduces1ClusterController() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <content version='1.0' id='bar'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2'/>" + "  </content>" + "</services>";
    int numberOfHosts = 2;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    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)

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