Module: check_mk
Branch: master
Commit: c410cebf8e6376c852cf55ec212edae594ccacd3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c410cebf8e6376…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 24 12:39:34 2018 +0200
Merged all pylint tests into a single test
* The check / inventory and agent plugins still need to be compiled
to a fake modules
* Merged check and inventory plugins together to a single compiled file
to prevent checking the checks twice
* Execute all pylint checks using a single call
Reduces total execution time from 4:00 to 2:30 min
Change-Id: If3c3cdd469187d20def04428c40cf294aaf66ea6
---
tests/pylint/test_pylint.py | 54 ++++++++++-----------------------------------
1 file changed, 12 insertions(+), 42 deletions(-)
diff --git a/tests/pylint/test_pylint.py b/tests/pylint/test_pylint.py
index 859cbad..d96e893 100755
--- a/tests/pylint/test_pylint.py
+++ b/tests/pylint/test_pylint.py
@@ -33,7 +33,7 @@ def pylint_test_dir():
shutil.rmtree(test_dir)
-def test_pylint_misc():
+def test_pylint(pylint_test_dir):
# Only specify the path to python packages or modules here
modules_or_packages = [
# Check_MK base
@@ -59,6 +59,14 @@ def test_pylint_misc():
"managed/cmk/gui/cme",
]
+ # Add the compiled files for things that are no modules yet
+ file(pylint_test_dir + "/__init__.py", "w")
+ _compile_check_and_inventory_plugins(pylint_test_dir)
+ _compile_bakery_plugins(pylint_test_dir)
+ modules_or_packages += [
+ pylint_test_dir,
+ ]
+
# We use our own search logic to find scripts without python extension
search_paths = [
"omd/packages/omd",
@@ -80,8 +88,8 @@ def test_pylint_misc():
assert exit_code == 0, "PyLint found an error"
-def test_pylint_inventory_plugins(pylint_test_dir):
- with open(pylint_test_dir + "/cmk-inventory-plugins.py", "w") as
f:
+def _compile_check_and_inventory_plugins(pylint_test_dir):
+ with open(pylint_test_dir + "/cmk_checks.py", "w") as f:
# Fake data structures where checks register (See cmk_base/checks.py)
f.write("""
@@ -114,8 +122,6 @@ def inv_tree(path, default_value=None):
# add the modules
pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
-
- # add the modules
pylint_cmk.add_file(f, repo_path() + "/cmk_base/inventory_plugins.py")
# Now add the checks
@@ -126,41 +132,8 @@ def inv_tree(path, default_value=None):
for path in pylint_cmk.check_files(repo_path() + "/inventory"):
pylint_cmk.add_file(f, path)
- exit_code = pylint_cmk.run_pylint(pylint_test_dir)
- assert exit_code == 0, "PyLint found an error in inventory plugins"
-
-def test_pylint_checks(pylint_test_dir):
- with open(pylint_test_dir + "/cmk-checks.py", "w") as f:
-
- # Fake data structures where checks register (See cmk_base/checks.py)
- f.write("""
-# -*- encoding: utf-8 -*-
-check_info = {}
-check_includes = {}
-precompile_params = {}
-check_default_levels = {}
-factory_settings = {}
-check_config_variables = []
-snmp_info = {}
-snmp_scan_functions = {}
-active_check_info = {}
-special_agent_info = {}
-""")
-
- # add the modules
- pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
-
- # Now add the checks
- for path in pylint_cmk.check_files(repo_path() + "/checks"):
- pylint_cmk.add_file(f, path)
-
- exit_code = pylint_cmk.run_pylint(pylint_test_dir)
- assert exit_code == 0, "PyLint found an error in checks, inventory " \
- "or agent bakery plugins"
-
-
-def test_pylint_bakery_plugins(pylint_test_dir):
+def _compile_bakery_plugins(pylint_test_dir):
with open(pylint_test_dir + "/cmk_bakery_plugins.py", "w") as f:
pylint_cmk.add_file(f, os.path.realpath(os.path.join(cmc_path(),
"cmk_base/cee/agent_bakery_plugins.py")))
@@ -168,6 +141,3 @@ def test_pylint_bakery_plugins(pylint_test_dir):
# Also add bakery plugins
for path in pylint_cmk.check_files(os.path.join(cmc_path(),
"agents/bakery")):
pylint_cmk.add_file(f, path)
-
- exit_code = pylint_cmk.run_pylint(pylint_test_dir)
- assert exit_code == 0, "PyLint found an error in agent bakery plugins"