aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/PartitionTest.java
blob: 65acea02d345d81bb18a9c647c928ac3decd7cdf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
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.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class PartitionTest extends StateRestApiTest {

    @Test
    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));
    }

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