blob: c5f2ea6960b3a4babccbc6dbb90fa4ceddab57c7 (
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
|
/*
* Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
*/
package ai.vespa.metricsproxy.service;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* @author Unknown
*/
public class SystemPollerTest {
@Test
public void testSystemPoller() {
DummyService s = new DummyService(0, "id");
List<VespaService> services = new ArrayList<>();
services.add(s);
SystemPoller poller = new SystemPoller(services, 60*5);
assertThat(s.isAlive(), is(false));
long n = poller.getPidJiffies(s);
assertThat(n, is(0L));
long[] memusage = poller.getMemoryUsage(s);
assertThat(memusage[0], is(0L));
assertThat(memusage[1], is(0L));
}
@Test
public void testCPUJiffies() {
String line = "cpu1 102180864 789 56766899 12800020140 1654757 0 0";
CpuJiffies n = new CpuJiffies(line);
assertThat(n.getCpuId(), is(1));
assertThat(n.getTotalJiffies(), is(12960623449L));
}
}
|