ansible.utils
ansible.utils copied to clipboard
replace_keys: Add complex integration tests.
SUMMARY
Add integration tests.
ISSUE TYPE
- Feature Pull Request
COMPONENT NAME
ansible.utils.replace_keys
ADDITIONAL INFORMATION
No additional info atm.
I've successfully tested the code locally before submitting.
- Ansible 2.12
- Python 3.8.5
The playbook
shell> cat pb-replace_keys.yml
---
- name: Integration targets replace keys
hosts: localhost
gather_facts: false
# Test integration
# shell: ANSIBLE_ROLES_PATH=/scratch/vbotka.ansible.utils/tests/integration/targets
roles:
- utils_replace_keys
completed all tasks and skipped the debug tasks as expected
localhost: ok=15 changed=0 unreachable=0 failed=0 skipped=9 rescued=0 ignored=0
I downloaded the log. The first test failed
2022-09-01T12:19:07.8153682Z TASK [utils_replace_keys : 1.replace_keys debug] *******************************
2022-09-01T12:19:07.8154278Z task path: /home/runner/collections/ansible_collections/ansible/utils/tests/integration/targets/utils_replace_keys/tasks/complex1.yaml:4
2022-09-01T12:19:07.8154731Z skipping: [localhost] => {}
2022-09-01T12:19:07.8154874Z
2022-09-01T12:19:07.8155032Z TASK [utils_replace_keys : 1.replace_keys assert] ******************************
2022-09-01T12:19:07.8155625Z task path: /home/runner/collections/ansible_collections/ansible/utils/tests/integration/targets/utils_replace_keys/tasks/complex1.yaml:8
2022-09-01T12:19:07.8156254Z fatal: [localhost]: FAILED! => {
2022-09-01T12:19:07.8156569Z "assertion": "result == target",
2022-09-01T12:19:07.8156873Z "changed": false,
2022-09-01T12:19:07.8157166Z "evaluated_to": false,
2022-09-01T12:19:07.8157472Z "msg": "Assertion failed"
2022-09-01T12:19:07.8157707Z }
I added fail_msg to first test to see what's going on. Waiting for an approval to see it ...
I don't understand the error (Test collection / integration / py3.9 / stable-2.12 (pull_request)). See the value of result in the error message below "[ERR] Assertion failed\nresult: ..."
This is the task:
- name: 1.replace_keys
block:
- name: 1.replace_keys debug
debug:
var: result|to_yaml
when: debug_test|d(false)|bool
- name: 1.replace_keys assert
assert:
that: result == target
fail_msg: |-
[ERR] Assertion failed
result:
{{ result|to_yaml|indent(2) }}
target:
{{ target|to_yaml|indent(2) }}
vars:
result: "{{ l1|ansible.utils.replace_keys(target=_target) }}"
_target:
- { before: p1, after: x1 }
- { before: p2, after: x2 }
target:
- { p3: a, x1: a, x2: a }
- { p3: b, x1: b, x2: b }
- { p3: c, x1: c, x2: c }
tags: replace_keys
and this is the error (logs_271/integration\ \ py3.9\ \ stable-2.12/10_Run\ integration\ tests.txt):
2022-10-14T16:09:53.7077994Z TASK [utils_replace_keys : 1.replace_keys assert] ******************************
2022-10-14T16:09:53.7078691Z ^[[1;30mtask path: /home/runner/collections/ansible_collections/ansible/utils/tests/integration/targets/utils_replace_keys/tasks/complex1.yaml:8^[[0m
2022-10-14T16:09:53.7079393Z ^[[0;31mfatal: [localhost]: FAILED! => {^[[0m
2022-10-14T16:09:53.7079928Z ^[[0;31m "assertion": "result == target",^[[0m
2022-10-14T16:09:53.7080289Z ^[[0;31m "changed": false,^[[0m
2022-10-14T16:09:53.7080641Z ^[[0;31m "evaluated_to": false,^[[0m
2022-10-14T16:09:53.7082884Z ^[[0;31m "msg": "[ERR] Assertion failed\nresult:\n changed: false\n failed: false\n msg:\n - {duplex: auto, enabled: true, name: eth0, speed: auto}\n - d\
escription: Configured by Ansible - Interface 1\n duplex: auto\n enabled: true\n mtu: 1500\n name: eth1\n speed: auto\n vifs:\n - {description: Eth1 - VIF 100, enabled: \
true, mtu: 400, vlan_id: 100}\n - {description: Eth1 - VIF 101, enabled: true, vlan_id: 101}\n - {description: Configured by Ansible - Interface 2 (ADMIN DOWN), enabled: false,\n mtu:\
600, name: eth2}\n\ntarget:\n - {p3: a, x1: a, x2: a}\n - {p3: b, x1: b, x2: b}\n - {p3: c, x1: c, x2: c}\n"^[[0m
2022-10-14T16:09:53.7083952Z ^[[0;31m}^[[0m
There is no problem with Python 3.8 (logs_271/integration\ \ py3.8\ \ stable-2.12/10_Run\ integration\ tests.txt)
Any idea?
Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/99f29c3677b648b5955dcb1b1aa0c6aa
:heavy_check_mark: ansible-galaxy-importer SUCCESS in 2m 55s :heavy_check_mark: build-ansible-collection SUCCESS in 7m 03s
Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/702e61fe50f04915b75970f7727b57eb
:heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 17s :heavy_check_mark: build-ansible-collection SUCCESS in 6m 59s
Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/350e07d51a45445ca34d99f2febcdc55
:heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 16s :heavy_check_mark: build-ansible-collection SUCCESS in 6m 34s
Build succeeded. https://ansible.softwarefactory-project.io/zuul/buildset/01f0412eb4a849688a70b854cc844d95
:heavy_check_mark: ansible-galaxy-importer SUCCESS in 4m 07s :heavy_check_mark: build-ansible-collection SUCCESS in 6m 40s
thank you for your contribution @vbotka :)