Module: check_mk
Branch: master
Commit: 9efff1f965d896a3a9bf3b4b01acd91aebe1500a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9efff1f965d896…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Sep 7 12:28:58 2018 +0200
Add tests for WMI timeouts
Change-Id: I1edb4f9bdc23dabfbd4ffe25e5795b01be061a81
---
tests/unit/checks/test_wmi_check.py | 41 +++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/tests/unit/checks/test_wmi_check.py b/tests/unit/checks/test_wmi_check.py
new file mode 100644
index 0000000..78dce72
--- /dev/null
+++ b/tests/unit/checks/test_wmi_check.py
@@ -0,0 +1,41 @@
+import pytest
+
+from checktestlib import (
+ DiscoveryResult,
+ CheckResult,
+ assertDiscoveryResultsEqual,
+)
+
+from cmk_base.check_api import MKCounterWrapped
+
+pytestmark = pytest.mark.checks
+
+info_wmi_timeout = [[u'WMItimeout']]
+
+info_subsection_wmi_timeout = [
+ [u'[system_perf]'],
+ [u'WMItimeout'],
+ [u'[computer_system]'],
+ [u'name', u'unimportant', u'data'],
+]
+
+
+(a)pytest.mark.parametrize("check_name,info,expected"cted", [
+ ('wmi_webservices', info_wmi_timeout, []),
+ ('wmi_cpuload', info_subsection_wmi_timeout, []),
+])
+def test_wmi_cpu_load_discovery(check_manager, check_name, info, expected):
+ check = check_manager.get_check(check_name)
+ discovery_result = DiscoveryResult(check.run_discovery(check.run_parse(info)))
+ discovery_expected = DiscoveryResult(expected)
+ assertDiscoveryResultsEqual(discovery_result, discovery_expected)
+
+
+(a)pytest.mark.parametrize("check_name,info,expected"cted", [
+ ('wmi_webservices', info_wmi_timeout, None),
+ ('wmi_cpuload', info_subsection_wmi_timeout, None),
+])
+def test_wmi_cpuload_timeout_exceptions(check_manager, check_name, info, expected):
+ check = check_manager.get_check(check_name)
+ with pytest.raises(MKCounterWrapped):
+ CheckResult(check.run_check(None, {}, check.run_parse(info)))