Skip to content

Commit 79b4c0f

Browse files
committed
tests: Fix AttributeError in callback plugins used by test suite
CALLBACK_VERSION et al are documented as required in https://docs.ansible.com/ansible/2.10/dev_guide/developing_plugins.html#callback-plugins. The need for document_fragment is noted in https://github.com/ansible/ansible/blob/cfa8075537f5fa83ca5bfe3170373aaef9ce932f/lib/ansible/plugins/callback/default.py#L28-L32 Fixes #758 This addresses the following error, seen while running `ansible_tests.py`. ``` TASK [Gathering Facts gather_timeout=10, gather_subset=['all']] **************** task path: /home/alex/src/mitogen/tests/ansible/regression/issue_109__target_has_old_ansible_installed.yml:4 [WARNING]: Failure using method (v2_runner_on_start) in callback plugin (<ansible.plugins.callback.nice_stdout.CallbackModule object at 0x7f76b3dad090>): 'show_per_host_start' Callback Exception: File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 372, in send_callback method(*new_args, **kwargs) File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/default.py", line 240, in v2_runner_on_start if self.get_option('show_per_host_start'): File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option return self._plugin_options[k] Callback Exception: File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 372, in send_callback method(*new_args, **kwargs) File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/default.py", line 240, in v2_runner_on_start if self.get_option('show_per_host_start'): File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option return self._plugin_options[k] [task 339882] 00:00:08.172036 D ansible_mitogen.affinity: CPU mask for WorkerProcess: 0x000004 Callback Exception: File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 372, in send_callback method(*new_args, **kwargs) File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/default.py", line 240, in v2_runner_on_start if self.get_option('show_per_host_start'): File "/home/alex/src/mitogen/.tox/py27-ansible2.10/lib/python2.7/site-packages/ansible/plugins/callback/__init__.py", line 91, in get_option return self._plugin_options[k] ```
1 parent 5942bfb commit 79b4c0f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ To avail of fixes in an unreleased version, please download a ZIP file
2323

2424
* :gh:issue:`756` ssh connections with `check_host_keys='accept'` would
2525
timeout, when using recent OpenSSH client versions.
26+
* :gh:issue:`758` fix initilialisation of callback plugins in test suite, to
27+
to address a `KeyError` in
28+
:method:`ansible.plugins.callback.CallbackBase.v2_runner_on_start`
2629

2730

2831
v0.2.9 (2019-11-02)

tests/ansible/lib/callback/nice_stdout.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
DOCUMENTATION = '''
2121
callback: nice_stdout
2222
type: stdout
23+
extends_documentation_fragment:
24+
- default_callback
2325
options:
2426
check_mode_markers:
2527
name: Show markers when running in check mode
@@ -74,6 +76,10 @@ def write(s, *args):
7476

7577

7678
class CallbackModule(DefaultModule):
79+
CALLBACK_VERSION = 2.0
80+
CALLBACK_TYPE = 'stdout'
81+
CALLBACK_NAME = 'nice_stdout'
82+
7783
def _dump_results(self, result, *args, **kwargs):
7884
try:
7985
tio = io.StringIO()

tests/ansible/lib/callback/profile_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class CallbackModule(CallbackBase):
3737
A plugin for timing tasks
3838
"""
3939
def __init__(self):
40+
super(CallbackModule, self).__init__()
4041
self.stats = {}
4142
self.current = None
4243

0 commit comments

Comments
 (0)