aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-07-05 11:31:11 +0200
committerHarald Musum <musum@yahooinc.com>2023-07-05 11:31:11 +0200
commit16737570b30afbe3b8699daafdcc9b8de286e5b0 (patch)
tree329a8704915cc0500e0704f29a6957296035c976 /clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller
parent89d23c1a2836b519001cccdcd98123153ba25653 (diff)
Minor refactoring and start of some new test
Diffstat (limited to 'clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller')
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java43
1 files changed, 32 insertions, 11 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
index c4fd7cb69b9..43687d51937 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java
@@ -13,7 +13,6 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import static com.yahoo.vdslib.state.NodeType.DISTRIBUTOR;
@@ -168,12 +167,9 @@ public class NodeStateChangeCheckerTest {
@Test
void testMaintenanceAllowedFor2Of4Groups() {
- // 4 groups with 1 node in each group
- Collection<ConfiguredNode> nodes = createNodes(4);
- StorDistributionConfig config = createDistributionConfig(4, 4);
-
int maxNumberOfGroupsAllowedToBeDown = 2;
- var cluster = new ContentCluster("Clustername", nodes, new Distribution(config), maxNumberOfGroupsAllowedToBeDown);
+ // 4 groups with 1 node in each group
+ var cluster = createCluster(4, 4, maxNumberOfGroupsAllowedToBeDown);
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 5, 6)));
var nodeStateChangeChecker = createChangeChecker(cluster);
@@ -219,12 +215,9 @@ public class NodeStateChangeCheckerTest {
@Test
void testMaintenanceAllowedFor2Of4Groups8Nodes() {
- // 4 groups with 2 nodes in each group
- Collection<ConfiguredNode> nodes = createNodes(8);
- StorDistributionConfig config = createDistributionConfig(8, 4);
-
int maxNumberOfGroupsAllowedToBeDown = 2;
- var cluster = new ContentCluster("Clustername", nodes, new Distribution(config), maxNumberOfGroupsAllowedToBeDown);
+ // 4 groups with 2 nodes in each group
+ var cluster = createCluster(8, 4, maxNumberOfGroupsAllowedToBeDown);
setAllNodesUp(cluster, HostInfo.createHostInfo(createDistributorHostInfo(4, 5, 6)));
var nodeStateChangeChecker = createChangeChecker(cluster);
@@ -271,6 +264,34 @@ public class NodeStateChangeCheckerTest {
setStorageNodeWantedStateToMaintenance(cluster, nodeIndex);
}
+ // 2 nodes in group 0 and 2 nodes in group 1 in maintenance, try to set storage node 4 in group 2 to maintenance, should fail
+ {
+ ClusterState clusterState = clusterState(String.format("version:%d distributor:8 storage:8 .0.s:m .1.s:m .2.s:m .3.s:m", currentClusterStateVersion));
+ int nodeIndex = 4;
+ Node node = new Node(STORAGE, nodeIndex);
+ Result result = nodeStateChangeChecker.evaluateTransition(node, clusterState, SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
+ assertFalse(result.settingWantedStateIsAllowed(), result.toString());
+ assertFalse(result.wantedStateAlreadySet());
+ assertEquals("At most 2 groups can have wanted state: [0, 1]", result.getReason());
+ }
+
+ // 2 nodes in group 0 up again but buckets not in sync and 2 nodes in group 1 in maintenance,
+ // try to set storage node 4 in group 2 to maintenance
+ /* WIP
+ {
+ ClusterState clusterState = clusterState(String.format("version:%d distributor:8 storage:8 .2.s:m .3.s:m", currentClusterStateVersion));
+ setStorageNodeWantedState(cluster, 0, UP, "");
+ setStorageNodeWantedState(cluster, 1, UP, "");
+ int nodeIndex = 4;
+ Node node = new Node(STORAGE, nodeIndex);
+ Result result = nodeStateChangeChecker.evaluateTransition(node, clusterState, SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE);
+ assertFalse(result.settingWantedStateIsAllowed(), result.toString());
+ assertFalse(result.wantedStateAlreadySet());
+ assertEquals("At most 2 groups can have wanted state: [0, 1]", result.getReason());
+ }
+
+ */
+
// 2 nodes in group 0 in maintenance, storage node 3 in group 1 is in maintenance with another description
// (set in maintenance by operator), try to set storage node 3 in group 1 to maintenance, should bew allowed
{