aboutsummaryrefslogtreecommitdiffstats
path: root/metrics-proxy/src/test/java/ai/vespa/metricsproxy/http/metrics/MetricsV2HandlerTest.java
blob: ff12610c7a64251d56ab5ae54bb8b8b9c678bf4c (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
50
51
52
53
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.http.metrics;

import ai.vespa.metricsproxy.metric.model.json.GenericApplicationModel;
import ai.vespa.metricsproxy.metric.model.json.GenericJsonModel;
import com.yahoo.container.jdisc.RequestHandlerTestDriver;
import org.junit.Before;
import org.junit.BeforeClass;

import java.util.concurrent.Executors;

import static ai.vespa.metricsproxy.http.metrics.MetricsV2Handler.V2_PATH;
import static ai.vespa.metricsproxy.http.metrics.MetricsV2Handler.VALUES_PATH;

/**
 * @author gjoranv
 */
@SuppressWarnings("UnstableApiUsage")
public class MetricsV2HandlerTest extends MetricsHandlerTestBase<GenericApplicationModel> {

    private static final String V2_URI = URI_BASE + V2_PATH;
    private static final String VALUES_URI = URI_BASE + VALUES_PATH;


    @BeforeClass
    public static void setup() {
        rootUri = V2_URI;
        valuesUri = VALUES_URI;
        var handler = new MetricsV2Handler(Executors.newSingleThreadExecutor(),
                                           getMetricsManager(),
                                           vespaServices,
                                           getMetricsConsumers(),
                                           nodeInfoConfig());
        testDriver = new RequestHandlerTestDriver(handler);
    }

    @Before
    public void initModelClass() {
        modelClass = GenericApplicationModel.class;
    }

    @Override
    GenericJsonModel getGenericJsonModel(GenericApplicationModel genericApplicationModel) {
        return genericApplicationModel.nodes.get(0);
    }

    private static NodeInfoConfig nodeInfoConfig() {
        return new NodeInfoConfig.Builder()
                .role("my-role")
                .hostname("my-hostname")
                .build();
    }
}