Module: check_mk
Branch: master
Commit: caa86253da982e883d792709d7cd1be08a03b2c5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=caa86253da982e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 5 08:13:18 2018 +0100
Simplified local integration test execution a bit
Integration tests are now executed in dedicated sites, not
heute / stable anymore. These sites are named "int_[branch_part]".
While the branch part is calculated out of the current git branch
name. The branch names are mangled like this: 1. split by "/" and only
the last element is used, then all characters except the ones allowed
in site IDs are strippted.
This should make local integration test execution a bit more straight forward
because there is no relation to the development sites anymore.
Change-Id: Idd9320f5e43eca53b79180251ee9e36e98ff4269
---
tests/conftest.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index 9a338c5..c407e50 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -10,6 +10,7 @@ pytest.register_assert_rewrite(
"unit.cmk.gui.tools")
import _pytest.monkeypatch
+import re
import collections
import errno
import os
@@ -250,10 +251,15 @@ def _get_site_object():
def _site_id():
site_id = os.environ.get("OMD_SITE")
- if site_id is None:
- site_id = file(testlib.repo_path() + "/.site").read().strip()
- os.putenv("OMD_SITE", site_id)
+ if site_id is not None:
+ return site_id
+ branch_name = os.environ.get("BRANCH", testlib.current_branch_name())
+ # Split by / and get last element, remove unwanted chars
+ branch_part = re.sub("[^a-zA-Z0-9_]", "",
branch_name.split("/")[-1])
+ site_id = "int_%s" % branch_part
+
+ os.putenv("OMD_SITE", site_id)
return site_id