forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_esx_vsphere_hostsystem_maintenance.py
71 lines (64 loc) · 2.36 KB
/
test_esx_vsphere_hostsystem_maintenance.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
# Copyright (C) 2019 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 collections.abc import Mapping
import pytest
from cmk.checkengine.checking import CheckPluginName
from cmk.base.api.agent_based.register import AgentBasedPlugins
from cmk.agent_based.v1 import Result, State
from cmk.agent_based.v1.type_defs import CheckResult
from cmk.plugins.lib.esx_vsphere import Section
@pytest.mark.parametrize(
"section, params, expected_check_result",
[
pytest.param(
Section(
[
("runtime.inMaintenanceMode", ["false"]),
]
),
{"target_state": "false"},
[Result(state=State.OK, summary="System not in Maintenance mode")],
id=("Maintenance mode off"),
),
pytest.param(
Section(
[
("runtime.inMaintenanceMode", ["false"]),
]
),
{"target_state": "true"},
[Result(state=State.CRIT, summary="System not in Maintenance mode")],
id=("Maintenance mode off but want on"),
),
pytest.param(
Section(
[
("runtime.inMaintenanceMode", ["true"]),
]
),
{"target_state": "true"},
[Result(state=State.OK, summary="System running is in Maintenance mode")],
id=("Maintenance mode on"),
),
pytest.param(
Section(
[
("runtime.inMaintenanceMode", ["true"]),
]
),
{"target_state": "false"},
[Result(state=State.CRIT, summary="System running is in Maintenance mode")],
id=("Maintenance mode on but want off"),
),
],
)
def test_check_esx_vsphere_hostsystem_maintenance(
agent_based_plugins: AgentBasedPlugins,
section: Section,
params: Mapping[str, str],
expected_check_result: CheckResult,
) -> None:
check = agent_based_plugins.check_plugins[CheckPluginName("esx_vsphere_hostsystem_maintenance")]
assert list(check.check_function(params=params, section=section)) == expected_check_result