aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2
diff options
context:
space:
mode:
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/ClusterListTest.java91
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java102
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java160
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java72
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java48
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java11
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java192
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/SetNodeStateTest.java143
-rw-r--r--clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequestTest.java20
9 files changed, 414 insertions, 425 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java
index 84116674afa..8e49703c94b 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterListTest.java
@@ -2,67 +2,68 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ClusterListTest extends StateRestApiTest {
@Test
- public void testClusterList() throws Exception {
+ void testClusterList() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("", 0));
String expected =
"{\"cluster\": {\n" +
- " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
- " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
- "}}";
+ " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
+ " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveClusterList() throws Exception {
+ void testRecursiveClusterList() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("", 1));
String expected =
"{\"cluster\": {\n" +
- " \"books\": {\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
- " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:4 storage:4\",\n" +
- " \"bucket-spaces\": [\n" +
- " {\n" +
- " \"name\": \"default\",\n" +
- " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"global\",\n" +
- " \"state\": \"distributor:4 storage:4\"\n" +
- " }\n" +
- " ]\n" +
- " }}\n" +
- " },\n" +
- " \"music\": {\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\"},\n" +
- " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\"}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
- " \"bucket-spaces\": []\n" +
- " }}\n" +
- " }\n" +
- "}}";
+ " \"books\": {\n" +
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
+ " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:4 storage:4\",\n" +
+ " \"bucket-spaces\": [\n" +
+ " {\n" +
+ " \"name\": \"default\",\n" +
+ " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"global\",\n" +
+ " \"state\": \"distributor:4 storage:4\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }}\n" +
+ " },\n" +
+ " \"music\": {\n" +
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\"},\n" +
+ " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\"}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
+ " \"bucket-spaces\": []\n" +
+ " }}\n" +
+ " }\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java
index 2efb731c88c..ab9c92a6d9e 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ClusterTest.java
@@ -2,74 +2,74 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ClusterTest extends StateRestApiTest {
@Test
- public void testCluster() throws Exception {
+ void testCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("books", 0));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
- " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:4 storage:4\",\n" +
- " \"bucket-spaces\": [\n" +
- " {\n" +
- " \"name\": \"default\",\n" +
- " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
- " },\n" +
- " {\n" +
- " \"name\": \"global\",\n" +
- " \"state\": \"distributor:4 storage:4\"\n" +
- " }\n" +
- " ]\n" +
- " }}\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"link\": \"\\/cluster\\/v2\\/books\\/storage\"},\n" +
+ " \"distributor\": {\"link\": \"\\/cluster\\/v2\\/books\\/distributor\"}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:4 storage:4\",\n" +
+ " \"bucket-spaces\": [\n" +
+ " {\n" +
+ " \"name\": \"default\",\n" +
+ " \"state\": \"distributor:4 storage:4 .3.s:m\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"name\": \"global\",\n" +
+ " \"state\": \"distributor:4 storage:4\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }}\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveCluster() throws Exception {
+ void testRecursiveCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music", 1));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"service\": {\n" +
- " \"storage\": {\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\"},\n" +
- " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/2\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/3\"},\n" +
- " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/5\"},\n" +
- " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/7\"}\n" +
- " }},\n" +
- " \"distributor\": {\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
- " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
- " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
- " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
- " }}\n" +
- " },\n" +
- " \"distribution-states\": {\"published\": {\n" +
- " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
- " \"bucket-spaces\": []\n" +
- " }}\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"service\": {\n" +
+ " \"storage\": {\"node\": {\n" +
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\"},\n" +
+ " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/2\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/3\"},\n" +
+ " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/5\"},\n" +
+ " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/7\"}\n" +
+ " }},\n" +
+ " \"distributor\": {\"node\": {\n" +
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
+ " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
+ " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
+ " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
+ " }}\n" +
+ " },\n" +
+ " \"distribution-states\": {\"published\": {\n" +
+ " \"baseline\": \"distributor:8 .0.s:d .2.s:d .4.s:d .6.s:d storage:8 .0.s:d .2.s:d .4.s:d .6.s:d\",\n" +
+ " \"bucket-spaces\": []\n" +
+ " }}\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java
index 38fab2f5c54..52c46215e50 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NodeTest.java
@@ -8,99 +8,99 @@ import com.yahoo.vdslib.state.State;
import com.yahoo.vespa.clustercontroller.core.ContentCluster;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class NodeTest extends StateRestApiTest {
@Test
- public void testDistributor() throws Exception {
+ void testDistributor() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/distributor/1", 0));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testStorage() throws Exception {
+ void testStorage() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 0));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " },\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveNode() throws Exception {
+ void testRecursiveNode() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 1));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " },\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testNodeNotSeenInSlobrok() throws Exception {
+ void testNodeNotSeenInSlobrok() throws Exception {
setUp(true);
ContentCluster old = music.context.cluster;
music.context.cluster = new ContentCluster(old.getName(), old.getConfiguredNodes().values(), old.getDistribution());
@@ -110,22 +110,22 @@ public class NodeTest extends StateRestApiTest {
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 0));
String expected =
"{\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"Not seen\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"Node not seen in slobrok.\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- "}";
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"Not seen\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"Node not seen in slobrok.\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
index d85cf95defc..15aeded2d37 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/NotMasterTest.java
@@ -5,19 +5,17 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.OtherMasterEx
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import static com.yahoo.vespa.defaults.Defaults.getDefaults;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
public class NotMasterTest extends StateRestApiTest {
@Test
- public void testUnknownMaster() throws Exception {
+ void testUnknownMaster() throws Exception {
setUp(true);
music.fleetControllerMaster = null;
- // Non-recursive cluster list works, as it doesn't touches into fleetcontrollers
+ // Non-recursive cluster list works, as it doesn't touches into fleetcontrollers
{
UnitResponse response = restAPI.getState(new StateRequest("", 0));
String expected =
@@ -27,49 +25,49 @@ public class NotMasterTest extends StateRestApiTest {
"}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
- // Recursive cluster list does not work
- try{
+ // Recursive cluster list does not work
+ try {
restAPI.getState(new StateRequest("", 1));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- // Other requests does not work either
- try{
+ // Other requests does not work either
+ try {
restAPI.getState(new StateRequest("music", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1/0", 0));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1")
- .setNewState("user", "down", "test"));
+ .setNewState("user", "down", "test"));
fail();
} catch (UnknownMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No known master cluster controller"));
+ assertTrue(e.getMessage().contains("No known master cluster controller"), e.getMessage());
}
}
@Test
- public void testKnownOtherMaster() throws Exception {
+ void testKnownOtherMaster() throws Exception {
setUp(true);
ccSockets.put(1, new ClusterControllerStateRestAPI.Socket("otherhost", getDefaults().vespaWebServicePort()));
music.fleetControllerMaster = 1;
@@ -78,59 +76,59 @@ public class NotMasterTest extends StateRestApiTest {
UnitResponse response = restAPI.getState(new StateRequest("", 0));
String expected =
"{\"cluster\": {\n" +
- " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
- " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
- "}}";
+ " \"books\": {\"link\": \"\\/cluster\\/v2\\/books\"},\n" +
+ " \"music\": {\"link\": \"\\/cluster\\/v2\\/music\"}\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
// Recursive cluster list does not work
- try{
+ try {
restAPI.getState(new StateRequest("", 1));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
// Other requests does not work either
- try{
+ try {
restAPI.getState(new StateRequest("music", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.getState(new StateRequest("music/storage/1/0", 0));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
- try{
+ try {
restAPI.setUnitState(new SetNodeStateTest.SetUnitStateRequestImpl("music/storage/1")
.setNewState("user", "down", "test"));
fail();
} catch (OtherMasterException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."));
+ assertTrue(e.getMessage().contains("Cluster controller not master. Use master at otherhost:" + getDefaults().vespaWebServicePort() + "."), e.getMessage());
assertEquals("otherhost", e.getHost());
assertEquals(e.getPort(), getDefaults().vespaWebServicePort());
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
index ec60adf16d3..65acea02d34 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
@@ -3,47 +3,47 @@ package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import org.codehaus.jettison.json.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class PartitionTest extends StateRestApiTest {
@Test
- public void testPartition() throws Exception {
+ void testPartition() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1/0", 0));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveCluster() throws Exception {
+ void testRecursiveCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1/0", 1));
String expected =
"{\n" +
- " \"state\": {\"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }},\n" +
- " \"metrics\": {\n" +
- " \"bucket-count\": 1,\n" +
- " \"unique-document-count\": 2,\n" +
- " \"unique-document-total-size\": 3\n" +
- " }\n" +
- "}";
+ " \"state\": {\"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }},\n" +
+ " \"metrics\": {\n" +
+ " \"bucket-count\": 1,\n" +
+ " \"unique-document-count\": 2,\n" +
+ " \"unique-document-total-size\": 3\n" +
+ " }\n" +
+ "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
index ec8e7855db6..adbf24bc4d1 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java
@@ -2,22 +2,21 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
public class RequestTest {
@Test
- public void testGetResultBeforeCompletion() {
+ void testGetResultBeforeCompletion() {
Request<String> r = new Request<>(Request.MasterState.MUST_BE_MASTER) {
@Override
public String calculateResult(Context context) {
return "foo";
}
};
- try{
+ try {
r.getResult();
fail();
} catch (InternalFailure e) {
@@ -25,7 +24,7 @@ public class RequestTest {
fail();
}
r.notifyCompleted();
- try{
+ try {
r.getResult();
fail();
} catch (InternalFailure e) {
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
index f2aa00ea13e..2e5b610a039 100644
--- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
+++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/ServiceTest.java
@@ -2,119 +2,119 @@
package com.yahoo.vespa.clustercontroller.core.restapiv2;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ServiceTest extends StateRestApiTest {
@Test
- public void testService() throws Exception {
+ void testService() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/distributor", 0));
String expected =
"{\"node\": {\n" +
- " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
- " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
- " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
- " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
- " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
- "}}";
+ " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/1\"},\n" +
+ " \"2\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/2\"},\n" +
+ " \"3\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/3\"},\n" +
+ " \"5\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/5\"},\n" +
+ " \"7\": {\"link\": \"\\/cluster\\/v2\\/music\\/distributor\\/7\"}\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
@Test
- public void testRecursiveCluster() throws Exception {
+ void testRecursiveCluster() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/distributor", 1));
String expected =
"{\"node\": {\n" +
- " \"1\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"2\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g1\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"down\",\n" +
- " \"reason\": \"Node not seen in slobrok.\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"3\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"5\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " },\n" +
- " \"7\": {\n" +
- " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
- " \"state\": {\n" +
- " \"generated\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"unit\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " },\n" +
- " \"user\": {\n" +
- " \"state\": \"up\",\n" +
- " \"reason\": \"\"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}}";
+ " \"1\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"2\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g1\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"down\",\n" +
+ " \"reason\": \"Node not seen in slobrok.\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"3\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"5\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"7\": {\n" +
+ " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" +
+ " \"state\": {\n" +
+ " \"generated\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"unit\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " },\n" +
+ " \"user\": {\n" +
+ " \"state\": \"up\",\n" +
+ " \"reason\": \"\"\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
}
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 685ad3f0b43..1b52194b270 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
@@ -18,9 +18,7 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStat
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import java.time.Clock;
import java.time.Duration;
@@ -32,11 +30,7 @@ import java.util.regex.Pattern;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.mock;
@@ -44,10 +38,6 @@ import static org.mockito.Mockito.when;
public class SetNodeStateTest extends StateRestApiTest {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
public static class SetUnitStateRequestImpl extends StateRequest implements SetUnitStateRequest {
private final Map<String, UnitState> newStates = new LinkedHashMap<>();
private Condition condition = Condition.FORCE;
@@ -176,7 +166,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testSimple() throws Exception {
+ void testSimple() throws Exception {
setUp(true);
verifyStateSet("down", "testing");
verifyStateSet("up", "foo");
@@ -186,14 +176,14 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testSetNodesForCluster() throws Exception {
+ void testSetNodesForCluster() throws Exception {
setUp(true);
verifyClusterSet("maintenance", "prepare for maintenance");
verifyClusterSet("up", "and we're back online");
}
@Test
- public void testShouldNotModifyDistributorSafe() throws Exception {
+ void testShouldNotModifyDistributorSafe() throws Exception {
setUp(false);
SetResponse setResponse = restAPI.setUnitState(new SetUnitStateRequestImpl("music/distributor/1")
.setNewState("user", "up", "whatever reason.")
@@ -204,7 +194,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testShouldModifyStorageSafeOk() throws Exception {
+ void testShouldModifyStorageSafeOk() throws Exception {
setUp(false);
SetResponse setResponse = restAPI.setUnitState(new SetUnitStateRequestImpl("music/storage/2")
.setNewState("user", "maintenance", "whatever reason.")
@@ -214,7 +204,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testShouldModifyStorageSafeBlocked() throws Exception {
+ void testShouldModifyStorageSafeBlocked() throws Exception {
// Sets up 2 groups: [0, 2, 4] and [1, 3, 5]
setUpMusicGroup(6, "");
@@ -254,7 +244,7 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void settingSafeMaintenanceWhenNodeDown() throws Exception {
+ void settingSafeMaintenanceWhenNodeDown() throws Exception {
// Sets up 2 groups: [0, 2, 4] and [1, 3, 5], with 1 being down
setUpMusicGroup(6, " .1.s:d");
assertUnitState(1, "generated", State.DOWN, "");
@@ -289,7 +279,7 @@ public class SetNodeStateTest extends StateRestApiTest {
UnitResponse response = restAPI.getState(new StateRequest(path, 0));
Response.NodeResponse nodeResponse = (Response.NodeResponse) response;
UnitState unitState = nodeResponse.getStatePerType().get(type);
- assertNotNull("No such type " + type + " at path " + path, unitState);
+ assertNotNull(unitState, "No such type " + type + " at path " + path);
assertEquals(state.toString().toLowerCase(), unitState.getId());
assertEquals(reason, unitState.getReason());
}
@@ -326,19 +316,18 @@ public class SetNodeStateTest extends StateRestApiTest {
Matcher matcher = Pattern.compile(reasonRegex).matcher(setResponse.getReason());
String errorMessage = "Expected reason to match '" + reasonRegex + "', but got: " + setResponse.getReason() + "'";
- assertTrue(errorMessage, matcher.find());
+ assertTrue(matcher.find(), errorMessage);
int alreadyMaintainedIndex = Integer.parseInt(matcher.group(1));
// Example: Say index 1 is in maintenance, and we try to set 2 in maintenance. This should
// NOT be allowed, since 2 is in a different group than 1.
- assertEquals("Tried to set " + index + " in maintenance, but got: " + setResponse.getReason(),
- index % 2, (alreadyMaintainedIndex + 1) % 2);
+ assertEquals(index % 2, (alreadyMaintainedIndex + 1) % 2, "Tried to set " + index + " in maintenance, but got: " + setResponse.getReason());
assertThat(setResponse.getWasModified(), is(false));
}
@Test
- public void testSetWantedStateOnNodeNotInSlobrok() throws Exception {
+ void testSetWantedStateOnNodeNotInSlobrok() throws Exception {
// Node 2 in cluster music does not have a valid NodeInfo due to passing true to setUp
setUp(true);
restAPI.setUnitState(new SetUnitStateRequestImpl("music/distributor/2").setNewState("user", "down", "borked node"));
@@ -348,73 +337,73 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testWrongUnit() throws Exception {
+ void testWrongUnit() throws Exception {
setUp(true);
String wrongUnitMessage = "State can only be set at cluster or node level";
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"").setNewState("user", "down", "testing"));
fail();
} catch (OperationNotSupportedForUnitException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
+ assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage());
}
// ... setting at cluster-level is allowed
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor").setNewState("user", "down", "testing"));
fail();
} catch (OperationNotSupportedForUnitException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
+ assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage());
}
// ... setting at node-level is allowed
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/0").setNewState("user", "down", "testing"));
fail();
} catch (OperationNotSupportedForUnitException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(wrongUnitMessage));
+ assertTrue(e.getMessage().contains(wrongUnitMessage), e.getMessage());
}
}
@Test
- public void testInvalidUnit() throws Exception {
+ void testInvalidUnit() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"foo").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/content").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/bah").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/10").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/0/1").setNewState("user", "down", "testing"));
fail();
} catch (MissingUnitException e) {
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/storage/1/bar").setNewState("user", "down", "testing"));
fail();
@@ -423,71 +412,71 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void testSettingInvalidStateType() throws Exception {
+ void testSettingInvalidStateType() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("foo", "down", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No new user state given"));
+ assertTrue(e.getMessage().contains("No new user state given"), e.getMessage());
}
}
@Test
- public void testSafeIsInvalidForSetNodesStatesForCluster() throws Exception {
+ void testSafeIsInvalidForSetNodesStatesForCluster() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl("music")
.setNewState("user", "maintenance", "example reason")
.setCondition(SetUnitStateRequest.Condition.SAFE));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains(
- "Setting all nodes in a cluster to a state is only supported with FORCE"));
+ assertTrue(e.getMessage().contains(
+ "Setting all nodes in a cluster to a state is only supported with FORCE"), e.getMessage());
}
}
@Test
- public void testSettingWrongStateType() throws Exception {
+ void testSettingWrongStateType() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("generated", "down", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No new user state given"));
+ assertTrue(e.getMessage().contains("No new user state given"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("unit", "down", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("No new user state given"));
+ assertTrue(e.getMessage().contains("No new user state given"), e.getMessage());
}
}
@Test
- public void testInvalidState() throws Exception {
+ void testInvalidState() throws Exception {
setUp(true);
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "initializing", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Invalid user state"));
+ assertTrue(e.getMessage().contains("Invalid user state"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "stopping", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Invalid user state"));
+ assertTrue(e.getMessage().contains("Invalid user state"), e.getMessage());
}
- try{
+ try {
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "foo", "testing"));
} catch (InvalidContentException e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Invalid user state"));
+ assertTrue(e.getMessage().contains("Invalid user state"), e.getMessage());
}
}
@Test
- public void testOverwriteReason() throws Exception {
+ void testOverwriteReason() throws Exception {
setUp(true);
restAPI.setUnitState(new SetUnitStateRequestImpl(
"music/distributor/1").setNewState("user", "down", "testing"));
@@ -508,19 +497,19 @@ public class SetNodeStateTest extends StateRestApiTest {
}
@Test
- public void set_node_state_requests_are_by_default_tagged_as_having_version_ack_dependency() {
+ void set_node_state_requests_are_by_default_tagged_as_having_version_ack_dependency() {
SetNodeStateRequest request = createDummySetNodeStateRequest();
assertTrue(request.hasVersionAckDependency());
}
@Test
- public void set_node_state_requests_not_initially_marked_as_failed() {
+ void set_node_state_requests_not_initially_marked_as_failed() {
SetNodeStateRequest request = createDummySetNodeStateRequest();
assertFalse(request.isFailed());
}
@Test
- public void set_node_state_requests_may_override_version_ack_dependency() {
+ void set_node_state_requests_may_override_version_ack_dependency() {
SetNodeStateRequest request = new SetNodeStateRequest(createDummyId(), new SetUnitStateRequestImpl("music/storage/1")
.setNewState("user", "maintenance", "whatever reason.")
.setResponseWait(SetUnitStateRequest.ResponseWait.NO_WAIT));
@@ -531,40 +520,42 @@ public class SetNodeStateTest extends StateRestApiTest {
// important to test (and expected to happen) for requests that have dependencies on cluster
// state version publishing.
@Test
- public void leadership_loss_fails_set_node_state_request() throws Exception {
- expectedException.expectMessage("Leadership lost before request could complete");
- expectedException.expect(UnknownMasterException.class);
+ void leadership_loss_fails_set_node_state_request() throws Exception {
+ Throwable exception = assertThrows(UnknownMasterException.class, () -> {
- SetNodeStateRequest request = createDummySetNodeStateRequest();
- request.handleFailure(RemoteClusterControllerTask.Failure.of(RemoteClusterControllerTask.FailureCondition.LEADERSHIP_LOST));
- request.getResult();
+ SetNodeStateRequest request = createDummySetNodeStateRequest();
+ request.handleFailure(RemoteClusterControllerTask.Failure.of(RemoteClusterControllerTask.FailureCondition.LEADERSHIP_LOST));
+ request.getResult();
+ });
+ assertTrue(exception.getMessage().contains("Leadership lost before request could complete"));
}
@Test
- public void leadership_loss_marks_request_as_failed_for_early_out_response() {
+ void leadership_loss_marks_request_as_failed_for_early_out_response() {
SetNodeStateRequest request = createDummySetNodeStateRequest();
request.handleFailure(RemoteClusterControllerTask.Failure.of(RemoteClusterControllerTask.FailureCondition.LEADERSHIP_LOST));
assertTrue(request.isFailed());
}
@Test
- public void deadline_exceeded_fails_set_node_state_request() throws Exception {
- expectedException.expectMessage("Task exceeded its version wait deadline: gremlins in the computer");
- expectedException.expect(DeadlineExceededException.class);
+ void deadline_exceeded_fails_set_node_state_request() throws Exception {
+ Throwable exception = assertThrows(DeadlineExceededException.class, () -> {
- SetNodeStateRequest request = createDummySetNodeStateRequest();
- request.handleFailure(RemoteClusterControllerTask.Failure.of(
- RemoteClusterControllerTask.FailureCondition.DEADLINE_EXCEEDED, "gremlins in the computer"));
- request.getResult();
+ SetNodeStateRequest request = createDummySetNodeStateRequest();
+ request.handleFailure(RemoteClusterControllerTask.Failure.of(
+ RemoteClusterControllerTask.FailureCondition.DEADLINE_EXCEEDED, "gremlins in the computer"));
+ request.getResult();
+ });
+ assertTrue(exception.getMessage().contains("Task exceeded its version wait deadline: gremlins in the computer"));
}
@Test
- public void no_fail_if_modified() throws StateRestApiException {
+ void no_fail_if_modified() throws StateRestApiException {
assertFalse(isFailed(true));
}
@Test
- public void fail_if_not_modified() throws StateRestApiException {
+ void fail_if_not_modified() throws StateRestApiException {
assertTrue(isFailed(false));
}
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 9f14b2e71d2..1bd17b11755 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
@@ -15,8 +15,8 @@ import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiE
import com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse;
import com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitState;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -43,13 +43,13 @@ public class SetNodeStateRequestTest {
private boolean inMasterMoratorium = false;
private boolean probe = false;
- @Before
+ @BeforeEach
public void setUp() {
newStates.put("user", unitState);
}
@Test
- public void testUpToMaintenance() throws StateRestApiException {
+ void testUpToMaintenance() throws StateRestApiException {
testSetStateRequest(
"maintenance",
State.UP, State.UP,
@@ -58,7 +58,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testProbingDoesntChangeState() throws StateRestApiException {
+ void testProbingDoesntChangeState() throws StateRestApiException {
probe = true;
testSetStateRequest(
"maintenance",
@@ -68,7 +68,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testUpToDown() throws StateRestApiException {
+ void testUpToDown() throws StateRestApiException {
testSetStateRequest(
"down",
State.UP, State.UP,
@@ -77,7 +77,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testMaintenanceToUp() throws StateRestApiException {
+ void testMaintenanceToUp() throws StateRestApiException {
testSetStateRequest(
"up",
State.MAINTENANCE, State.DOWN,
@@ -86,7 +86,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testDownToUp() throws StateRestApiException {
+ void testDownToUp() throws StateRestApiException {
testSetStateRequest(
"up",
State.DOWN, State.DOWN,
@@ -95,7 +95,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testOnlyStorageInMaintenaceToMaintenance() throws StateRestApiException {
+ void testOnlyStorageInMaintenaceToMaintenance() throws StateRestApiException {
testSetStateRequest(
"maintenance",
State.MAINTENANCE, State.UP,
@@ -104,7 +104,7 @@ public class SetNodeStateRequestTest {
}
@Test
- public void testNoOpMaintenaceToMaintenance() throws StateRestApiException {
+ void testNoOpMaintenaceToMaintenance() throws StateRestApiException {
testSetStateRequest(
"maintenance",
State.MAINTENANCE, State.DOWN,