Module: check_mk
Branch: master
Commit: 1d744052da29fdce5d72ad5ee332bc97923806dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1d744052da29fd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Feb 24 09:38:44 2017 +0100
Integration tests: When trying to install another package wait for other dpkg to finish
Change-Id: I1fb95a8ee1ed427d4648e95edbdf216052cc1148
---
tests/testlib/__init__.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/testlib/__init__.py b/tests/testlib/__init__.py
index fa54837..fdfd74a 100644
--- a/tests/testlib/__init__.py
+++ b/tests/testlib/__init__.py
@@ -137,6 +137,13 @@ class CMKVersion(object):
raise Exception("Failed to load package: %s" % self.package_url())
file(temp_package_path, "w").write(response.content)
+ # The following gdebi call will fail in case there is another package
+ # manager task being active. Try to wait for other task to finish. Sure
+ # this is not race free, but hope it's sufficient.
+ while os.system("sudo fuser /var/lib/dpkg/lock >/dev/null
2>&1") >> 8 == 0:
+ print("Waiting for other dpkg process to complete...\n")
+ time.sleep(1)
+
cmd = "sudo /usr/bin/gdebi --non-interactive %s" % temp_package_path
print(cmd)
sys.stdout.flush()