blob: 783f95f2f272406e666c5d87e7f88c5dbb45c731 (
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
|
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.metricsproxy.node;
import ai.vespa.metricsproxy.metric.model.MetricId;
import ai.vespa.metricsproxy.metric.model.MetricsPacket;
import org.junit.Test;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
/**
* @author olaa
*/
public class HostLifeGathererTest {
@Test
public void host_is_alive() {
MetricsPacket packet = HostLifeGatherer.gatherHostLifeMetrics(new MockFileWrapper()).build();
Map<MetricId, Number> expectedMetrics = Map.of(MetricId.toMetricId("uptime"), 123d, MetricId.toMetricId("alive"), 1);
assertEquals("host_life", packet.service.id);
assertEquals(0, packet.statusCode);
assertEquals(expectedMetrics, packet.metrics());
}
static class MockFileWrapper extends FileWrapper {
@Override
List<String> readAllLines(Path path) {
return List.of("123 432");
}
}
}
|