summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-09-23 16:18:40 +0200
committerGitHub <noreply@github.com>2019-09-23 16:18:40 +0200
commit8070bd0d1a0cd0eda908cc32fc2506d247ec2f67 (patch)
tree5bc2817ade8d96ae87ede69000ed8de09306a9be /config-model/src/test/java
parent463bb2a8400f0fd9370f155454c385eb98be2acb (diff)
Revert "Revert "Balder/remove tld from config model rebased""
Diffstat (limited to 'config-model/src/test/java')
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java111
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java62
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java44
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java47
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java130
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/MultilevelDispatchTest.java382
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/TldTest.java146
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/utils/DispatchUtils.java35
8 files changed, 120 insertions, 837 deletions
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
index 535048eafa3..dfd2fe00d46 100644
--- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
@@ -7,13 +7,10 @@ import com.yahoo.config.model.api.container.ContainerServiceType;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.config.provision.ClusterMembership;
-import com.yahoo.config.provision.Flavor;
import com.yahoo.config.provision.NodeResources;
import com.yahoo.config.provision.Zone;
-import com.yahoo.config.provisioning.FlavorsConfig;
import com.yahoo.container.core.ApplicationMetadataConfig;
import com.yahoo.search.config.QrStartConfig;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.model.HostResource;
import com.yahoo.vespa.model.HostSystem;
@@ -22,14 +19,12 @@ import com.yahoo.vespa.model.admin.Admin;
import com.yahoo.vespa.model.admin.Logserver;
import com.yahoo.vespa.model.admin.Slobrok;
import com.yahoo.vespa.model.admin.clustercontroller.ClusterControllerContainerCluster;
-import com.yahoo.vespa.model.container.ApplicationContainer;
import com.yahoo.vespa.model.container.ApplicationContainerCluster;
import com.yahoo.vespa.model.container.Container;
import com.yahoo.vespa.model.container.ContainerCluster;
import com.yahoo.vespa.model.content.ContentSearchCluster;
import com.yahoo.vespa.model.content.StorageNode;
import com.yahoo.vespa.model.content.cluster.ContentCluster;
-import com.yahoo.vespa.model.search.Dispatch;
import com.yahoo.vespa.model.search.SearchNode;
import com.yahoo.vespa.model.test.VespaModelTester;
import com.yahoo.vespa.model.test.utils.ApplicationPackageUtils;
@@ -38,7 +33,6 @@ import org.junit.Ignore;
import org.junit.Test;
import java.io.StringReader;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -1019,10 +1013,6 @@ public class ModelProvisioningTest {
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"));
- PartitionsConfig.Builder partBuilder = new PartitionsConfig.Builder();
- cluster.getSearch().getIndexed().getTLDs().get(0).getConfig(partBuilder);
- PartitionsConfig partCFg = partBuilder.build();
- assertEquals(4, partCFg.dataset(0).searchablecopies());
}
@Test
@@ -1605,97 +1595,6 @@ public class ModelProvisioningTest {
return modelCreatorWithMockPkg.create(false, deployState);
}
- @Test
- public void testThatTldConfigIdsAreDeterministic() {
- String services =
- "<?xml version='1.0' encoding='utf-8' ?>\n" +
- "<services>" +
- " <admin version='4.0'/>" +
- " <container version='1.0' id='jdisc0'>" +
- " <search/>" +
- " <nodes count='2'/>" +
- " </container>" +
- " <container version='1.0' id='jdisc1'>" +
- " <search/>" +
- " <nodes count='2'/>" +
- " </container>" +
- " <content version='1.0' id='content0'>" +
- " <redundancy>2</redundancy>" +
- " <documents>" +
- " <document type='type1' mode='index'/>" +
- " </documents>" +
- " <nodes count='2'/>" +
- " </content>" +
- " <content version='1.0' id='content1'>" +
- " <redundancy>2</redundancy>" +
- " <documents>" +
- " <document type='type1' mode='index'/>" +
- " </documents>" +
- " <nodes count='2'/>" +
- " </content>" +
- "</services>";
-
- int numberOfHosts = 8;
-
- {
- VespaModelTester tester = new VespaModelTester();
- tester.addHosts(numberOfHosts);
- // Nodes used will be default0, default1, .. and so on.
- VespaModel model = tester.createModel(services, true);
- assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
-
- Map<String, ContentCluster> contentClusters = model.getContentClusters();
- assertEquals(2, contentClusters.size());
-
- checkThatTldAndContainerRunningOnSameHostHaveSameId(
- model.getContainerClusters().values(),
- model.getContentClusters().values(),
- 0);
- }
-
- {
- VespaModelTester tester = new VespaModelTester();
- tester.addHosts(numberOfHosts + 1);
- // Start numbering nodes with index 1 and retire first node
- // Nodes used will be default1, default2, .. and so on. Containers will start with index 1, not 0 as they are in the test above
- VespaModel model = tester.createModel(services, true, 1, "default0");
- assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
-
- Map<String, ContentCluster> contentClusters = model.getContentClusters();
- assertEquals(2, contentClusters.size());
-
- checkThatTldAndContainerRunningOnSameHostHaveSameId(
- model.getContainerClusters().values(),
- model.getContentClusters().values(),
- 1);
- }
- }
-
- private void checkThatTldAndContainerRunningOnSameHostHaveSameId(Collection<ApplicationContainerCluster> containerClusters,
- Collection<ContentCluster> contentClusters,
- int startIndexForContainerIds) {
- for (ContentCluster contentCluster : contentClusters) {
- String contentClusterName = contentCluster.getName();
- int i = 0;
- for (ApplicationContainerCluster containerCluster : containerClusters) {
- String containerClusterName = containerCluster.getName();
- for (int j = 0; j < 2; j++) {
- Dispatch tld = contentCluster.getSearch().getIndexed().getTLDs().get(2 * i + j);
- ApplicationContainer container = containerCluster.getContainers().get(j);
- int containerConfigIdIndex = j + startIndexForContainerIds;
-
- assertEquals(container.getHostName(), tld.getHostname());
- assertEquals(contentClusterName + "/search/cluster." + contentClusterName + "/tlds/" +
- containerClusterName + "." + containerConfigIdIndex + ".tld." + containerConfigIdIndex,
- tld.getConfigId());
- assertEquals(containerClusterName + "/" + "container." + containerConfigIdIndex,
- container.getConfigId());
- }
- i++;
- }
- }
- }
-
private int physicalMemoryPercentage(ContainerCluster cluster) {
QrStartConfig.Builder b = new QrStartConfig.Builder();
cluster.getConfig(b);
@@ -1725,11 +1624,6 @@ public class ModelProvisioningTest {
assertEquals(40, getProtonConfig(cluster, 1).hwinfo().disk().writespeed(), 0.001);
}
- private static Flavor createFlavorFromDiskSetting(String name, boolean fastDisk) {
- return new Flavor(new FlavorsConfig.Flavor(new FlavorsConfig.Flavor.Builder().
- name(name).fastDisk(fastDisk)));
- }
-
private static ProtonConfig getProtonConfig(ContentSearchCluster cluster, int searchNodeIdx) {
ProtonConfig.Builder builder = new ProtonConfig.Builder();
List<SearchNode> searchNodes = cluster.getSearchNodes();
@@ -1787,11 +1681,6 @@ public class ModelProvisioningTest {
private static long GB = 1024 * 1024 * 1024;
- private static Flavor createFlavorFromMemoryAndDisk(String name, int memoryGb, int diskGb) {
- return new Flavor(new FlavorsConfig.Flavor(new FlavorsConfig.Flavor.Builder().
- name(name).minMainMemoryAvailableGb(memoryGb).minDiskAvailableGb(diskGb)));
- }
-
private static ProtonConfig getProtonConfig(VespaModel model, String configId) {
ProtonConfig.Builder builder = new ProtonConfig.Builder();
model.getConfig(builder, configId);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java
index 567e54ed4c4..a7ab9e02a79 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/ContentBuilderTest.java
@@ -12,7 +12,6 @@ import com.yahoo.text.StringUtilities;
import com.yahoo.vespa.config.ConfigDefinitionKey;
import com.yahoo.vespa.config.ConfigPayloadBuilder;
import com.yahoo.vespa.config.GenericConfig;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.model.HostResource;
import com.yahoo.vespa.model.Service;
@@ -21,7 +20,6 @@ import com.yahoo.vespa.model.content.ContentSearchCluster;
import com.yahoo.vespa.model.content.cluster.ContentCluster;
import com.yahoo.vespa.model.content.engines.ProtonEngine;
import com.yahoo.vespa.model.search.AbstractSearchCluster;
-import com.yahoo.vespa.model.search.Dispatch;
import com.yahoo.vespa.model.search.IndexedSearchCluster;
import com.yahoo.vespa.model.search.SearchNode;
import com.yahoo.vespa.model.search.StreamingSearchCluster;
@@ -172,25 +170,11 @@ public class ContentBuilderTest extends DomBuilderTest {
assertEquals("clu/storage/0", c.getRootGroup().getNodes().get(0).getConfigId()); // Due to reuse.
assertEquals(1, c.getRoot().getHostSystem().getHosts().size());
HostResource h = c.getRoot().getHostSystem().getHost("mockhost");
- String [] expectedServices = {"logd", "configproxy","config-sentinel", "qrserver", "storagenode", "searchnode", "distributor", "topleveldispatch", "transactionlogserver"};
-// TODO assertServices(h, expectedServices);
+ String [] expectedServices = {"configserver", "logserver", "logd", "container-clustercontroller", "metricsproxy-container", "slobrok", "configproxy","config-sentinel", "qrserver", "storagenode", "searchnode", "distributor", "transactionlogserver"};
+ assertServices(h, expectedServices);
assertEquals("clu/storage/0", h.getService("storagenode").getConfigId());
assertEquals("clu/search/cluster.clu/0", h.getService("searchnode").getConfigId());
assertEquals("clu/distributor/0", h.getService("distributor").getConfigId());
- assertEquals("clu/search/cluster.clu/tlds/qrc.0.tld.0", h.getService("topleveldispatch").getConfigId());
- //assertEquals("tcp/node0:19104", h.getService("topleveldispatch").getConfig("partitions", "").innerArray("dataset").value("0").innerArray("engine").value("0").getString("name_and_port"));
- PartitionsConfig partitionsConfig = new PartitionsConfig((PartitionsConfig.Builder)
- m.getConfig(new PartitionsConfig.Builder(), "clu/search/cluster.clu/tlds/qrc.0.tld.0"));
- assertTrue(partitionsConfig.dataset(0).engine(0).name_and_port().startsWith("tcp/node0:191"));
- }
-
- @Test
- public void testConfigIdLookup() {
- VespaModel m = new VespaModelCreatorWithMockPkg(createAppWithMusic(getHosts(), getBasicServices())).create();
-
- PartitionsConfig partitionsConfig = new PartitionsConfig((PartitionsConfig.Builder)
- m.getConfig(new PartitionsConfig.Builder(), "clu/search/cluster.clu/tlds/qrc.0.tld.0"));
- assertTrue(partitionsConfig.dataset(0).engine(0).name_and_port().startsWith("tcp/node0:191"));
}
@Test
@@ -198,9 +182,6 @@ public class ContentBuilderTest extends DomBuilderTest {
String services = getServices("<node hostalias='mockhost' distribution-key='0'/>" +
"<node hostalias='mockhost' distribution-key='1'/>");
VespaModel m = new VespaModelCreatorWithMockPkg(createAppWithMusic(getHosts(), services)).create();
- PartitionsConfig partitionsConfig = new PartitionsConfig((PartitionsConfig.Builder)
- m.getConfig(new PartitionsConfig.Builder(), "clu/search/cluster.clu/tlds/qrc.0.tld.0"));
- assertTrue(partitionsConfig.dataset(0).engine(0).name_and_port().startsWith("tcp/node0:191"));
IndexedSearchCluster sc = m.getContentClusters().get("clu").getSearch().getIndexed();
assertEquals(2, sc.getSearchNodeCount());
}
@@ -711,45 +692,6 @@ public class ContentBuilderTest extends DomBuilderTest {
}
@Test
- public void requireOneTldPerSearchContainer() {
- ContentCluster content = createContent(
- " <content version='1.0' id='storage'>\n" +
- " <redundancy>1</redundancy>\n" +
- " <documents>" +
- " <document type='music' mode='index'/>" +
- " </documents>" +
- " <group>\n" +
- " <node hostalias='mockhost' distribution-key='0' />\n" +
- " </group>\n" +
- " </content>\n" +
- " <container version='1.0' id='qrc'>" +
- " <search/>" +
- " <nodes>" +
- " <node hostalias='mockhost' />" +
- " </nodes>" +
- " </container>" +
- " <container version='1.0' id='qrc2'>" +
- " <http>" +
- " <server id ='server1' port='5000' />" +
- " </http>" +
- " <search/>" +
- " <nodes>" +
- " <node hostalias='mockhost' />" +
- " <node hostalias='mockhost2' />" +
- " </nodes>" +
- " </container>"
-
- );
- List<Dispatch> tlds = content.getSearch().getIndexed().getTLDs();
-
- assertThat(tlds.get(0).getHostname(), is("node0"));
- assertThat(tlds.get(1).getHostname(), is("node0"));
- assertThat(tlds.get(2).getHostname(), is("node1"));
-
- assertThat(tlds.size(), is(3));
- }
-
- @Test
@Ignore
public void ensureOverrideAppendedOnlyOnce() {
ContentCluster content = createContent(
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
index d98d1da9d2a..d6579ba88d4 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java
@@ -18,7 +18,7 @@ import com.yahoo.vespa.config.content.StorDistributionConfig;
import com.yahoo.vespa.config.content.StorFilestorConfig;
import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig;
import com.yahoo.vespa.config.content.core.StorServerConfig;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
+import com.yahoo.vespa.config.search.DispatchConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.container.ContainerCluster;
@@ -271,25 +271,6 @@ public class ContentClusterTest extends ContentBaseTest {
assertEquals(1, cluster.getContainers().size());
}
- private void verifyRoundRobinPropertiesControl(boolean useAdaptiveDispatch) {
- VespaModel model = createEnd2EndOneNode(new TestProperties().setUseAdaptiveDispatch(useAdaptiveDispatch));
-
- ContentCluster cc = model.getContentClusters().get("storage");
- PartitionsConfig.Builder partBuilder = new PartitionsConfig.Builder();
- assertNotNull(cc.getSearch());
- assertNotNull(cc.getSearch().getIndexed());
- assertEquals(1, cc.getSearch().getIndexed().getTLDs().size());
- cc.getSearch().getIndexed().getTLDs().get(0).getConfig(partBuilder);
- PartitionsConfig partitionsConfig = new PartitionsConfig(partBuilder);
- assertFalse(useAdaptiveDispatch == partitionsConfig.dataset(0).useroundrobinforfixedrow());
- }
-
- @Test
- public void default_dispatch_controlled_by_properties() {
- verifyRoundRobinPropertiesControl(false);
- verifyRoundRobinPropertiesControl(true);
- }
-
@Test
public void testSearchTuning() {
String xml =
@@ -950,4 +931,27 @@ public class ContentClusterTest extends ContentBaseTest {
assertEquals(distributionBits, storDistributormanagerConfig.minsplitcount());
}
+ private void verifyRoundRobinPropertiesControl(boolean useAdaptiveDispatch) {
+ VespaModel model = createEnd2EndOneNode(new TestProperties().setUseAdaptiveDispatch(useAdaptiveDispatch));
+
+ ContentCluster cc = model.getContentClusters().get("storage");
+ DispatchConfig.Builder builder = new DispatchConfig.Builder();
+ cc.getSearch().getConfig(builder);
+
+ DispatchConfig cfg = new DispatchConfig(builder);
+ if (useAdaptiveDispatch) {
+ assertEquals(DispatchConfig.DistributionPolicy.ADAPTIVE, cfg.distributionPolicy());
+ } else {
+ assertEquals(DispatchConfig.DistributionPolicy.ROUNDROBIN, cfg.distributionPolicy());
+ }
+
+ }
+
+ @Test
+ public void default_dispatch_controlled_by_properties() {
+ verifyRoundRobinPropertiesControl(false);
+ verifyRoundRobinPropertiesControl(true);
+ }
+
+
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java
index afedbaea779..d290d4ec953 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionTest.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.model.content;
import com.yahoo.vespa.config.content.StorDistributionConfig;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
import com.yahoo.config.model.test.MockRoot;
import com.yahoo.vespa.model.Host;
import com.yahoo.vespa.model.HostResource;
@@ -21,8 +20,6 @@ import static com.yahoo.config.model.test.TestUtil.joinLines;
import static org.hamcrest.Matchers.containsString;
import static com.yahoo.vespa.model.content.utils.ContentClusterUtils.createCluster;
import static com.yahoo.vespa.model.content.utils.ContentClusterUtils.createClusterXml;
-import static com.yahoo.vespa.model.search.utils.DispatchUtils.assertEngine;
-import static com.yahoo.vespa.model.search.utils.DispatchUtils.getDataset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
@@ -35,19 +32,13 @@ import static org.junit.Assert.assertTrue;
*/
public class IndexedHierarchicDistributionTest {
- private ContentCluster addDispatcher(ContentCluster c) {
- MockRoot root = new MockRoot("");
- c.getSearch().getIndexed().addTld(root.deployLogger(), new SimpleConfigProducer(root, ""), new HostResource(new Host(root, "mockhost")));
- return c;
- }
-
private ContentCluster getOneGroupCluster() throws Exception {
String groupXml = joinLines(" <group>",
" <node distribution-key='0' hostalias='mockhost'/>",
" <node distribution-key='1' hostalias='mockhost'/>",
" <node distribution-key='2' hostalias='mockhost'/>",
" </group>", "");
- return addDispatcher(createCluster(createClusterXml(groupXml, 2, 2)));
+ return createCluster(createClusterXml(groupXml, 2, 2));
}
private String getTwoGroupsXml(String partitions) {
@@ -67,11 +58,11 @@ public class IndexedHierarchicDistributionTest {
}
private ContentCluster getTwoGroupsCluster() throws Exception {
- return addDispatcher(createCluster(createClusterXml(getTwoGroupsXml("3|*"), 6, 6)));
+ return createCluster(createClusterXml(getTwoGroupsXml("3|*"), 6, 6));
}
private ContentCluster getTwoGroupsCluster(int redundancy, int searchableCopies, String partitions) throws Exception {
- return addDispatcher(createCluster(createClusterXml(getTwoGroupsXml(partitions), redundancy, searchableCopies)));
+ return createCluster(createClusterXml(getTwoGroupsXml(partitions), redundancy, searchableCopies));
}
private void assertSearchNode(int expRowId, int expPartitionId, int expDistibutionKey, SearchNode node) {
@@ -98,20 +89,6 @@ public class IndexedHierarchicDistributionTest {
}
@Test
- public void requireThatDispatcherIsCorrectWithOneGroup() throws Exception {
- ContentCluster c = getOneGroupCluster();
- PartitionsConfig.Dataset dataset = getDataset(c.getSearch().getIndexed().getTLDs().get(0));
-
- assertEquals(3, dataset.numparts());
- assertEquals(PartitionsConfig.Dataset.Querydistribution.AUTOMATIC, dataset.querydistribution());
- List<PartitionsConfig.Dataset.Engine> engines = dataset.engine();
- assertEquals(3, engines.size());
- assertEngine(0, 0, engines.get(0));
- assertEngine(0, 1, engines.get(1));
- assertEngine(0, 2, engines.get(2));
- }
-
- @Test
public void requireThatActivePerLeafGroupIsDefaultWithOneGroup() throws Exception {
ContentCluster c = getOneGroupCluster();
assertFalse(getStorDistributionConfig(c).active_per_leaf_group());
@@ -132,24 +109,6 @@ public class IndexedHierarchicDistributionTest {
}
@Test
- public void requireThatDispatcherIsCorrectWithTwoGroups() throws Exception {
- ContentCluster c = getTwoGroupsCluster();
- PartitionsConfig.Dataset dataset = getDataset(c.getSearch().getIndexed().getTLDs().get(0));
-
- assertEquals(3, dataset.numparts());
- assertEquals(2, dataset.maxnodesdownperfixedrow());
- assertEquals(PartitionsConfig.Dataset.Querydistribution.FIXEDROW, dataset.querydistribution());
- List<PartitionsConfig.Dataset.Engine> engines = dataset.engine();
- assertEquals(6, engines.size());
- assertEngine(0, 0, engines.get(0));
- assertEngine(1, 0, engines.get(1));
- assertEngine(0, 1, engines.get(2));
- assertEngine(1, 1, engines.get(3));
- assertEngine(0, 2, engines.get(4));
- assertEngine(1, 2, engines.get(5));
- }
-
- @Test
public void requireThatActivePerLeafGroupIsSetWithTwoGroups() throws Exception {
ContentCluster c = getTwoGroupsCluster();
assertTrue(getStorDistributionConfig(c).active_per_leaf_group());
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java
index 4fadea74feb..4291c68eff8 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java
@@ -4,10 +4,9 @@ package com.yahoo.vespa.model.content.cluster;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.model.test.TestDriver;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
+import com.yahoo.vespa.config.search.DispatchConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.model.content.Content;
-import com.yahoo.vespa.model.search.Dispatch;
import com.yahoo.vespa.model.search.IndexedSearchCluster;
import com.yahoo.vespa.model.test.utils.ApplicationPackageUtils;
import org.junit.Test;
@@ -16,6 +15,7 @@ import java.util.List;
import static com.yahoo.config.model.test.TestUtil.joinLines;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
*/
public class ClusterTest {
+ static final double DELTA = 1E-12;
@Test
public void requireThatContentSearchIsApplied() {
ContentCluster cluster = newContentCluster(joinLines("<search>",
@@ -32,10 +33,19 @@ public class ClusterTest {
"</search>"));
IndexedSearchCluster searchCluster = cluster.getSearch().getIndexed();
assertNotNull(searchCluster);
- assertEquals(1.1, searchCluster.getQueryTimeout(), 1E-6);
- assertEquals(2.3, searchCluster.getVisibilityDelay(), 1E-6);
+ assertEquals(1.1, searchCluster.getQueryTimeout(), DELTA);
+ assertEquals(2.3, searchCluster.getVisibilityDelay(), DELTA);
ProtonConfig proton = getProtonConfig(cluster);
- assertEquals(searchCluster.getVisibilityDelay(), proton.documentdb(0).visibilitydelay(), 1E-6);
+ assertEquals(searchCluster.getVisibilityDelay(), proton.documentdb(0).visibilitydelay(), DELTA);
+ }
+
+ @Test
+ public void requireThatVisibilityDelayIsZeroForGlobalDocumentType() {
+ ContentCluster cluster = newContentCluster(joinLines("<search>",
+ " <visibility-delay>2.3</visibility-delay>",
+ "</search>"), true);
+ ProtonConfig proton = getProtonConfig(cluster);
+ assertEquals(0.0, proton.documentdb(0).visibilitydelay(), DELTA);
}
@Test
@@ -47,56 +57,93 @@ public class ClusterTest {
" <max-wait-after-coverage-factor>0.58</max-wait-after-coverage-factor>",
" </coverage>",
"</search>"));
- assertEquals(1, cluster.getSearch().getIndexed().getTLDs().size());
- for (Dispatch tld : cluster.getSearch().getIndexed().getTLDs()) {
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- tld.getConfig(builder);
- PartitionsConfig config = new PartitionsConfig(builder);
- assertEquals(11.0, config.dataset(0).minimal_searchcoverage(), 1E-6);
- assertEquals(0.23, config.dataset(0).higher_coverage_minsearchwait(), 1E-6);
- assertEquals(0.58, config.dataset(0).higher_coverage_maxsearchwait(), 1E-6);
- assertEquals(2, config.dataset(0).searchablecopies());
- assertTrue(config.dataset(0).useroundrobinforfixedrow());
- }
+ DispatchConfig.Builder builder = new DispatchConfig.Builder();
+ cluster.getSearch().getConfig(builder);
+ DispatchConfig config = new DispatchConfig(builder);
+ assertEquals(11.0, config.minSearchCoverage(), DELTA);
+ assertEquals(0.23, config.minWaitAfterCoverageFactor(), DELTA);
+ assertEquals(0.58, config.maxWaitAfterCoverageFactor(), DELTA);
+ assertEquals(2, config.searchableCopies());
+ assertEquals(DispatchConfig.DistributionPolicy.ROUNDROBIN, config.distributionPolicy());
}
@Test
- public void requireThatDispatchTuningIsApplied() {
+ public void requireThatDispatchTuningIsApplied() {
ContentCluster cluster = newContentCluster(joinLines("<search>", "</search>"),
- joinLines("<tuning>",
- "</tuning>"));
- assertEquals(1, cluster.getSearch().getIndexed().getTLDs().size());
- for (Dispatch tld : cluster.getSearch().getIndexed().getTLDs()) {
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- tld.getConfig(builder);
- PartitionsConfig config = new PartitionsConfig(builder);
- assertEquals(2, config.dataset(0).searchablecopies());
- assertTrue(config.dataset(0).useroundrobinforfixedrow());
- }
+ "",
+ joinLines(
+ "<max-hits-per-partition>77</max-hits-per-partition>",
+ "<dispatch-policy>adaptive</dispatch-policy>",
+ "<min-group-coverage>13</min-group-coverage>",
+ "<min-active-docs-coverage>93</min-active-docs-coverage>",
+ "<use-local-node>true</use-local-node>"),
+ false);
+ DispatchConfig.Builder builder = new DispatchConfig.Builder();
+ cluster.getSearch().getConfig(builder);
+ DispatchConfig config = new DispatchConfig(builder);
+ assertEquals(2, config.searchableCopies());
+ assertEquals(93.0, config.minActivedocsPercentage(), DELTA);
+ assertEquals(13.0, config.minGroupCoverage(), DELTA);
+ assertTrue(config.useLocalNode());
+ assertEquals(DispatchConfig.DistributionPolicy.ADAPTIVE, config.distributionPolicy());
+ assertEquals(77, config.maxHitsPerNode());
}
@Test
- public void requireThatVisibilityDelayIsZeroForGlobalDocumentType() {
- ContentCluster cluster = newContentCluster(joinLines("<search>",
- " <visibility-delay>2.3</visibility-delay>",
- "</search>"), true);
- ProtonConfig proton = getProtonConfig(cluster);
- assertEquals(0.0, proton.documentdb(0).visibilitydelay(), 1E-6);
- }
+ public void requireThatDefaultDispatchConfigIsCorrect() {
+ ContentCluster cluster = newContentCluster(joinLines("<search>", "</search>"),
+ joinLines("<tuning>", "</tuning>"));
+ DispatchConfig.Builder builder = new DispatchConfig.Builder();
+ cluster.getSearch().getConfig(builder);
+ DispatchConfig config = new DispatchConfig(builder);
+ assertEquals(2, config.searchableCopies());
+ assertEquals(DispatchConfig.DistributionPolicy.ROUNDROBIN, config.distributionPolicy());
+ assertEquals(0, config.maxNodesDownPerGroup());
+ assertEquals(1.0, config.maxWaitAfterCoverageFactor(), DELTA);
+ assertEquals(0, config.minWaitAfterCoverageFactor(), DELTA);
+ assertEquals(8, config.numJrtConnectionsPerNode());
+ assertEquals(8, config.numJrtTransportThreads());
+ assertEquals(100.0, config.minSearchCoverage(), DELTA);
+ assertEquals(97.0, config.minActivedocsPercentage(), DELTA);
+ assertEquals(100.0, config.minGroupCoverage(), DELTA);
+ assertFalse(config.useLocalNode());
+ assertEquals(3, config.node().size());
+ assertEquals(0, config.node(0).key());
+ assertEquals(1, config.node(1).key());
+ assertEquals(2, config.node(2).key());
- private static ContentCluster newContentCluster(String contentSearchXml) {
- return newContentCluster(contentSearchXml, "", false);
+ assertEquals(19106, config.node(0).port());
+ assertEquals(19118, config.node(1).port());
+ assertEquals(19130, config.node(2).port());
+
+ assertEquals(19107, config.node(0).fs4port());
+ assertEquals(19119, config.node(1).fs4port());
+ assertEquals(19131, config.node(2).fs4port());
+
+ assertEquals(0, config.node(0).group());
+ assertEquals(0, config.node(1).group());
+ assertEquals(0, config.node(2).group());
+
+ assertEquals("localhost", config.node(0).host());
+ assertEquals("localhost", config.node(1).host());
+ assertEquals("localhost", config.node(2).host());
}
private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml) {
- return newContentCluster(contentSearchXml, searchNodeTuningXml, false);
+ return newContentCluster(contentSearchXml, searchNodeTuningXml, "", false);
+ }
+
+ private static ContentCluster newContentCluster(String contentSearchXml) {
+ return newContentCluster(contentSearchXml, false);
}
private static ContentCluster newContentCluster(String contentSearchXml, boolean globalDocType) {
- return newContentCluster(contentSearchXml, "", globalDocType);
+ return newContentCluster(contentSearchXml, "", "", globalDocType);
}
- private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml, boolean globalDocType) {
+ private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml,
+ String dispatchTuning, boolean globalDocType)
+ {
ApplicationPackage app = new MockApplicationPackage.Builder()
.withHosts(joinLines(
"<hosts>",
@@ -128,6 +175,11 @@ public class ClusterTest {
" <node hostalias='my_host' distribution-key='2' />",
" </group>",
contentSearchXml,
+ " <tuning>",
+ " <dispatch>",
+ dispatchTuning,
+ " </dispatch>",
+ " </tuning>",
" </content>",
"</services>"))
.withSearchDefinitions(ApplicationPackageUtils.generateSearchDefinition("my_document"))
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/MultilevelDispatchTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/MultilevelDispatchTest.java
deleted file mode 100644
index c87774cf692..00000000000
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/MultilevelDispatchTest.java
+++ /dev/null
@@ -1,382 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.search;
-
-import com.yahoo.config.model.producer.AbstractConfigProducer;
-import com.yahoo.config.model.test.MockApplicationPackage;
-import com.yahoo.config.model.test.MockRoot;
-import com.yahoo.config.model.test.TestDriver;
-import com.yahoo.config.model.test.TestRoot;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
-import com.yahoo.vespa.model.Host;
-import com.yahoo.vespa.model.HostResource;
-import com.yahoo.vespa.model.SimpleConfigProducer;
-import com.yahoo.vespa.model.content.DispatchSpec;
-import com.yahoo.vespa.model.content.cluster.ContentCluster;
-import com.yahoo.vespa.model.content.utils.ContentClusterUtils;
-import com.yahoo.vespa.model.search.utils.DispatchUtils;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import static com.yahoo.vespa.model.content.utils.ContentClusterUtils.createClusterXml;
-import static com.yahoo.vespa.model.search.utils.DispatchUtils.getDataset;
-import static com.yahoo.vespa.model.search.utils.DispatchUtils.getFdispatchrcConfig;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-
-/**
- * Unit tests for multi-level dispatchers in an indexed content cluster.
- *
- * @author geirst
- */
-public class MultilevelDispatchTest {
-
- private static class EngineAsserter {
- private List<PartitionsConfig.Dataset.Engine> engines;
- private int engineIdx = 0;
- public EngineAsserter(int numParts, int numEngines, Dispatch dispatch) {
- PartitionsConfig.Dataset dataset = getDataset(dispatch);
- assertEquals(numParts, dataset.numparts());
- assertEquals(PartitionsConfig.Dataset.Querydistribution.AUTOMATIC, dataset.querydistribution());
- engines = dataset.engine();
- assertEquals(numEngines, engines.size());
- }
- EngineAsserter assertEngine(int rowId, int partitionId, String connectSpec) {
- DispatchUtils.assertEngine(rowId, partitionId, connectSpec, engines.get(engineIdx++));
- return this;
- }
- }
-
- private String getGroupXml() {
- return " <group>\n" +
- " <node distribution-key='10' hostalias='mh0'/>\n" +
- " <node distribution-key='11' hostalias='mh1'/>\n" +
- " <node distribution-key='12' hostalias='mh2'/>\n" +
- " <node distribution-key='13' hostalias='mh3'/>\n" +
- " <node distribution-key='14' hostalias='mh4'/>\n" +
- " <node distribution-key='15' hostalias='mh5'/>\n" +
- " </group>\n";
- }
-
- private String getSimpleDispatchXml() {
- return " <dispatch>\n" +
- " <num-dispatch-groups>2</num-dispatch-groups>\n" +
- " </dispatch>\n";
- }
-
- private String getDispatchXml() {
- return " <dispatch>\n" +
- " <group>\n" +
- " <node distribution-key='10'/>\n" +
- " <node distribution-key='12'/>\n" +
- " <node distribution-key='14'/>\n" +
- " </group>\n" +
- " <group>\n" +
- " <node distribution-key='11'/>\n" +
- " <node distribution-key='13'/>\n" +
- " <node distribution-key='15'/>\n" +
- " </group>\n" +
- " </dispatch>\n";
- }
-
- private ContentCluster createCluster(String dispatchXml) throws Exception {
- String[] hosts = {"mh0", "mh1", "mh2", "mh3", "mh4", "mh5"};
- MockRoot root = ContentClusterUtils.createMockRoot(hosts);
- ContentCluster cluster = ContentClusterUtils.createCluster(createClusterXml(getGroupXml(), Optional.of(dispatchXml), 1, 1), root);
-
- AbstractConfigProducer<Dispatch> dispatchParent = new SimpleConfigProducer<>(root, "tlds");
- HostResource hostResource = new HostResource(new Host(root, "mockhost"));
- IndexedSearchCluster index = cluster.getSearch().getIndexed();
- index.addTld(root.deployLogger(), dispatchParent, hostResource);
- index.setupDispatchGroups(root.deployLogger());
-
- root.freezeModelTopology();
- cluster.validate();
- return cluster;
- }
-
- private List<Dispatch> getDispatchers(Dispatch tld) {
- DispatchGroup group = tld.getDispatchGroup();
- List<Dispatch> dispatchers = new ArrayList<>();
- for (SearchInterface dispatch : group.getSearchersIterable()) {
- dispatchers.add((Dispatch)dispatch);
- }
- return dispatchers;
- }
-
- private void assertDispatchAndSearchNodes(int partId, Dispatch[] dispatchers, String[] connectSpecs, SearchNode[] searchNodes) {
- assertEquals(dispatchers.length, connectSpecs.length);
- assertEquals(connectSpecs.length, searchNodes.length);
- int searchNodeIdx = 0;
- for (int rowId = 0; rowId < dispatchers.length; ++rowId) {
- assertDispatchAndSearchNodes(rowId, partId, searchNodes[searchNodeIdx++].getDistributionKey(),
- dispatchers[rowId], connectSpecs, searchNodes);
- }
- }
-
- private void assertDispatchAndSearchNodes(int expRowId, int expPartId, int expDistributionKey, Dispatch dispatch, String[] connectSpecs, SearchNode[] searchNodes) {
- assertEquals(expRowId, dispatch.getNodeSpec().groupIndex());
- assertEquals(expPartId, dispatch.getNodeSpec().partitionId());
- assertEquals("mycluster/search/cluster.mycluster/dispatchers/dispatch." + expDistributionKey, dispatch.getConfigId());
- assertEquals(expPartId, getFdispatchrcConfig(dispatch).partition());
- assertEquals(1, getFdispatchrcConfig(dispatch).dispatchlevel());
-
- int numEngines = connectSpecs.length;
- EngineAsserter ea = new EngineAsserter(numEngines, numEngines, dispatch);
- for (int i = 0; i < numEngines; ++i) {
- ea.assertEngine(0, i, connectSpecs[i]);
- assertEquals(i, searchNodes[i].getNodeSpec().partitionId());
- }
- }
-
- @Test
- public void requireThatDispatchGroupsCanBeAutomaticallySetup() throws Exception {
- ContentCluster cr = createCluster(getSimpleDispatchXml());
- IndexedSearchCluster ix = cr.getSearch().getIndexed();
- Dispatch tld = cr.getSearch().getIndexed().getTLDs().get(0);
-
- assertEquals("tlds/tld.0", tld.getConfigId());
- assertEquals(0, getFdispatchrcConfig(tld).dispatchlevel());
- new EngineAsserter(2, 6, tld).
- assertEngine(0, 0, "tcp/mh0:19113").
- assertEngine(1, 0, "tcp/mh1:19113").
- assertEngine(2, 0, "tcp/mh2:19113").
- assertEngine(0, 1, "tcp/mh3:19113").
- assertEngine(1, 1, "tcp/mh4:19113").
- assertEngine(2, 1, "tcp/mh5:19113");
-
- List<Dispatch> ds = getDispatchers(tld);
- assertEquals(6, ds.size());
- { // dispatch group 1
- Dispatch[] dispatchers = {ds.get(0), ds.get(1), ds.get(2)};
- String[] specs = {"tcp/mh0:19104", "tcp/mh1:19104", "tcp/mh2:19104"};
- SearchNode[] searchNodes = {ix.getSearchNode(0), ix.getSearchNode(1), ix.getSearchNode(2)};
- assertDispatchAndSearchNodes(0, dispatchers, specs, searchNodes);
- }
- { // dispatch group 2
- Dispatch[] dispatchers = {ds.get(3), ds.get(4), ds.get(5)};
- String[] specs = {"tcp/mh3:19104", "tcp/mh4:19104", "tcp/mh5:19104"};
- SearchNode[] searchNodes = {ix.getSearchNode(3), ix.getSearchNode(4), ix.getSearchNode(5)};
- assertDispatchAndSearchNodes(1, dispatchers, specs, searchNodes);
- }
- }
-
- @Test
- public void requireThatMaxHitsIsScaled() throws Exception {
- ContentCluster cr = createCluster(getSimpleDispatchXml() + getMaxhitsTuning());
- Dispatch tld = cr.getSearch().getIndexed().getTLDs().get(0);
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- tld.getConfig(builder);
- PartitionsConfig config = new PartitionsConfig(builder);
- assertThat(config.dataset().size(), is(1));
- assertThat(config.dataset(0).maxhitspernode(), is(300));
- for (Dispatch dispatch : getDispatchers(tld)) {
- PartitionsConfig.Builder b = new PartitionsConfig.Builder();
- dispatch.getConfig(b);
- PartitionsConfig c= new PartitionsConfig(b);
- assertThat(c.dataset().size(), is(1));
- assertThat(c.dataset(0).maxhitspernode(), is(100));
- }
- }
-
- private String getMaxhitsTuning() {
- return "<tuning>" +
- " <dispatch>" +
- " <max-hits-per-partition>100</max-hits-per-partition>" +
- " </dispatch>" +
- "</tuning>";
- }
-
-
- @Test
- public void requireThatSearchCoverageIsSetInMultilevelSetup() throws Exception {
- ContentCluster cr = createCluster(getSimpleDispatchXml() + getCoverage());
- Dispatch tld = cr.getSearch().getIndexed().getTLDs().get(0);
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- tld.getConfig(builder);
- PartitionsConfig config = new PartitionsConfig(builder);
- assertThat(config.dataset().size(), is(1));
- assertEquals(95.0, config.dataset(0).minimal_searchcoverage(), 0.1);
- for (Dispatch dispatch : getDispatchers(tld)) {
- PartitionsConfig.Builder b = new PartitionsConfig.Builder();
- dispatch.getConfig(b);
- PartitionsConfig c= new PartitionsConfig(b);
- assertThat(c.dataset().size(), is(1));
- assertEquals(95.0, c.dataset(0).minimal_searchcoverage(), 0.1);
- }
- }
-
- @Test
- public void requireThatSearchCoverageIsSetInSingleLevelSetup() {
- TestRoot root = new TestDriver(true).buildModel(new MockApplicationPackage.Builder()
- .withServices("<services version='1.0'>" +
- "<content id='stateful' version='1.0'>" +
- " <redundancy>1</redundancy>" +
- " <documents><document mode='index' type='music' /></documents>" +
- " <nodes>" +
- " <node distribution-key='1' hostalias='mockroot' />" +
- " </nodes>" +
- " <search><coverage><minimum>0.95</minimum></coverage></search>" +
- "</content>" +
- "<container id='foo' version='1.0'>" +
- " <search />" +
- " <nodes><node hostalias='mockroot' /></nodes>" +
- "</container>" +
- "</services>")
- .withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION)
- .build());
- PartitionsConfig config = root.getConfig(PartitionsConfig.class, "stateful/search/cluster.stateful/tlds/foo.0.tld.0");
- assertThat(config.dataset().size(), is(1));
- assertEquals(95.0, config.dataset(0).minimal_searchcoverage(), 0.1);
- }
-
- private String getCoverage() {
- return "<search>" +
- " <coverage>" +
- " <minimum>0.95</minimum>" +
- " </coverage>" +
- "</search>";
- }
-
- @Test
- public void requireThatDispatchGroupsCanBeExplicitlySpecified() throws Exception {
- ContentCluster cr = createCluster(getDispatchXml());
- IndexedSearchCluster ix = cr.getSearch().getIndexed();
- Dispatch tld = cr.getSearch().getIndexed().getTLDs().get(0);
-
- assertEquals("tlds/tld.0", tld.getConfigId());
- assertEquals(0, getFdispatchrcConfig(tld).dispatchlevel());
- new EngineAsserter(2, 6, tld).
- assertEngine(0, 0, "tcp/mh0:19113").
- assertEngine(1, 0, "tcp/mh2:19113").
- assertEngine(2, 0, "tcp/mh4:19113").
- assertEngine(0, 1, "tcp/mh1:19113").
- assertEngine(1, 1, "tcp/mh3:19113").
- assertEngine(2, 1, "tcp/mh5:19113");
-
- List<Dispatch> ds = getDispatchers(tld);
- assertEquals(6, ds.size());
- { // dispatch group 1
- Dispatch[] dispatchers = {ds.get(0), ds.get(1), ds.get(2)};
- String[] specs = {"tcp/mh0:19104", "tcp/mh2:19104", "tcp/mh4:19104"};
- SearchNode[] searchNodes = {ix.getSearchNode(0), ix.getSearchNode(2), ix.getSearchNode(4)};
- assertDispatchAndSearchNodes(0, dispatchers, specs, searchNodes);
- }
- { // dispatch group 2
- Dispatch[] dispatchers = {ds.get(3), ds.get(4), ds.get(5)};
- String[] specs = {"tcp/mh1:19104", "tcp/mh3:19104", "tcp/mh5:19104"};
- SearchNode[] searchNodes = {ix.getSearchNode(1), ix.getSearchNode(3), ix.getSearchNode(5)};
- assertDispatchAndSearchNodes(1, dispatchers, specs, searchNodes);
- }
- }
-
- @Test
- public void requireThatUnevenDispatchGroupsCanBeCreated() {
- List<SearchNode> searchNodes = createSearchNodes(5);
- List<DispatchSpec.Group> groups = DispatchGroupBuilder.createDispatchGroups(searchNodes, 3);
- assertEquals(3, groups.size());
- assertGroup(new int[]{0, 1}, groups.get(0));
- assertGroup(new int[]{2, 3}, groups.get(1));
- assertGroup(new int[]{4}, groups.get(2));
- }
-
- private List<SearchNode> createSearchNodes(int numNodes) {
- List<SearchNode> searchNodes = new ArrayList<>();
- MockRoot root = new MockRoot("");
- for (int i = 0; i < numNodes; ++i) {
- searchNodes.add(SearchNode.create(root, "mynode" + i, i, new NodeSpec(0, i), "mycluster", null, false,
- Optional.empty(), Optional.empty(), root.getDeployState().isHosted()));
- }
- return searchNodes;
- }
-
- private void assertGroup(int[] nodes, DispatchSpec.Group group) {
- assertEquals(nodes.length, group.getNodes().size());
- for (int i = 0; i < nodes.length; ++i) {
- assertEquals(nodes[i], group.getNodes().get(i).getDistributionKey());
- }
- }
-
- private ContentCluster createIllegalSetupWithMultipleNodeReferences() throws Exception {
- String dispatchXml = " <dispatch>\n" +
- " <group>\n" +
- " <node distribution-key='10'/>\n" +
- " <node distribution-key='11'/>\n" +
- " <node distribution-key='12'/>\n" +
- " </group>\n" +
- " <group>\n" +
- " <node distribution-key='12'/>\n" +
- " <node distribution-key='13'/>\n" +
- " <node distribution-key='14'/>\n" +
- " </group>\n" +
- " </dispatch>\n";
- return createCluster(dispatchXml);
- }
-
- private ContentCluster createIllegalSetupWithMissingNodeReferences() throws Exception {
- String dispatchXml = " <dispatch>\n" +
- " <group>\n" +
- " <node distribution-key='10'/>\n" +
- " <node distribution-key='11'/>\n" +
- " </group>\n" +
- " <group>\n" +
- " <node distribution-key='13'/>\n" +
- " <node distribution-key='14'/>\n" +
- " </group>\n" +
- " </dispatch>\n";
- return createCluster(dispatchXml);
- }
-
- private ContentCluster createIllegalSetupWithIllegalNodeReference() throws Exception {
- String dispatchXml = " <dispatch>\n" +
- " <group>\n" +
- " <node distribution-key='10'/>\n" +
- " <node distribution-key='11'/>\n" +
- " <node distribution-key='12'/>\n" +
- " </group>\n" +
- " <group>\n" +
- " <node distribution-key='13'/>\n" +
- " <node distribution-key='14'/>\n" +
- " <node distribution-key='15'/>\n" +
- " <node distribution-key='19'/>\n" +
- " </group>\n" +
- " </dispatch>\n";
- return createCluster(dispatchXml);
- }
-
- @Test
- public void requireThatWeReferenceNodesOnlyOnceWhenSettingUpDispatchGroups() {
- try {
- createIllegalSetupWithMultipleNodeReferences();
- assertFalse("Did not get expected Exception", true);
- } catch (Exception e) {
- assertThat(e.getMessage(), containsString("node with distribution key '12' is referenced multiple times"));
- }
- }
-
- @Test
- public void requireThatWeReferenceAllNodesWhenSettingUpDispatchGroups() {
- try {
- createIllegalSetupWithMissingNodeReferences();
- assertFalse("Did not get expected Exception", true);
- } catch (Exception e) {
- assertThat(e.getMessage(), containsString("2 node(s) with distribution keys [12, 15] are not referenced"));
- }
- }
-
- @Test
- public void requireThatWeReferenceValidNodesWhenSettingUpDispatchGroups() {
- try {
- createIllegalSetupWithIllegalNodeReference();
- assertFalse("Did not get expected Exception", true);
- } catch (Exception e) {
- assertThat(e.getMessage(), containsString("node with distribution key '19' does not exists"));
- }
- }
-
-}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/TldTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/TldTest.java
deleted file mode 100644
index 227ad9c6be1..00000000000
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/TldTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.search;
-
-import com.yahoo.config.application.api.ApplicationPackage;
-import com.yahoo.config.model.test.MockApplicationPackage;
-import com.yahoo.config.model.test.TestDriver;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Simon Thoresen Hult
- */
-public class TldTest {
-
- @Test
- public void requireThatServicesIsParsed() {
- ApplicationPackage app = new MockApplicationPackage.Builder()
- .withHosts("<hosts><host name='localhost'><alias>mockhost</alias></host><host name='my.other.host'><alias>mockhost2</alias></host></hosts>")
- .withServices(
- "<services>" +
- " <admin version='2.0'>" +
- " <adminserver hostalias='mockhost' />" +
- " </admin>" +
- " <container version='1.0' id='default'>" +
- " <search />" +
- " <nodes>" +
- " <node hostalias='mockhost'/>" +
- " </nodes>" +
- " </container>" +
- " <content version='1.0' id='foo'>" +
- " <redundancy>1</redundancy>" +
- " <documents>" +
- " <document type='music' mode='index'/>" +
- " </documents>" +
- " <group>" +
- " <node hostalias='mockhost' distribution-key='0'/>" +
- " <node hostalias='mockhost2' distribution-key='1'/>" +
- " </group>" +
- " <tuning>" +
- " <dispatch>" +
- " <max-hits-per-partition>69</max-hits-per-partition>" +
- " <use-local-node>true</use-local-node>" +
- " </dispatch>" +
- " </tuning>" +
- " </content>" +
- "</services>")
- .withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION)
- .build();
-
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.0.tld.0");
- PartitionsConfig config = new PartitionsConfig(builder);
-
- assertEquals(1, config.dataset().size());
- assertEquals(69, config.dataset(0).maxhitspernode());
- assertEquals(1, config.dataset(0).engine().size());
- }
-
- @Test
- public void requireThatUseLocalPolicyIsOk() {
- ApplicationPackage app = new MockApplicationPackage.Builder()
- .withHosts(
- "<hosts>" +
- " <host name='search.node1'><alias>search1</alias></host>" +
- " <host name='search.node2'><alias>search2</alias></host>" +
- " <host name='jdisc.host.other'><alias>gateway</alias></host>" +
- "</hosts>")
- .withServices(
- "<services>" +
- " <admin version='2.0'>" +
- " <adminserver hostalias='gateway' />" +
- " </admin>" +
- " <container version='1.0' id='default'>" +
- " <search />" +
- " <nodes>" +
- " <node hostalias='search1'/>" +
- " <node hostalias='search2'/>" +
- " </nodes>" +
- " </container>" +
- " <container version='1.0' id='gw'>" +
- " <document-api/>" +
- " <nodes>" +
- " <node hostalias='gateway'/>" +
- " </nodes>" +
- " </container>" +
- " <content version='1.0' id='foo'>" +
- " <redundancy>2</redundancy>" +
- " <documents>" +
- " <document type='music' mode='index'/>" +
- " </documents>" +
- " <group name='topGroup'>" +
- " <distribution partitions='1|*'/>" +
- " <group name='group1' distribution-key='0'>" +
- " <node hostalias='search1' distribution-key='0'/>" +
- " </group>" +
- " <group name='group2' distribution-key='1'>" +
- " <node hostalias='search2' distribution-key='1'/>" +
- " </group>" +
- " </group>" +
- " <tuning>" +
- " <dispatch>" +
- " <use-local-node>true</use-local-node>" +
- " </dispatch>" +
- " </tuning>" +
- " </content>" +
- "</services>")
- .withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION)
- .build();
-
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/gw.0.tld.0");
- PartitionsConfig config = new PartitionsConfig(builder);
-
- // No tld if no search
- assertEquals(0, config.dataset().size());
-
- // First container with a local search node
- builder = new PartitionsConfig.Builder();
- new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.0.tld.0");
- config = new PartitionsConfig(builder);
-
- assertEquals(1, config.dataset().size());
- assertEquals(1, config.dataset(0).engine().size());
- assertEquals(0,config.dataset(0).engine(0).rowid());
- assertEquals(0,config.dataset(0).engine(0).partid());
- assertTrue("Configured with local search node as engine",
- config.dataset(0).engine(0).name_and_port().contains("search.node1"));
-
- // Second container with a local search node
- builder = new PartitionsConfig.Builder();
- new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.1.tld.1");
- config = new PartitionsConfig(builder);
-
- assertEquals(1, config.dataset().size());
- assertEquals(1, config.dataset(0).engine().size());
-
- assertEquals("rowid equals 0",0, config.dataset(0).engine(0).rowid()); // Load Balance row 0
- assertEquals("partid equals 0",0, config.dataset(0).engine(0).partid());
- assertTrue("Configured with correct search node",
- config.dataset(0).engine(0).name_and_port().contains("search.node2"));
- }
-
-}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/utils/DispatchUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/search/utils/DispatchUtils.java
deleted file mode 100644
index 0185770037f..00000000000
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/utils/DispatchUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.search.utils;
-
-import com.yahoo.vespa.config.search.core.FdispatchrcConfig;
-import com.yahoo.vespa.config.search.core.PartitionsConfig;
-import com.yahoo.vespa.model.search.Dispatch;
-
-import static org.junit.Assert.assertEquals;
-
-public class DispatchUtils {
-
- public static PartitionsConfig.Dataset getDataset(Dispatch dispatch) {
- PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
- dispatch.getConfig(builder);
- PartitionsConfig cfg = new PartitionsConfig(builder);
- assertEquals(1, cfg.dataset().size());
- return cfg.dataset(0);
- }
-
- public static FdispatchrcConfig getFdispatchrcConfig(Dispatch dispatch) {
- FdispatchrcConfig.Builder builder = new FdispatchrcConfig.Builder();
- dispatch.getConfig(builder);
- return new FdispatchrcConfig(builder);
- }
-
- public static void assertEngine(int rowId, int partitionId, PartitionsConfig.Dataset.Engine engine) {
- assertEquals(rowId, engine.rowid());
- assertEquals(partitionId, engine.partid());
- }
-
- public static void assertEngine(int rowId, int partitionId, String connectSpec, PartitionsConfig.Dataset.Engine engine) {
- assertEngine(rowId, partitionId, engine);
- assertEquals(connectSpec, engine.name_and_port());
- }
-}