Exemplo n.º 1
0
def test_check_memory(params, meminfo, expected):
    copy_info = meminfo.copy()

    result = list(check_mem_used(params, meminfo))

    assert result == expected
    assert copy_info == meminfo
Exemplo n.º 2
0
def test_check_memory(params, meminfo, expected):
    copy_info = meminfo.copy()

    with value_store.context(CheckPluginName("mem_used_unittest"), None):
        result = list(check_mem_used(params, meminfo))

    assert result == expected
    assert copy_info == meminfo
Exemplo n.º 3
0
def test_check_discovery_total_zero():
    """
    Some containers do not provide memory info.
    Make sure they are discovered, and a proper error message is displayed
    """
    section = {"MemTotal": 0}
    assert list(discover_mem_used(section)) == [Service()]
    result, = check_mem_used({}, section)
    assert isinstance(result, Result)
    assert result.state == State.UNKNOWN
    assert result.summary.startswith("Reported total memory is 0 B")
Exemplo n.º 4
0
def test_check_memory_fails(params, meminfo, fail_with_exception):
    with pytest.raises(fail_with_exception):
        list(check_mem_used(params, meminfo))