blob: b4f836b78d0dc57af1092c61ccda4feb48490a31 (
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
54
|
// 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.MetricsPacket;
import org.junit.Test;
import java.nio.file.Path;
import java.time.Instant;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
/**
* @author olaa
*/
public class CoredumpGathererTest {
@Test
public void finds_one_coredump() {
List<MetricsPacket> actualPackets = CoredumpMetricGatherer.gatherCoredumpMetrics(new MockFileWrapper())
.stream()
.map(MetricsPacket.Builder::build)
.collect(Collectors.toList());
assertEquals(1, actualPackets.size());
MetricsPacket packet = actualPackets.get(0);
assertEquals("system-coredumps-processing", packet.service.id);
assertEquals(1, packet.statusCode);
}
static class MockFileWrapper extends FileWrapper {
@Override
Stream<Path> walkTree(Path path) {
return Stream.of(Path.of("dummy-path"));
}
@Override
Instant getLastModifiedTime(Path path) {
return Instant.now();
}
@Override
boolean isRegularFile(Path path) {
return true;
}
}
}
|