aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2
diff options
context:
space:
mode:
authorHÃ¥kon Hallingstad <hakon@oath.com>2018-11-01 08:55:55 +0100
committerGitHub <noreply@github.com>2018-11-01 08:55:55 +0100
commit08d60ee8e27259b936821b80d7f0f89f99d44d56 (patch)
treea01a49cf3be5ab1d69dd3a961b8e6cec05951046 /clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2
parentea4900aa266ec8e3e55b9fbc98d9b20b6eb61995 (diff)
Revert "Revert "Enforce CC timeouts in Orchestrator [4]""
Diffstat (limited to 'clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2')
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java9
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java41
2 files changed, 40 insertions, 10 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
index f3a4be5ac2f..6cf4b7989e7 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java
@@ -33,6 +33,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -46,6 +47,7 @@ public class SetNodeStateTest extends StateRestApiTest {
private Condition condition = Condition.FORCE;
private ResponseWait responseWait = ResponseWait.WAIT_UNTIL_CLUSTER_ACKED;
private TimeBudget timeBudget = TimeBudget.fromNow(Clock.systemUTC(), Duration.ofSeconds(10));
+ private boolean probe = false;
public SetUnitStateRequestImpl(String req) {
super(req, 0);
@@ -98,6 +100,11 @@ public class SetNodeStateTest extends StateRestApiTest {
public TimeBudget timeBudget() {
return timeBudget;
}
+
+ @Override
+ public boolean isProbe() {
+ return probe;
+ }
}
private void verifyStateSet(String state, String reason) throws Exception {
@@ -458,7 +465,7 @@ public class SetNodeStateTest extends StateRestApiTest {
new SetUnitStateRequestImpl("music/storage/1").setNewState("user", "maintenance", "whatever reason."),
wantedStateSetter);
SetResponse response = new SetResponse("some reason", wasModified);
- when(wantedStateSetter.set(any(), any(), any(), any(), any(), any())).thenReturn(response);
+ when(wantedStateSetter.set(any(), any(), any(), any(), any(), any(), anyBoolean())).thenReturn(response);
RemoteClusterControllerTask.Context context = mock(RemoteClusterControllerTask.Context.class);
MasterInterface masterInterface = mock(MasterInterface.class);
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
index 9239b8774b0..7161fb1be79 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java
@@ -23,20 +23,23 @@ import java.util.Map;
import java.util.Optional;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class SetNodeStateRequestTest {
- public static final String REASON = "operator";
- ContentCluster cluster = mock(ContentCluster.class);
- SetUnitStateRequest.Condition condition = SetUnitStateRequest.Condition.SAFE;
- Map<String, UnitState> newStates = new HashMap<>();
- UnitState unitState = mock(UnitState.class);
+ private static final String REASON = "operator";
+ private ContentCluster cluster = mock(ContentCluster.class);
+ private SetUnitStateRequest.Condition condition = SetUnitStateRequest.Condition.SAFE;
+ private Map<String, UnitState> newStates = new HashMap<>();
+ private UnitState unitState = mock(UnitState.class);
private final int NODE_INDEX = 2;
- Node storageNode = new Node(NodeType.STORAGE, NODE_INDEX);
- NodeStateOrHostInfoChangeHandler stateListener = mock(NodeStateOrHostInfoChangeHandler.class);
- ClusterState currentClusterState = mock(ClusterState.class);
+ private Node storageNode = new Node(NodeType.STORAGE, NODE_INDEX);
+ private NodeStateOrHostInfoChangeHandler stateListener = mock(NodeStateOrHostInfoChangeHandler.class);
+ private ClusterState currentClusterState = mock(ClusterState.class);
+ private boolean probe = false;
@Before
public void setUp() {
@@ -53,6 +56,16 @@ public class SetNodeStateRequestTest {
}
@Test
+ public void testProbingDoesntChangeState() throws StateRestApiException {
+ probe = true;
+ testSetStateRequest(
+ "maintenance",
+ State.UP, State.UP,
+ NodeStateChangeChecker.Result.allowSettingOfWantedState(),
+ Optional.empty(), Optional.empty());
+ }
+
+ @Test
public void testUpToDown() throws StateRestApiException {
testSetStateRequest(
"down",
@@ -124,6 +137,9 @@ public class SetNodeStateRequestTest {
when(cluster.getNodeInfo(distributorNode)).thenReturn(distributorNodeInfo);
NodeState distributorNodeState = new NodeState(distributorNode.getType(), distributorWantedState);
+ if (distributorWantedState != State.UP) {
+ distributorNodeState.setDescription(REASON);
+ }
when(distributorNodeInfo.getUserWantedState()).thenReturn(distributorNodeState);
setWantedState();
@@ -133,6 +149,9 @@ public class SetNodeStateRequestTest {
new NodeState(NodeType.STORAGE, expectedNewStorageWantedState.get());
verify(storageNodeInfo).setWantedState(expectedNewStorageNodeState);
verify(stateListener).handleNewWantedNodeState(storageNodeInfo, expectedNewStorageNodeState);
+ } else {
+ verify(storageNodeInfo, times(0)).setWantedState(any());
+ verify(stateListener, times(0)).handleNewWantedNodeState(eq(storageNodeInfo), any());
}
if (expectedNewDistributorWantedState.isPresent()) {
@@ -140,6 +159,9 @@ public class SetNodeStateRequestTest {
new NodeState(NodeType.DISTRIBUTOR, expectedNewDistributorWantedState.get());
verify(distributorNodeInfo).setWantedState(expectedNewDistributorNodeState);
verify(stateListener).handleNewWantedNodeState(distributorNodeInfo, expectedNewDistributorNodeState);
+ } else {
+ verify(distributorNodeInfo, times(0)).setWantedState(any());
+ verify(stateListener, times(0)).handleNewWantedNodeState(eq(distributorNodeInfo), any());
}
}
@@ -150,6 +172,7 @@ public class SetNodeStateRequestTest {
newStates,
storageNode,
stateListener,
- currentClusterState);
+ currentClusterState,
+ probe);
}
} \ No newline at end of file