Search in sources :

Example 11 with UnitResponse

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));
}
Also used : SetNodeStateRequest(com.yahoo.vespa.clustercontroller.core.restapiv2.requests.SetNodeStateRequest) SetUnitStateRequest(com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest) UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Test(org.junit.Test)

Example 12 with UnitResponse

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));
    }
}
Also used : SetNodeStateRequest(com.yahoo.vespa.clustercontroller.core.restapiv2.requests.SetNodeStateRequest) SetUnitStateRequest(com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest) UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Example 13 with UnitResponse

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));
}
Also used : UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Test(org.junit.Test)

Example 14 with UnitResponse

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));
}
Also used : UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Test(org.junit.Test)

Example 15 with UnitResponse

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));
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Test(org.junit.Test)

Aggregations

UnitResponse (com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse)18 Test (org.junit.Test)16 SetNodeStateRequest (com.yahoo.vespa.clustercontroller.core.restapiv2.requests.SetNodeStateRequest)4 SetUnitStateRequest (com.yahoo.vespa.clustercontroller.utils.staterestapi.requests.SetUnitStateRequest)4 StringContains.containsString (org.hamcrest.core.StringContains.containsString)4 JSONObject (org.codehaus.jettison.json.JSONObject)2 Node (com.yahoo.vdslib.state.Node)1 NodeState (com.yahoo.vdslib.state.NodeState)1 ContentCluster (com.yahoo.vespa.clustercontroller.core.ContentCluster)1