parent
7e5a8a51c3
commit
7de48fe5ff
2 changed files with 17 additions and 19 deletions
|
|
@ -366,7 +366,10 @@ class BaseTaskHandler(object):
|
|||
"""
|
||||
|
||||
if canfail is None:
|
||||
canfail = []
|
||||
checked = set()
|
||||
else:
|
||||
# canfail task are marked as checked
|
||||
checked = set(canfail)
|
||||
if isinstance(subtasks, int):
|
||||
# allow single integer w/o enclosing list
|
||||
subtasks = [subtasks]
|
||||
|
|
@ -381,23 +384,18 @@ class BaseTaskHandler(object):
|
|||
elif len(finished) > 0:
|
||||
if all:
|
||||
if failany:
|
||||
failed = False
|
||||
for task in finished:
|
||||
if task in canfail:
|
||||
# no point in checking
|
||||
continue
|
||||
# we care only about tasks which are not correctly
|
||||
# finished and in same time not in canfail list
|
||||
for task in set(finished) - checked:
|
||||
try:
|
||||
self.session.getTaskResult(task)
|
||||
except (koji.GenericError, xmlrpclib.Fault) as task_error:
|
||||
self.logger.info("task %s failed or was canceled" % task)
|
||||
failed = True
|
||||
break
|
||||
if failed:
|
||||
self.logger.info("at least one task failed or was canceled, cancelling unfinished tasks")
|
||||
self.session.cancelTaskChildren(self.id)
|
||||
# reraise the original error now, rather than waiting for
|
||||
# an error in taskWaitResults()
|
||||
raise task_error
|
||||
checked.add(task)
|
||||
except (koji.GenericError, xmlrpclib.Fault) as ex:
|
||||
self.logger.info("task %s failed or was canceled, cancelling unfinished tasks" % task)
|
||||
self.session.cancelTaskChildren(self.id)
|
||||
# reraise the original error now, rather than waiting for
|
||||
# an error in taskWaitResults()
|
||||
raise
|
||||
else:
|
||||
# at least one done
|
||||
break
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ class TasksTestCase(unittest.TestCase):
|
|||
obj.session.host.taskWaitResults.return_value = taskWaitResults
|
||||
self.assertEquals(obj.wait([1551234, 1591234]), dict(taskWaitResults))
|
||||
obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234])
|
||||
obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234], canfail=[])
|
||||
obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234], canfail=None)
|
||||
|
||||
def test_BaseTaskHandler_wait_some_not_done(self):
|
||||
""" Tests that the wait function returns the one finished subtask results of
|
||||
|
|
@ -244,7 +244,7 @@ class TasksTestCase(unittest.TestCase):
|
|||
obj.session.host.taskWaitResults.return_value = taskWaitResults
|
||||
self.assertEquals(obj.wait([1551234, 1591234]), dict(taskWaitResults))
|
||||
obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234])
|
||||
obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234], canfail=[])
|
||||
obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234], canfail=None)
|
||||
|
||||
@patch('signal.pause', return_value=None)
|
||||
def test_BaseTaskHandler_wait_some_not_done_all_set(self, mock_signal_pause):
|
||||
|
|
@ -284,7 +284,7 @@ class TasksTestCase(unittest.TestCase):
|
|||
obj.session.host.taskSetWait.assert_called_once_with(12345678, [1551234, 1591234])
|
||||
obj.session.host.taskWait.assert_has_calls([call(12345678), call(12345678)])
|
||||
mock_signal_pause.assert_called_once_with()
|
||||
obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234], canfail=[])
|
||||
obj.session.host.taskWaitResults.assert_called_once_with(12345678, [1551234, 1591234], canfail=None)
|
||||
|
||||
def test_BaseTaskHandler_wait_some_not_done_all_set_failany_set_failed_task(self):
|
||||
""" Tests that the wait function raises an exception when one of the subtask fails when the failany flag is set
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue