diff options
author | Harald Musum <musum@yahooinc.com> | 2023-04-17 15:06:48 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-04-17 15:06:48 +0200 |
commit | e87be82cddf3145659a9ed75a0f5730fcb345fe3 (patch) | |
tree | 8568cb36c19ba37feafec27824ae8da6572c85e5 /clustercontroller-core/src/test | |
parent | 8162871b7bdc83d4ab03c14979b3b1f8020a81b5 (diff) |
Check state down later and simplify
Diffstat (limited to 'clustercontroller-core/src/test')
-rw-r--r-- | clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeCheckerTest.java | 33 |
1 files changed, 28 insertions, 5 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 37d95f8c4b1..551b60be741 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 @@ -192,6 +192,18 @@ public class NodeStateChangeCheckerTest { setStorageNodeWantedStateToMaintenance(cluster, nodeIndex); } + // Nodes in group 0 and 1 in maintenance, try to set storage node in group 2 to maintenance while storage node 2 is down, should fail + { + ClusterState clusterState = clusterState(String.format("version:%d distributor:4 storage:4 .0.s:m .1.s:m .2.s:d", currentClusterStateVersion)); + int nodeIndex = 2; + cluster.clusterInfo().getStorageNodeInfo(nodeIndex).setReportedState(new NodeState(STORAGE, DOWN), 0); + 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 nodes in 2 groups can have wanted state", result.getReason()); + } + // Nodes in group 0 and 1 in maintenance, try to set storage node in group 2 to maintenance, should fail { ClusterState clusterState = clusterState(String.format("version:%d distributor:4 storage:4 .0.s:m .1.s:m", currentClusterStateVersion)); @@ -300,7 +312,10 @@ public class NodeStateChangeCheckerTest { SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE); assertFalse(result.settingWantedStateIsAllowed()); assertFalse(result.wantedStateAlreadySet()); - assertEquals("At most one group can have wanted state: Other distributor 0 in group 0 has wanted state Down", result.getReason()); + if (maxNumberOfGroupsAllowedToBeDown >= 1) + assertEquals("At most nodes in 1 groups can have wanted state", result.getReason()); + else + assertEquals("At most one group can have wanted state: Other distributor 0 in group 0 has wanted state Down", result.getReason()); } { @@ -309,8 +324,13 @@ public class NodeStateChangeCheckerTest { Result result = nodeStateChangeChecker.evaluateTransition( new Node(STORAGE, 1), clusterStateWith0InMaintenance, SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE); - assertFalse(result.settingWantedStateIsAllowed(), result.getReason()); - assertEquals("Another distributor wants state DOWN: 0", result.getReason()); + if (maxNumberOfGroupsAllowedToBeDown >= 1) { + assertTrue(result.settingWantedStateIsAllowed(), result.getReason()); + assertFalse(result.wantedStateAlreadySet()); + } else { + assertFalse(result.settingWantedStateIsAllowed(), result.getReason()); + assertEquals("Another distributor wants state DOWN: 0", result.getReason()); + } } } @@ -333,8 +353,11 @@ public class NodeStateChangeCheckerTest { SAFE, UP_NODE_STATE, MAINTENANCE_NODE_STATE); assertFalse(result.settingWantedStateIsAllowed()); assertFalse(result.wantedStateAlreadySet()); - assertEquals("At most one group can have wanted state: Other storage node 0 in group 0 has wanted state Maintenance", - result.getReason()); + if (maxNumberOfGroupsAllowedToBeDown >= 1) + assertEquals("At most nodes in 1 groups can have wanted state", result.getReason()); + else + assertEquals("At most one group can have wanted state: Other storage node 0 in group 0 has wanted state Maintenance", + result.getReason()); } { |