Add sleep after drivetrain update to wait salt completed all jobs
PROD-36385
Change-Id: I9b28e8a35abb666fe5180274e5c3136b4e8bfb1a
diff --git a/tcp_tests/managers/saltmanager.py b/tcp_tests/managers/saltmanager.py
index 1f63ae9..fbbb9b8 100644
--- a/tcp_tests/managers/saltmanager.py
+++ b/tcp_tests/managers/saltmanager.py
@@ -16,6 +16,7 @@
import pkg_resources
from collections import defaultdict
+from polling import poll
from datetime import datetime
from pepper import libpepper
@@ -116,6 +117,10 @@
def local_async(self, tgt, fun, args=None, kwargs=None, timeout=None):
return self.api.local_async(tgt, fun, args, kwargs, timeout=timeout)
+ def runner(self, fun, args=None, **kwargs):
+ response = self.api.runner(fun, arg=args, **kwargs)
+ return response.get("return")
+
def lookup_result(self, jid):
return self.api.lookup_jid(jid)
@@ -194,6 +199,20 @@
result = self.local(tgt=tgt, fun='grains.get', args=grains)
return result['return']
+ def wait_jobs_completed(self, timeout=60, interval=5):
+ """
+ :param timeout: int, time seconds to wait
+ :param interval: int, time in second between attempts
+ :return: None
+ """
+ # TODO(harhipova) PROD-36434 : need to check that last job completed
+ # with successful result
+ poll(
+ target=lambda: self.runner('jobs.active')[0] == {},
+ timeout=timeout,
+ step=interval
+ )
+
def get_ssh_data(self):
"""Generate ssh config for Underlay