summaryrefslogtreecommitdiff
path: root/tests/unit/test_streaming.py
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2022-07-06 11:47:32 -0700
committerClark Boylan <clark.boylan@gmail.com>2022-07-06 15:59:17 -0700
commit1cdf491a2e2536f1643cb7d36fa49148611e2f66 (patch)
treef5e89fb85ca25585e2ac6caabe1caaa457c9fdc2 /tests/unit/test_streaming.py
parent35bee00c8e83f554d8a57dbfe476f43e3c7e7e6d (diff)
downloadzuul-1cdf491a2e2536f1643cb7d36fa49148611e2f66.tar.gz
Handle non default loopvars in Ansible callback stream plugin
The Zuul Ansible callback stream plugin assumed that the ansible loop var was always called 'item' in the result_dict. You can override this value (and it is often necessary to do so to avoid collisions) to something less generic. In those cases we would get errors like: b'[WARNING]: Failure using method (v2_runner_item_on_ok) in callback plugin' b'(<ansible.plugins.callback.zuul_stream.CallbackModule object at' b"0x7fbecc97c910>): 'item'" And stream output would not include the info typically logged. Address this by checking if ansible_loop_var is in the results_dict and using that value for the loop var name instead. We still fall back to 'item' as I'm not sure that ansible_loop_var is always present. Change-Id: I408e6d4af632f8097d63c04cbcb611d843086f6c
Diffstat (limited to 'tests/unit/test_streaming.py')
-rw-r--r--tests/unit/test_streaming.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/unit/test_streaming.py b/tests/unit/test_streaming.py
index f323cd82a..ba3117f59 100644
--- a/tests/unit/test_streaming.py
+++ b/tests/unit/test_streaming.py
@@ -295,6 +295,11 @@ class TestStreaming(TestStreamingBase):
match = r.search(self.streaming_data[None])
self.assertNotEqual(match, None)
+ # Check that we logged loop_var contents properly
+ pattern = r'ok: "(one|two|three)"'
+ m = re.search(pattern, self.streaming_data[None])
+ self.assertNotEqual(m, None)
+
def runWSClient(self, port, build_uuid):
client = WSClient(port, build_uuid)
client.event.wait()