summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-09-05 10:47:23 +0200
committerjonmv <venstad@gmail.com>2023-09-05 11:01:15 +0200
commit5c5be982848fb8a3f1d84fa522f380b8706e6ddb (patch)
tree87879722d4763785b73648b6778bb3b428b5f555 /container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
parent932a5311bf7acfc9bad8e45be39cec5540b0a692 (diff)
Keep and reconfigure ClusterMonitor when reconfiguring dispatcher
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java')
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java12
1 files changed, 11 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 f6a1ca5cae3..109b9db2ce4 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
@@ -6,12 +6,14 @@ import com.yahoo.container.handler.ClustersStatus;
import com.yahoo.container.handler.VipStatus;
import com.yahoo.net.HostName;
import com.yahoo.prelude.Pong;
+import com.yahoo.search.cluster.BaseNodeMonitor;
import com.yahoo.search.cluster.ClusterMonitor;
import com.yahoo.search.result.ErrorMessage;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -384,6 +386,7 @@ public class SearchClusterTest {
@Test
void requireThatPreciselyTheRetainedNodesAreKeptWhenNodesAreUpdated() {
try (State state = new State("query", 2, IntStream.range(0, 6).mapToObj(i -> "node-" + i).toList())) {
+ state.clusterMonitor.start();
List<Node> referenceNodes = List.of(new Node("test", 0, "node-0", 0),
new Node("test", 1, "node-1", 0),
new Node("test", 0, "node-2", 1),
@@ -392,6 +395,7 @@ public class SearchClusterTest {
new Node("test", 1, "node-5", 2));
SearchGroups oldGroups = state.searchCluster.groupList();
assertEquals(Set.copyOf(referenceNodes), oldGroups.nodes());
+ List<BaseNodeMonitor<Node>> oldMonitors = state.clusterMonitor.nodeMonitors();
List<Node> updatedNodes = List.of(new Node("test", 0, "node-1", 0), // Swap node-0 and node-1
new Node("test", 1, "node-0", 0), // Swap node-1 and node-0
@@ -399,7 +403,7 @@ public class SearchClusterTest {
new Node("test", 1, "node-3", 1),
new Node("test", 0, "node-2", 2), // Swap node-4 and node-2
new Node("test", 1, "node-6", 2)); // Replace node-6
- state.searchCluster.updateNodes(updatedNodes, 100.0);
+ state.searchCluster.updateNodes(updatedNodes, state.clusterMonitor, 100.0);
SearchGroups newGroups = state.searchCluster.groupList();
assertEquals(Set.copyOf(updatedNodes), newGroups.nodes());
@@ -417,6 +421,12 @@ public class SearchClusterTest {
for (Node node : updatedNodes)
assertEquals(pathIndexWithinGroup[node.group()]++, newNodesByIdentity.get(node).pathIndex(),
"search path index within group should follow updated node order for: " + node);
+
+ // Precisely the one retained node keeps its monitor through reconfiguration.
+ Set<BaseNodeMonitor<Node>> retainedMonitors = new HashSet<>(state.clusterMonitor.nodeMonitors());
+ retainedMonitors.retainAll(oldMonitors);
+ assertEquals(1, retainedMonitors.size());
+ assertSame(oldNodesByIdentity.get(updatedNodes.get(3)), retainedMonitors.iterator().next().getNode());
}
}