Module: check_mk
Branch: master
Commit: 2820a82cfb70a0ae12cddf5a9ccd8e019c8c9dd0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2820a82cfb70a0…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Wed May 16 15:36:09 2018 +0200
Win-agent: test section mem followed by systemtime
Check that the mem section is correctly formatted until
the end by adding section systemtime after it. This is necessary for
ensuring that e. g. the newline is not left out at the end of the
mem section.
Change-Id: I6e06825eeca92b95c5d5ea1b50427b183454356b
---
agents/windows/it/test_section_mem.py | 46 ++++++++++++++++++++++------------
agents/windows/it/test_section_mrpe.py | 23 ++++++++---------
2 files changed, 40 insertions(+), 29 deletions(-)
diff --git a/agents/windows/it/test_section_mem.py
b/agents/windows/it/test_section_mem.py
index 3a61f13..6219693 100644
--- a/agents/windows/it/test_section_mem.py
+++ b/agents/windows/it/test_section_mem.py
@@ -2,36 +2,50 @@
# -*- coding: utf-8; py-indent-offset: 4 -*-
import os
import pytest
+import re
from remote import actual_output, config, remotetest, wait_agent, write_config
+class Globals(object):
+ section = 'mem'
+ alone = True
+
+
@pytest.fixture
def testfile():
return os.path.basename(__file__)
-(a)pytest.fixture
-def testconfig(config):
- section = 'mem'
- config.set('global', 'sections', section)
+(a)pytest.fixture(params=['alone'one', 'with_systemtime'])
+def testconfig(request, config):
+ Globals.alone = request.param == 'alone'
+ if Globals.alone:
+ config.set('global', 'sections', Globals.section)
+ else:
+ config.set('global', 'sections', '%s systemtime' %
Globals.section)
config.set('global', 'crash_debug', 'yes')
return config
@pytest.fixture
def expected_output():
- return [
- r'<<<mem>>>',
- r'MemTotal:\s+\d+\skB',
- r'MemFree:\s+\d+\skB',
- r'SwapTotal:\s+\d+\skB',
- r'SwapFree:\s+\d+\skB',
- r'PageTotal:\s+\d+\skB',
- r'PageFree:\s+\d+\skB',
- r'VirtualTotal:\s+\d+\skB',
- r'VirtualFree:\s+\d+\skB'
+ expected = [
+ r'<<<mem>>>', #
+ r'MemTotal:\s+\d+\skB', #
+ r'MemFree:\s+\d+\skB', #
+ r'SwapTotal:\s+\d+\skB', #
+ r'SwapFree:\s+\d+\skB', #
+ r'PageTotal:\s+\d+\skB', #
+ r'PageFree:\s+\d+\skB', #
+ r'VirtualTotal:\s+\d+\skB', #
+ r'VirtualFree:\s+\d+\skB' #
]
+ if not Globals.alone:
+ expected += [re.escape(r'<<<systemtime>>>'),
r'\d+']
+ return expected
-def test_section_mem(testconfig, expected_output, actual_output, testfile):
- remotetest(expected_output, actual_output, testfile)
+def test_section_mem(request, testconfig, expected_output, actual_output,
+ testfile):
+ # request.node.name gives test name
+ remotetest(expected_output, actual_output, testfile, request.node.name)
diff --git a/agents/windows/it/test_section_mrpe.py
b/agents/windows/it/test_section_mrpe.py
index 73de0ac..13f79a6 100644
--- a/agents/windows/it/test_section_mrpe.py
+++ b/agents/windows/it/test_section_mrpe.py
@@ -16,7 +16,7 @@ class Globals(object):
param = 'foobar'
checkname = 'Dummy'
mrpedir = 'mrpe'
- includedir = 'test include' # space in directory name!
+ includedir = 'test include' # space in directory name!
cfgfile = 'test.cfg'
newline = -1
@@ -49,15 +49,12 @@ def testconfig(request, config):
def expected_output():
drive = r'[A-Z]:%s' % re.escape(os.sep)
expected = [
- re.escape(r'<<<%s>>>' % Globals.section),
- r'\(%s\) %s 2 CRIT - This check is always critical' %
- (Globals.pluginname, Globals.checkname)
- ]
+ re.escape(r'<<<%s>>>' % Globals.section),
+ r'\(%s\) %s 2 CRIT - This check is always critical' %
+ (Globals.pluginname, Globals.checkname)
+ ]
if not Globals.alone:
- expected += [
- re.escape(r'<<<systemtime>>>'),
- r'\d+'
- ]
+ expected += [re.escape(r'<<<systemtime>>>'),
r'\d+']
return expected
@@ -81,7 +78,8 @@ def manage_plugin(request):
cmds = [[
'ssh', sshopts,
'%s@%s' % (remoteuser, remote_ip),
- 'if not exist "%s" md "%s"' % (targetdir_windows,
targetdir_windows)
+ 'if not exist "%s" md "%s"' %
(targetdir_windows,
+ targetdir_windows)
], [
'scp', sshopts, source,
'%s@%s:"%s"' % (remoteuser, remote_ip, targetdir)
@@ -94,7 +92,7 @@ def manage_plugin(request):
if Globals.newline == 2:
path = path.replace('\\', '/')
cfg.write('check = %s "%s"%s' % (Globals.checkname, path,
'\n'
- if Globals.newline > 0 else ""))
+ if Globals.newline > 0 else
""))
yield
if platform.system() == 'Windows':
os.unlink(os.path.join(targetdir, Globals.pluginname))
@@ -105,5 +103,4 @@ def manage_plugin(request):
def test_section_mrpe(request, testconfig, expected_output, actual_output,
testfile):
# request.node.name gives test name
- remotetest(expected_output, actual_output, testfile,
- request.node.name)
+ remotetest(expected_output, actual_output, testfile, request.node.name)