mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Don't raise an exception at the end of a task if we are running unit tests
This commit is contained in:
@@ -391,7 +391,6 @@ class Job(CommonTask):
|
|||||||
dependent_tasks = [{'type': r['type'], 'id': r['obj'].id} for r in runnable_tasks[idx:]] + [thisjob]
|
dependent_tasks = [{'type': r['type'], 'id': r['obj'].id} for r in runnable_tasks[idx:]] + [thisjob]
|
||||||
run_tasks.append(runnable_tasks[idx]['sig'].set(link_error=handle_work_error.s(subtasks=dependent_tasks)))
|
run_tasks.append(runnable_tasks[idx]['sig'].set(link_error=handle_work_error.s(subtasks=dependent_tasks)))
|
||||||
run_tasks.append(task_class().si(self.pk, **opts).set(link_error=handle_work_error.s(subtasks=[thisjob])))
|
run_tasks.append(task_class().si(self.pk, **opts).set(link_error=handle_work_error.s(subtasks=[thisjob])))
|
||||||
print runnable_tasks
|
|
||||||
res = chain(run_tasks)()
|
res = chain(run_tasks)()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ class BaseTask(Task):
|
|||||||
result_traceback=tb,
|
result_traceback=tb,
|
||||||
output_replacements=output_replacements)
|
output_replacements=output_replacements)
|
||||||
self.post_run_hook(instance, **kwargs)
|
self.post_run_hook(instance, **kwargs)
|
||||||
if status != 'successful':
|
if status != 'successful' and not has hasattr(settings, 'CELERY_UNIT_TEST'):
|
||||||
# Raising an exception will mark the job as 'failed' in celery
|
# Raising an exception will mark the job as 'failed' in celery
|
||||||
# and will stop a task chain from continuing to execute
|
# and will stop a task chain from continuing to execute
|
||||||
raise Exception("Task %s(pk:%s) encountered an error" % (str(self.model.__class__), str(pk)))
|
raise Exception("Task %s(pk:%s) encountered an error" % (str(self.model.__class__), str(pk)))
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class BaseTestMixin(object):
|
|||||||
# callbacks.
|
# callbacks.
|
||||||
if settings.BROKER_URL.startswith('amqp://'):
|
if settings.BROKER_URL.startswith('amqp://'):
|
||||||
settings.BROKER_URL = 'django://'
|
settings.BROKER_URL = 'django://'
|
||||||
|
settings.CELERY_UNIT_TEST = True
|
||||||
# Make temp job status directory for unit tests.
|
# Make temp job status directory for unit tests.
|
||||||
job_status_dir = tempfile.mkdtemp()
|
job_status_dir = tempfile.mkdtemp()
|
||||||
self._temp_project_dirs.append(job_status_dir)
|
self._temp_project_dirs.append(job_status_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user