Module: check_mk
Branch: master
Commit: c39d6d0d01436a55145d162340d47284baab587d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c39d6d0d01436a…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Jan 26 10:58:21 2018 +0100
Tests: Use older daily builds if today's build is unavailable
Change-Id: I2a9fb3bae37816db648dc9db9a87bcc07c037b4d
---
tests/testlib/__init__.py | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index 19612fa..28ed02f 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -74,14 +74,15 @@ class CMKVersion(object):
self._edition = edition
self._branch = branch
- self.set_version(version, branch)
-
if len(edition) != 3:
raise Exception("Invalid edition: %s. Must be short notation (cee, cre,
...)")
self.edition_short = edition
self._credentials = ("d-vonheute", "lOBFsgAH")
+ self.set_version(version, branch)
+
+
def get_default_version(self):
if os.path.exists("/etc/alternatives/omd"):
@@ -93,12 +94,18 @@ class CMKVersion(object):
def set_version(self, version, branch):
if version in [ CMKVersion.DAILY, CMKVersion.GIT ]:
- date_part = time.strftime("%Y.%m.%d")
+ for days_ago in range(7): # Try a week's worth of versions. If none of
these exist, there's likely another issue at play.
+ localtime = time.localtime(time.time() - 60*60*24*days_ago)
- if branch != "master":
- self.version = "%s-%s" % (branch, date_part)
- else:
- self.version = date_part
+ date_part = time.strftime("%Y.%m.%d", localtime)
+
+ if branch != "master":
+ self.version = "%s-%s" % (branch, date_part)
+ else:
+ self.version = date_part
+
+ if self._version_available():
+ break
elif version == CMKVersion.DEFAULT:
self.version = self.get_default_version()
@@ -167,6 +174,12 @@ class CMKVersion(object):
return os.path.exists(self.version_path())
+ def _version_available(self):
+ response = requests.head(self.package_url(), auth=self._credentials,
verify=False)
+ available_on_server = response.status_code == 200
+ return self.is_installed() or available_on_server
+
+
def install(self):
temp_package_path = "/tmp/%s" % self.package_name()