use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.
the class SetNodeStateTest method testOverwriteReason.
@Test
public void testOverwriteReason() throws Exception {
setUp(true);
restAPI.setUnitState(new SetUnitStateRequestImpl("music/distributor/1").setNewState("user", "down", "testing"));
restAPI.setUnitState(new SetUnitStateRequestImpl("music/distributor/1").setNewState("user", "down", "testing more"));
UnitResponse response = restAPI.getState(new StateRequest("music/distributor/1", 0));
String expected = musicClusterExpectedUserStateString("east.g2", "up", "up", "down", "testing more");
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.
the class SetNodeStateTest method verifyClusterSet.
private void verifyClusterSet(String state, String reason) throws Exception {
restAPI.setUnitState(new SetUnitStateRequestImpl("music").setNewState("user", state, reason));
for (int index : new int[] { 1, 2, 3, 5, 7 }) {
UnitResponse response = restAPI.getState(new StateRequest("music/storage/" + index, 0));
String actualState = response.getCurrentState().getStatePerType().get("user").getId();
assertThat(actualState, is(state.toLowerCase()));
String actualReason = response.getCurrentState().getStatePerType().get("user").getReason();
assertThat(actualReason, is(reason));
}
}
use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.
the class ClusterListTest method testRecursiveClusterList.
@Test
public 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" + "}}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.
the class NodeTest method testDistributor.
@Test
public 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" + "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.
the class NodeTest method testRecursiveStorageClusterDoesNotIncludePerNodeStatsOrMetrics.
@Test
public void testRecursiveStorageClusterDoesNotIncludePerNodeStatsOrMetrics() throws Exception {
setUp(true);
UnitResponse response = restAPI.getState(new StateRequest("music/storage", 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" + " \"partition\": {\n" + " \"0\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\\/0\"},\n" + " \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\\/1\"}\n" + " }\n" + "}";
JSONObject json = jsonWriter.createJson(response);
assertEquals(expected, json.getJSONObject("node").getJSONObject("1").toString(2));
}
Aggregations