summaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@oath.com>2018-06-13 23:37:25 +0200
committerHåkon Hallingstad <hakon@oath.com>2018-06-13 23:37:25 +0200
commitfb9ce82704844818f4089655c86bd807a75dda0d (patch)
treefb4c1274c80965103efe29fa375cf1fc7e1ac75c /clustercontroller-core/src/test/java
parentd69674079c29912663c89176db6b98b298f7d75e (diff)
Do not wait for version ack for failed set-node-state
Diffstat (limited to 'clustercontroller-core/src/test/java')
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java32
1 files changed, 32 insertions, 0 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 4fb244666a4..3f977273054 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
@@ -2,12 +2,15 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vdslib.state.NodeType;
+import com.yahoo.vespa.clustercontroller.core.MasterInterface;
import com.yahoo.vespa.clustercontroller.core.RemoteClusterControllerTask;
import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.SetNodeStateRequest;
+import com.yahoo.vespa.clustercontroller.core.restapiv2.requests.WantedStateSetter;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.DeadlineExceededException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InvalidContentException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.MissingUnitException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.OperationNotSupportedForUnitException;
+import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse;
@@ -26,6 +29,9 @@ import static org.hamcrest.core.StringContains.containsString;
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.Mockito.mock;
+import static org.mockito.Mockito.when;
public class SetNodeStateTest extends StateRestApiTest {
@@ -426,4 +432,30 @@ public class SetNodeStateTest extends StateRestApiTest {
request.getResult();
}
+ @Test
+ public void no_fail_if_modified() throws StateRestApiException {
+ assertFalse(isFailed(true));
+ }
+
+ @Test
+ public void fail_if_not_modified() throws StateRestApiException {
+ assertTrue(isFailed(false));
+ }
+
+ private boolean isFailed(boolean wasModified) throws StateRestApiException {
+ WantedStateSetter wantedStateSetter = mock(WantedStateSetter.class);
+ SetNodeStateRequest request = new SetNodeStateRequest(
+ createDummyId(),
+ 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);
+
+ RemoteClusterControllerTask.Context context = mock(RemoteClusterControllerTask.Context.class);
+ MasterInterface masterInterface = mock(MasterInterface.class);
+ context.masterInfo = masterInterface;
+ when(masterInterface.isMaster()).thenReturn(true);
+ request.doRemoteFleetControllerTask(context);
+ return request.isFailed();
+ }
}