Module: check_mk
Branch: master
Commit: 8b94c2f5c9822735a975107f29ec48f8e0ae629c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b94c2f5c98227…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 3 11:51:36 2017 +0200
Fake omd version for tests: Also replace version in omd bin
Change-Id: I926647e4c28bb996e40cc8fa7c47d109c145696b
---
tests/testlib/__init__.py | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 35e882a..aea9389 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -295,21 +295,8 @@ class Site(object):
if not self.version.is_installed():
self.version.install()
- # When using the Git version, the original version files will be
- # replaced by the .f12 scripts. When tests are running in parallel
- # with the same daily build, this may lead to problems when the .f12
- # scripts are executed while another test is loading affected files
- # As workaround we copy the original files to a test specific version
- # Don't do this in non CI environments
- if self.update_with_git and os.environ.get("BUILD_NUMBER"):
- src_path = self.version.version_path()
- new_version_name = "%s-%s" % (self.version.version, os.environ["BUILD_NUMBER"])
- self.version = CMKVersion(new_version_name, self.version._edition, self.version._branch)
- print("Copy CMK '%s' to '%s'" % (src_path, self.version.version_path()))
- cmd = "sudo /bin/cp -pr %s %s" % (src_path, self.version.version_path())
- if os.system(cmd) >> 8 != 0:
- raise Exception("Failed to copy Check_MK: %s" % cmd)
-
+ if self.update_with_git:
+ self._copy_omd_version_for_test()
if not self.reuse and self.exists():
raise Exception("The site %s already exists." % self.id)
@@ -327,6 +314,32 @@ class Site(object):
self._enable_mod_python_debug()
+ # When using the Git version, the original version files will be
+ # replaced by the .f12 scripts. When tests are running in parallel
+ # with the same daily build, this may lead to problems when the .f12
+ # scripts are executed while another test is loading affected files
+ # As workaround we copy the original files to a test specific version
+ def _copy_omd_version_for_test(self):
+ if not os.environ.get("BUILD_NUMBER"):
+ return # Don't do this in non CI environments
+
+ src_version, src_path = self.version.version, self.version.version_path()
+ new_version_name = "%s-%s" % (src_version, os.environ["BUILD_NUMBER"])
+ self.version = CMKVersion(new_version_name, self.version._edition, self.version._branch)
+
+ print("Copy CMK '%s' to '%s'" % (src_path, self.version.version_path()))
+ assert not os.path.exists(self.version.version_path()), \
+ "New version path '%s' already exists" % self.version.version_path()
+
+ cmd = "sudo /bin/cp -pr %s %s" % (src_path, self.version.version_path())
+ if os.system(cmd) >> 8 != 0:
+ raise Exception("Failed to copy Check_MK: %s" % cmd)
+
+ if os.system("sudo sed -i \"s|%s|%s|g\" %s/bin/omd" %
+ (src_version, new_version_name, self.version.version_path())) >> 8 != 0:
+ raise Exception("Failed to set new version to bin/omd")
+
+
def _update_with_f12_files(self):
paths = [
cmk_path() + "/bin",
Module: check_mk
Branch: master
Commit: 5fd4153e8f040417cf161d001cc5d30c24cc2619
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5fd4153e8f0404…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 3 10:40:08 2017 +0200
tests: Trying to fix random issues during crawls and integration tests
Change-Id: I67b03504d1caf013307e8b71809fcd34c350861e
---
tests/testlib/__init__.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index a108e98..35e882a 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -65,6 +65,10 @@ class CMKVersion(object):
CRE = "cre"
def __init__(self, version, edition, branch):
+ self._version = version
+ self._edition = edition
+ self._branch = branch
+
self.set_version(version, branch)
if len(edition) != 3:
@@ -85,6 +89,7 @@ class CMKVersion(object):
def set_version(self, version, branch):
if version in [ CMKVersion.DAILY, CMKVersion.GIT ]:
date_part = time.strftime("%Y.%m.%d")
+
if branch != "master":
self.version = "%s-%s" % (branch, date_part)
else:
@@ -290,6 +295,22 @@ class Site(object):
if not self.version.is_installed():
self.version.install()
+ # When using the Git version, the original version files will be
+ # replaced by the .f12 scripts. When tests are running in parallel
+ # with the same daily build, this may lead to problems when the .f12
+ # scripts are executed while another test is loading affected files
+ # As workaround we copy the original files to a test specific version
+ # Don't do this in non CI environments
+ if self.update_with_git and os.environ.get("BUILD_NUMBER"):
+ src_path = self.version.version_path()
+ new_version_name = "%s-%s" % (self.version.version, os.environ["BUILD_NUMBER"])
+ self.version = CMKVersion(new_version_name, self.version._edition, self.version._branch)
+ print("Copy CMK '%s' to '%s'" % (src_path, self.version.version_path()))
+ cmd = "sudo /bin/cp -pr %s %s" % (src_path, self.version.version_path())
+ if os.system(cmd) >> 8 != 0:
+ raise Exception("Failed to copy Check_MK: %s" % cmd)
+
+
if not self.reuse and self.exists():
raise Exception("The site %s already exists." % self.id)