Allow non-inclusion of setup task in junit report
The JUnit callback pushes every tasks in the report. Even the setup tasks that - sometime - might clutter the report rather than being useful, based on one needs. This PR allows one to specify whether or not the setup tasks should be part of the final report, defaulting to True to be backward compatible to what is already in place today.
This commit is contained in:
parent
c812396793
commit
dc420fc5fa
1 changed files with 16 additions and 2 deletions
|
@ -45,6 +45,12 @@ DOCUMENTATION = '''
|
||||||
description: Consider failed tasks as a junit test failure even if ignore_on_error is set
|
description: Consider failed tasks as a junit test failure even if ignore_on_error is set
|
||||||
env:
|
env:
|
||||||
- name: JUNIT_FAIL_ON_IGNORE
|
- name: JUNIT_FAIL_ON_IGNORE
|
||||||
|
include_setup_tasks_in_report:
|
||||||
|
name: JUnit include setup tasks in report
|
||||||
|
default: True
|
||||||
|
description: Should the setup tasks be included in the final report
|
||||||
|
env:
|
||||||
|
- name: JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT
|
||||||
requirements:
|
requirements:
|
||||||
- whitelist in configuration
|
- whitelist in configuration
|
||||||
- junit_xml (python lib)
|
- junit_xml (python lib)
|
||||||
|
@ -96,6 +102,8 @@ class CallbackModule(CallbackBase):
|
||||||
Default: False
|
Default: False
|
||||||
JUNIT_FAIL_ON_IGNORE (optional): Consider failed tasks as a junit test failure even if ignore_on_error is set
|
JUNIT_FAIL_ON_IGNORE (optional): Consider failed tasks as a junit test failure even if ignore_on_error is set
|
||||||
Default: False
|
Default: False
|
||||||
|
JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT (optional): Should the setup tasks be included in the final report
|
||||||
|
Default: True
|
||||||
|
|
||||||
Requires:
|
Requires:
|
||||||
junit_xml
|
junit_xml
|
||||||
|
@ -114,6 +122,7 @@ class CallbackModule(CallbackBase):
|
||||||
self._task_class = os.getenv('JUNIT_TASK_CLASS', 'False').lower()
|
self._task_class = os.getenv('JUNIT_TASK_CLASS', 'False').lower()
|
||||||
self._fail_on_change = os.getenv('JUNIT_FAIL_ON_CHANGE', 'False').lower()
|
self._fail_on_change = os.getenv('JUNIT_FAIL_ON_CHANGE', 'False').lower()
|
||||||
self._fail_on_ignore = os.getenv('JUNIT_FAIL_ON_IGNORE', 'False').lower()
|
self._fail_on_ignore = os.getenv('JUNIT_FAIL_ON_IGNORE', 'False').lower()
|
||||||
|
self._include_setup_tasks_in_report = os.getenv('JUNIT_INCLUDE_SETUP_TASKS_IN_REPORT', 'True').lower()
|
||||||
self._playbook_path = None
|
self._playbook_path = None
|
||||||
self._playbook_name = None
|
self._playbook_name = None
|
||||||
self._play_name = None
|
self._play_name = None
|
||||||
|
@ -147,13 +156,14 @@ class CallbackModule(CallbackBase):
|
||||||
play = self._play_name
|
play = self._play_name
|
||||||
name = task.get_name().strip()
|
name = task.get_name().strip()
|
||||||
path = task.get_path()
|
path = task.get_path()
|
||||||
|
action = task.action
|
||||||
|
|
||||||
if not task.no_log:
|
if not task.no_log:
|
||||||
args = ', '.join(('%s=%s' % a for a in task.args.items()))
|
args = ', '.join(('%s=%s' % a for a in task.args.items()))
|
||||||
if args:
|
if args:
|
||||||
name += ' ' + args
|
name += ' ' + args
|
||||||
|
|
||||||
self._task_data[uuid] = TaskData(uuid, name, path, play)
|
self._task_data[uuid] = TaskData(uuid, name, path, play, action)
|
||||||
|
|
||||||
def _finish_task(self, status, result):
|
def _finish_task(self, status, result):
|
||||||
""" record the results of a task for a single host """
|
""" record the results of a task for a single host """
|
||||||
|
@ -236,6 +246,9 @@ class CallbackModule(CallbackBase):
|
||||||
test_cases = []
|
test_cases = []
|
||||||
|
|
||||||
for task_uuid, task_data in self._task_data.items():
|
for task_uuid, task_data in self._task_data.items():
|
||||||
|
if task_data.action == 'setup' and self._include_setup_tasks_in_report == 'false':
|
||||||
|
continue
|
||||||
|
|
||||||
for host_uuid, host_data in task_data.host_data.items():
|
for host_uuid, host_data in task_data.host_data.items():
|
||||||
test_cases.append(self._build_test_case(task_data, host_data))
|
test_cases.append(self._build_test_case(task_data, host_data))
|
||||||
|
|
||||||
|
@ -290,7 +303,7 @@ class TaskData:
|
||||||
Data about an individual task.
|
Data about an individual task.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, uuid, name, path, play):
|
def __init__(self, uuid, name, path, play, action):
|
||||||
self.uuid = uuid
|
self.uuid = uuid
|
||||||
self.name = name
|
self.name = name
|
||||||
self.path = path
|
self.path = path
|
||||||
|
@ -298,6 +311,7 @@ class TaskData:
|
||||||
self.start = None
|
self.start = None
|
||||||
self.host_data = OrderedDict()
|
self.host_data = OrderedDict()
|
||||||
self.start = time.time()
|
self.start = time.time()
|
||||||
|
self.action = action
|
||||||
|
|
||||||
def add_host(self, host):
|
def add_host(self, host):
|
||||||
if host.uuid in self.host_data:
|
if host.uuid in self.host_data:
|
||||||
|
|
Loading…
Reference in a new issue