diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-24 12:10:45 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-24 12:10:45 +0100 |
commit | 8e2abfc58e936bd6be3194f9e02a21a9b70b7692 (patch) | |
tree | 9918c66fc57647c0b1c831223f6b0f9c5d6b680d /container-search/src/test/java/com/yahoo | |
parent | 90b260e83678edc36eb877ec235e0e6ce5892a48 (diff) |
Put loadbalancer and invokerfactory in a volatile object to ensure atomic switch when reconfiguring.
Diffstat (limited to 'container-search/src/test/java/com/yahoo')
-rw-r--r-- | container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java | 1 | ||||
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java | 23 | ||||
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/dispatch/MockDispatcher.java (renamed from container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java) | 11 | ||||
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java | 8 | ||||
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java | 8 |
5 files changed, 27 insertions, 24 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java index 2f960add4a8..e9b1cbabc79 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java @@ -13,6 +13,7 @@ import com.yahoo.prelude.fastsearch.SummaryParameters; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; +import com.yahoo.search.dispatch.MockDispatcher; import com.yahoo.search.dispatch.rpc.RpcResourcePool; import com.yahoo.search.dispatch.searchcluster.Node; import com.yahoo.search.grouping.GroupingRequest; diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java index 3c5b026b95e..89ca400362c 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java @@ -5,6 +5,7 @@ import com.yahoo.prelude.fastsearch.VespaBackEndSearcher; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.cluster.ClusterMonitor; +import com.yahoo.search.dispatch.searchcluster.SearchGroups; import com.yahoo.search.dispatch.searchcluster.Node; import com.yahoo.search.dispatch.searchcluster.PingFactory; import com.yahoo.search.dispatch.searchcluster.Pinger; @@ -34,7 +35,7 @@ public class DispatcherTest { SearchCluster cl = new MockSearchCluster("1", 2, 2); Query q = new Query(); q.getModel().setSearchPath("1/0"); // second node in first group - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (nodes, a) -> { + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl.groupList(), dispatchConfig, (nodes, a) -> { assertEquals(1, nodes.size()); assertEquals(1, nodes.get(0).key()); return true; @@ -54,7 +55,7 @@ public class DispatcherTest { return Optional.of(new Node(1, "test", 1)); } }; - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (n, a) -> true); + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl.groupList(), dispatchConfig, (n, a) -> true); Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, dispatchConfig, invokerFactory); SearchInvoker invoker = disp.getSearchInvoker(new Query(), null); assertNotNull(invoker); @@ -66,7 +67,7 @@ public class DispatcherTest { void requireThatInvokerConstructionIsRetriedAndLastAcceptsAnyCoverage() { SearchCluster cl = new MockSearchCluster("1", 2, 1); - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (n, acceptIncompleteCoverage) -> { + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl.groupList(), dispatchConfig, (n, acceptIncompleteCoverage) -> { assertFalse(acceptIncompleteCoverage); return false; }, (n, acceptIncompleteCoverage) -> { @@ -85,7 +86,7 @@ public class DispatcherTest { try { SearchCluster cl = new MockSearchCluster("1", 2, 1); - MockInvokerFactory invokerFactory = new MockInvokerFactory(cl, dispatchConfig, (n, a) -> false, (n, a) -> false); + MockInvokerFactory invokerFactory = new MockInvokerFactory(cl.groupList(), dispatchConfig, (n, a) -> false, (n, a) -> false); Dispatcher disp = new Dispatcher(new ClusterMonitor<>(cl, false), cl, dispatchConfig, invokerFactory); disp.getSearchInvoker(new Query(), null); disp.deconstruct(); @@ -99,7 +100,8 @@ public class DispatcherTest { @Test void testGroup0IsSelected() { SearchCluster cluster = new MockSearchCluster("1", 3, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, + new MockInvokerFactory(cluster.groupList(), dispatchConfig, (n, a) -> true)); cluster.pingIterationCompleted(); assertEquals(0, dispatcher.getSearchInvoker(new Query(), null).distributionKey().get().longValue()); @@ -109,7 +111,8 @@ public class DispatcherTest { @Test void testGroup0IsSkippedWhenItIsBlockingFeed() { SearchCluster cluster = new MockSearchCluster("1", 3, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, + new MockInvokerFactory(cluster.groupList(), dispatchConfig, (n, a) -> true)); cluster.group(0).nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); assertEquals(1, @@ -121,7 +124,8 @@ public class DispatcherTest { @Test void testGroup0IsSelectedWhenMoreAreBlockingFeed() { SearchCluster cluster = new MockSearchCluster("1", 3, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, + new MockInvokerFactory(cluster.groupList(), dispatchConfig, (n, a) -> true)); cluster.group(0).nodes().get(0).setBlockingWrites(true); cluster.group(1).nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); @@ -134,7 +138,8 @@ public class DispatcherTest { @Test void testGroup0IsSelectedWhenItIsBlockingFeedWhenNoOthers() { SearchCluster cluster = new MockSearchCluster("1", 1, 1); - Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, new MockInvokerFactory(cluster, dispatchConfig, (n, a) -> true)); + Dispatcher dispatcher = new Dispatcher(new ClusterMonitor<>(cluster, false), cluster, dispatchConfig, + new MockInvokerFactory(cluster.groupList(), dispatchConfig, (n, a) -> true)); cluster.group(0).nodes().get(0).setBlockingWrites(true); cluster.pingIterationCompleted(); assertEquals(0, @@ -152,7 +157,7 @@ public class DispatcherTest { private final FactoryStep[] events; private int step = 0; - public MockInvokerFactory(SearchCluster cl, DispatchConfig disptachConfig, FactoryStep... events) { + public MockInvokerFactory(SearchGroups cl, DispatchConfig disptachConfig, FactoryStep... events) { super(cl, disptachConfig); this.events = events; } diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java b/container-search/src/test/java/com/yahoo/search/dispatch/MockDispatcher.java index 886c9818842..86b3d90f5ca 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/MockDispatcher.java @@ -1,9 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.prelude.fastsearch.test; +package com.yahoo.search.dispatch; import com.yahoo.container.handler.VipStatus; import com.yahoo.search.cluster.ClusterMonitor; -import com.yahoo.search.dispatch.Dispatcher; import com.yahoo.search.dispatch.rpc.RpcInvokerFactory; import com.yahoo.search.dispatch.rpc.RpcPingFactory; import com.yahoo.search.dispatch.rpc.RpcResourcePool; @@ -14,7 +13,7 @@ import com.yahoo.vespa.config.search.DispatchNodesConfig; import java.util.List; -class MockDispatcher extends Dispatcher { +public class MockDispatcher extends Dispatcher { public final ClusterMonitor clusterMonitor; @@ -31,7 +30,7 @@ class MockDispatcher extends Dispatcher { } private MockDispatcher(ClusterMonitor clusterMonitor, SearchCluster searchCluster, DispatchConfig dispatchConfig, RpcResourcePool rpcResourcePool) { - this(clusterMonitor, searchCluster, dispatchConfig, new RpcInvokerFactory(rpcResourcePool, searchCluster, dispatchConfig)); + this(clusterMonitor, searchCluster, dispatchConfig, new RpcInvokerFactory(rpcResourcePool, searchCluster.groupList(), dispatchConfig)); } private MockDispatcher(ClusterMonitor clusterMonitor, SearchCluster searchCluster, DispatchConfig dispatchConfig, RpcInvokerFactory invokerFactory) { @@ -39,10 +38,10 @@ class MockDispatcher extends Dispatcher { this.clusterMonitor = clusterMonitor; } - static DispatchConfig toDispatchConfig() { + public static DispatchConfig toDispatchConfig() { return new DispatchConfig.Builder().build(); } - static DispatchNodesConfig toNodesConfig(List<Node> nodes) { + public static DispatchNodesConfig toNodesConfig(List<Node> nodes) { DispatchNodesConfig.Builder dispatchConfigBuilder = new DispatchNodesConfig.Builder(); int key = 0; for (Node node : nodes) { diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java b/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java index 9a4931a8fa7..727e00ed681 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/MockSearchCluster.java @@ -1,25 +1,23 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.dispatch; -import com.yahoo.search.dispatch.searchcluster.GroupListImpl; +import com.yahoo.search.dispatch.searchcluster.SearchGroupsImpl; import com.yahoo.search.dispatch.searchcluster.Node; import com.yahoo.search.dispatch.searchcluster.SearchCluster; import com.yahoo.vespa.config.search.DispatchConfig; -import java.util.List; - /** * @author ollivir */ public class MockSearchCluster extends SearchCluster { public MockSearchCluster(String clusterId, int groups, int nodesPerGroup) { - super(clusterId, 88.0, GroupListImpl.buildGroupListForTest(groups, nodesPerGroup), null, null); + super(clusterId, SearchGroupsImpl.buildGroupListForTest(groups, nodesPerGroup, 88.0), null, null); } @Override public int groupsWithSufficientCoverage() { - return numGroups(); + return groupList().size(); } @Override diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java index fcd587e19f7..f0083e13eac 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/SearchPathTest.java @@ -2,8 +2,8 @@ package com.yahoo.search.dispatch; import com.yahoo.search.dispatch.SearchPath.InvalidSearchPathException; -import com.yahoo.search.dispatch.searchcluster.GroupList; -import com.yahoo.search.dispatch.searchcluster.GroupListImpl; +import com.yahoo.search.dispatch.searchcluster.SearchGroups; +import com.yahoo.search.dispatch.searchcluster.SearchGroupsImpl; import com.yahoo.search.dispatch.searchcluster.Node; import org.junit.jupiter.api.Test; @@ -83,7 +83,7 @@ public class SearchPathTest { } } - private void verifyRandomGroup(GroupList cluster, String searchPath, Set<?> possibleSolutions) { + private void verifyRandomGroup(SearchGroups cluster, String searchPath, Set<?> possibleSolutions) { for (int i=0; i < 100; i++) { String nodes = distKeysAsString(SearchPath.selectNodes(searchPath, cluster)); assertTrue(possibleSolutions.contains(nodes)); @@ -92,7 +92,7 @@ public class SearchPathTest { @Test void searchPathMustFilterNodesBasedOnDefinition() { - GroupList cluster = GroupListImpl.buildGroupListForTest(3, 3); + SearchGroups cluster = SearchGroupsImpl.buildGroupListForTest(3, 3, 100); assertEquals(distKeysAsString(SearchPath.selectNodes("1/1", cluster)), "4"); assertEquals(distKeysAsString(SearchPath.selectNodes("/1", cluster)), "3,4,5"); |