aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/jdisc/state/CoredumpGathererTest.java
blob: 5cec6c471fec9079a8495e207e11fc60c6e8ba34 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.state;

import com.fasterxml.jackson.databind.JsonNode;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.util.stream.Stream;

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


/**
 * @author olaa
 */
public class CoredumpGathererTest {

    @Test
    void finds_one_coredump()  {
        JsonNode packet = CoredumpGatherer.gatherCoredumpMetrics(new MockFileWrapper());

        assertEquals("system-coredumps-processing", packet.get("application").textValue());
        assertEquals(1, packet.get("status_code").intValue());
        assertEquals("Found 1 coredump(s)", packet.get("status_msg").textValue());

    }

    static class MockFileWrapper extends FileWrapper {


        @Override
        Stream<Path> walkTree(Path path)  {
            return Stream.of(Path.of("dummy-path"));
        }

        @Override
        boolean isRegularFile(Path path) {
            return true;
        }
    }

}