diff options
| author | Michal Nasiadka <mnasiadka@gmail.com> | 2026-01-08 14:56:36 +0100 |
|---|---|---|
| committer | Michal Nasiadka <mnasiadka@gmail.com> | 2026-01-12 14:30:24 +0000 |
| commit | effd154e04a56203296a46fcce0b1919ddd029fb (patch) | |
| tree | dfd5df998224a5178af2a20b90344bd2fefcd2cb /tests | |
| parent | f699a56a8ac9706c6c33edf00e5056f8ce1dc896 (diff) | |
| download | kolla-ansible-effd154e04a56203296a46fcce0b1919ddd029fb.tar.gz kolla-ansible-effd154e04a56203296a46fcce0b1919ddd029fb.zip | |
kolla_toolbox: Add support for deprecation warnings
ansible-core 2.20 introduced some deprecation warnings
in internal module functions and not all modules have
adapted to new functionality, therefore kolla_toolbox
invocations contain both deprecation warnings (or other
warnings) and JSON blocks.
This patch adds support for separating these and printing
deprecation warnings using warn() function in AnsibleModule
Closes-Bug: #2138234
Change-Id: I2008d9d8c85b2216036f5155e29f7e5db43832f0
Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_kolla_toolbox.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_kolla_toolbox.py b/tests/test_kolla_toolbox.py index 9dca821cc..e170964db 100644 --- a/tests/test_kolla_toolbox.py +++ b/tests/test_kolla_toolbox.py @@ -263,6 +263,53 @@ class TestKollaToolboxMethods(TestKollaToolboxModule): self.assertIn('Ansible JSON output has unexpected format', error.result['msg']) + def test_process_container_output_deprecation(self): + container_output_deprecation = "[DEPRECATION WARNING] Some deprecation" + container_output_json = { + 'custom_stats': {}, + 'global_custom_stats': {}, + 'plays': [ + { + 'tasks': [ + { + 'hosts': { + 'localhost': { + '_ansible_no_log': False, + 'action': 'ping', + 'changed': False, + 'invocation': { + 'module_args': { + 'data': 'pong' + } + }, + 'ping': 'pong' + } + }, + } + ] + } + ], + } + container_encoded_json = json.dumps(container_output_json) + container_output = (str(container_output_deprecation) + + str(container_encoded_json)).encode('utf-8') + + expected_output = { + 'action': 'ping', + 'changed': False, + 'invocation': { + 'module_args': { + 'data': 'pong' + } + }, + 'ping': 'pong' + } + generated_module_output = self.fake_ktbw._process_container_output( + container_output) + + self.assertNotIn('_ansible_no_log', generated_module_output) + self.assertEqual(expected_output, generated_module_output) + def test_process_container_output_success(self): container_output_json = { 'custom_stats': {}, |
