aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-01-07 14:54:54 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-01-07 14:57:22 +0000
commitbb98a536fa3e3efb92816981ec1424c7de2e70d9 (patch)
tree98bd4bcf8e7da800c184e5d32a57c57970742d0e /container-search/src/test/java/com/yahoo/search/dispatch/searchcluster
parentde747f7296327a96b5f298f7f0f3905f91dfb8ba (diff)
Disable topk optimisation on dispatch when content distribution is severly skewed.
When the skew is too large the assumption that docs are evenly and randomly distributed hold. The impact and is larger on smaller systems. In large systems the where this optimisation is more important, the probabilitity of large skew will be less.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch/searchcluster')
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java45
1 files changed, 44 insertions, 1 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
index 09024150a9a..c6fd48836fe 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
@@ -8,7 +8,6 @@ import com.yahoo.net.HostName;
import com.yahoo.prelude.Pong;
import com.yahoo.search.cluster.ClusterMonitor;
import com.yahoo.search.dispatch.MockSearchCluster;
-import com.yahoo.search.dispatch.TopKEstimator;
import com.yahoo.search.result.ErrorMessage;
import org.junit.Test;
@@ -335,4 +334,48 @@ public class SearchClusterTest {
assertEquals(3, node.getLastReceivedPongId());
}
+ @Test
+ public void requireThatEmptyGroupIsInBalance() {
+ Group group = new Group(0, new ArrayList<>());
+ assertTrue(group.isContentWellBalanced());
+ group.aggregateNodeValues();
+ assertTrue(group.isContentWellBalanced());
+ }
+
+ @Test
+ public void requireThatSingleNodeGroupIsInBalance() {
+ Group group = new Group(0, Arrays.asList(new Node(1, "n", 1)));
+ group.nodes().forEach(node -> node.setWorking(true));
+ assertTrue(group.isContentWellBalanced());
+ group.aggregateNodeValues();
+ assertTrue(group.isContentWellBalanced());
+ group.nodes().get(0).setActiveDocuments(1000);
+ group.aggregateNodeValues();
+ assertTrue(group.isContentWellBalanced());
+ }
+
+ @Test
+ public void requireThatMultiNodeGroupDetectsBalance() {
+ Group group = new Group(0, Arrays.asList(new Node(1, "n1", 1), new Node(2, "n2", 1)));
+ assertTrue(group.isContentWellBalanced());
+ group.nodes().forEach(node -> node.setWorking(true));
+ assertTrue(group.isContentWellBalanced());
+ group.aggregateNodeValues();
+ assertTrue(group.isContentWellBalanced());
+ group.nodes().get(0).setActiveDocuments(1000);
+ group.aggregateNodeValues();
+ assertFalse(group.isContentWellBalanced());
+ group.nodes().get(1).setActiveDocuments(100);
+ group.aggregateNodeValues();
+ assertFalse(group.isContentWellBalanced());
+ group.nodes().get(1).setActiveDocuments(800);
+ group.aggregateNodeValues();
+ assertFalse(group.isContentWellBalanced());
+ group.nodes().get(1).setActiveDocuments(818);
+ group.aggregateNodeValues();
+ assertFalse(group.isContentWellBalanced());
+ group.nodes().get(1).setActiveDocuments(819);
+ group.aggregateNodeValues();
+ assertTrue(group.isContentWellBalanced());
+ }
}