-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, the plugin displayed: ``` aThe uptime did not change since the last check cycle for these node(s): , b ``` Change-Id: Ibfd4696d4152e86262ea653eb207273cee5fa040
- Loading branch information
1 parent
af8d215
commit 1ec06b2
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/unit/cmk/plugins/collection/agent_based/test_if64.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
|
||
from cmk.base.plugins.agent_based import if64 | ||
from cmk.base.plugins.agent_based.agent_based_api.v1 import Result, State | ||
|
||
|
||
def test_check_timestamps_decrease() -> None: | ||
value_store: dict[str, object] = {} | ||
assert not list(if64._check_timestamps({"a": 1, "b": 2}, value_store)) # pylint: disable=protected-access | ||
assert list(if64._check_timestamps({"a": 0, "b": 1}, value_store)) == [ # pylint: disable=protected-access | ||
Result( | ||
state=State.OK, | ||
notice="The uptime has decreased since the last check cycle for these node(s): \nThe device might have rebooted or its uptime counter overflowed.", | ||
) | ||
] | ||
|
||
|
||
def test_check_timestamps_no_change() -> None: | ||
value_store: dict[str, object] = {} | ||
assert not list(if64._check_timestamps({"a": 1, "b": 2}, value_store)) # pylint: disable=protected-access | ||
assert list(if64._check_timestamps({"a": 1, "b": 2}, value_store)) == [ # pylint: disable=protected-access | ||
Result( | ||
state=State.OK, | ||
notice="The uptime did not change since the last check cycle for these node(s): a, b\nIt is likely that no new data was collected.", | ||
) | ||
] | ||
|
||
|
||
def test_check_timestamps_valid() -> None: | ||
value_store: dict[str, object] = {} | ||
assert not list(if64._check_timestamps({"a": 1, "b": 2}, value_store)) # pylint: disable=protected-access | ||
assert not list(if64._check_timestamps({"a": 61, "b": 62}, value_store)) # pylint: disable=protected-access |