Skip to content

Commit

Permalink
[6.13.z] make wait_for_tasks must_succeed configurable also from caps…
Browse files Browse the repository at this point in the history
…ule mixins (#10663)

make wait_for_tasks must_succeed configurable also from capsule mixins (#10657)

(cherry picked from commit 7d2b8d7)

Co-authored-by: Peter Ondrejka <pondrejk@users.noreply.github.com>
  • Loading branch information
Satellite-QE and pondrejk authored Feb 9, 2023
1 parent 0ffcb7f commit 78ed78d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions robottelo/host_helpers/capsule_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ class CapsuleInfo:
"""Miscellaneous Capsule helper methods"""

def wait_for_tasks(
self, search_query, search_rate=1, max_tries=10, poll_rate=None, poll_timeout=None
self,
search_query,
search_rate=1,
max_tries=10,
poll_rate=None,
poll_timeout=None,
must_succeed=True,
):
"""Search for tasks by specified search query and poll them to ensure that
task has finished.
Expand All @@ -17,14 +23,15 @@ def wait_for_tasks(
the start of the next check-up. Parameter for ``sat.api.ForemanTask.poll()`` method.
:param poll_timeout: Maximum number of seconds to wait until timing out.
Parameter for ``sat.api.ForemanTask.poll()`` method.
:param must_succeed: Assert success result on finished task.
:return: List of ``sat.api.ForemanTasks`` entities.
:raises: ``AssertionError``. If not tasks were found until timeout.
"""
for _ in range(max_tries):
tasks = self.api.ForemanTask().search(query={'search': search_query})
if tasks:
for task in tasks:
task.poll(poll_rate=poll_rate, timeout=poll_timeout)
task.poll(poll_rate=poll_rate, timeout=poll_timeout, must_succeed=must_succeed)
break
else:
time.sleep(search_rate)
Expand Down

0 comments on commit 78ed78d

Please sign in to comment.