Module: check_mk
Branch: master
Commit: 6c55ec516f2f3b3240666316c846ba3e44fd5531
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6c55ec516f2f3b…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Dec 1 09:39:00 2017 +0100
Test for statgrab_cpu check function
This is a rudimentary test without any assertions as to the check result.
Change-Id: I2c29473c896ca5d0e58ae5601e2e68afaba442c7
---
tests/checks/test_statgrab_cpu_check.py | 34 +++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tests/checks/test_statgrab_cpu_check.py
b/tests/checks/test_statgrab_cpu_check.py
new file mode 100644
index 0000000..fe3ea1a
--- /dev/null
+++ b/tests/checks/test_statgrab_cpu_check.py
@@ -0,0 +1,34 @@
+import pytest
+import pprint
+from cmk_base.check_api import MKCounterWrapped
+
+pytestmark = pytest.mark.checks
+
+
+@pytest.mark.parametrize("timepoints,time_to_info,params,expected_results", [
+([60],lambda t: [[u'ctxsw', u'%d' % int(t*50)],
+ [u'idle', int(t*50)],
+ [u'intrs',int(t*50)],
+ [u'iowait',int(t*50)],
+ [u'kernel',int(t*50)],
+ [u'nice',int(t*50)],
+ [u'nvctxsw',int(t*50)],
+ [u'softintrs',int(t*50)],
+ [u'swap',int(t*50)],
+ [u'syscalls',int(t*50)],
+ [u'systime',int(t*50)],
+ [u'total',int(t*50)],
+ [u'user',int(t*50)],
+ [u'vctxsw',int(t*50)]],
+ {}, None),
+])
+def test_statgrab_cpu_check(check_manager, monkeypatch, timepoints, time_to_info, params,
expected_results):
+ import time
+ check = check_manager.get_check("statgrab_cpu")
+ try:
+ result = list(check.run_check(None, params, time_to_info(0)))
+ except MKCounterWrapped:
+ pass
+ for t in timepoints:
+ monkeypatch.setattr("time.time", lambda: t)
+ result = list(check.run_check(None, params, time_to_info(t)))