Search in sources :

Example 1 with UnitResponse

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.

the class SetNodeStateTest method testSetWantedStateOnNodeNotInSlobrok.

@Test
public 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"));
    UnitResponse response = restAPI.getState(new StateRequest("music/distributor/2", 0));
    String expected = musicClusterExpectedUserStateStringWithUninitializedNode("east.g1", "down", "down", "down", "borked node");
    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 2 with UnitResponse

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.

the class ClusterListTest method testClusterList.

@Test
public 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" + "}}";
    assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
Also used : UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Test(org.junit.Test)

Example 3 with UnitResponse

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.

the class NodeTest method testNodeNotSeenInSlobrok.

@Test
public void testNodeNotSeenInSlobrok() throws Exception {
    setUp(true);
    ContentCluster old = music.context.cluster;
    music.context.cluster = new ContentCluster(old.getName(), old.getConfiguredNodes().values(), old.getDistribution(), 0, 0.0);
    NodeState currentState = new NodeState(NodeType.STORAGE, State.DOWN);
    currentState.setDescription("Not seen");
    music.context.currentConsolidatedState.setNodeState(new Node(NodeType.STORAGE, 1), currentState);
    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" + "}";
    assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Node(com.yahoo.vdslib.state.Node) ContentCluster(com.yahoo.vespa.clustercontroller.core.ContentCluster) Test(org.junit.Test)

Example 4 with UnitResponse

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.

the class NodeTest method testStorage.

@Test
public 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" + "  \"partition\": {\n" + "    \"0\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\\/0\"},\n" + "    \"1\": {\"link\": \"\\/cluster\\/v2\\/music\\/storage\\/1\\/1\"}\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 5 with UnitResponse

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse in project vespa by vespa-engine.

the class PartitionTest method testPartition.

@Test
public 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" + "}";
    assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
Also used : 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