summaryrefslogtreecommitdiff
path: root/test/integration/targets/collections
diff options
context:
space:
mode:
authorSloane Hertel <19572925+s-hertel@users.noreply.github.com>2022-03-15 14:11:12 -0400
committerGitHub <noreply@github.com>2022-03-15 11:11:12 -0700
commit939f8430241a9bafd1fd903ce865b0d422b2218b (patch)
tree1376f4441b7136c41d2ac186291824ef1f4a358c /test/integration/targets/collections
parentca8835c99029e6cbbb64a5510e6b03a943ba1697 (diff)
downloadansible-939f8430241a9bafd1fd903ce865b0d422b2218b.tar.gz
[2.11] Fix collection redirects for filter and test plugins (#77210) (#77228)
* Fix collection redirects for filter and test plugins (#77210) * Fix collection redirects for jinja2 filters/tests * Handle recursive redirects Co-authored-by: Matt Martz <matt@sivel.net> (cherry picked from commit 8063643b4cec51a72377da5f3fa354d3ff9e737a) * The error message is only capitalized on 2.13. Make test more flexible. (cherry picked from commit 734777ef05b8c200f45336a8b9b41f9f9af597c1)
Diffstat (limited to 'test/integration/targets/collections')
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml17
-rwxr-xr-xtest/integration/targets/collections/runme.sh10
-rw-r--r--test/integration/targets/collections/test_collection_meta.yml19
3 files changed, 46 insertions, 0 deletions
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml
index da8e4901ce..2dcf456e17 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testredirect/meta/runtime.yml
@@ -2,3 +2,20 @@ plugin_routing:
modules:
ping:
redirect: testns.testcoll.ping
+ filter:
+ multi_redirect_filter:
+ redirect: testns.testredirect.redirect_filter1
+ deprecation:
+ warning_text: deprecation1
+ redirect_filter1:
+ redirect: redirect_filter2
+ deprecation:
+ warning_text: deprecation2
+ redirect_filter2:
+ redirect: testns.testcoll.testfilter
+ deprecation:
+ warning_text: deprecation3
+ dead_end:
+ redirect: bad_redirect
+ recursive_redirect:
+ redirect: recursive_redirect
diff --git a/test/integration/targets/collections/runme.sh b/test/integration/targets/collections/runme.sh
index 663b3e1cd7..f7f5aba30c 100755
--- a/test/integration/targets/collections/runme.sh
+++ b/test/integration/targets/collections/runme.sh
@@ -69,6 +69,16 @@ else
ansible-playbook -i "${INVENTORY_PATH}" collection_root_user/ansible_collections/testns/testcoll/playbooks/default_collection_playbook.yml "$@"
fi
+# test redirects and warnings for filter redirects
+echo "testing redirect and deprecation display"
+ANSIBLE_DEPRECATION_WARNINGS=yes ansible localhost -m debug -a msg='{{ "data" | testns.testredirect.multi_redirect_filter }}' -vvvvv 2>&1 | tee out.txt
+cat out.txt
+
+test "$(grep out.txt -ce 'deprecation1' -ce 'deprecation2' -ce 'deprecation3')" == 3
+grep out.txt -e 'redirecting (type: filter) testns.testredirect.multi_redirect_filter to testns.testredirect.redirect_filter1'
+grep out.txt -e 'redirecting (type: filter) testns.testredirect.redirect_filter1 to testns.testredirect.redirect_filter2'
+grep out.txt -e 'redirecting (type: filter) testns.testredirect.redirect_filter2 to testns.testcoll.testfilter'
+
echo "--- validating collections support in playbooks/roles"
# run test playbooks
ansible-playbook -i "${INVENTORY_PATH}" -v "${TEST_PLAYBOOK}" "$@"
diff --git a/test/integration/targets/collections/test_collection_meta.yml b/test/integration/targets/collections/test_collection_meta.yml
index 22a00b2197..b682d220c0 100644
--- a/test/integration/targets/collections/test_collection_meta.yml
+++ b/test/integration/targets/collections/test_collection_meta.yml
@@ -21,6 +21,25 @@
# redirect filter
- assert:
that: ('yes' | formerly_core_filter) == True
+ # redirect filter (multiple levels)
+ - assert:
+ that: ('data' | testns.testredirect.multi_redirect_filter) == 'data_via_testfilter_from_userdir'
+ # invalid filter redirect
+ - debug: msg="{{ 'data' | testns.testredirect.dead_end }}"
+ ignore_errors: yes
+ register: redirect_failure
+ - assert:
+ that:
+ - redirect_failure is failed
+ - '"no filter named ''testns.testredirect.dead_end''" in (redirect_failure.msg | lower)'
+ # recursive filter redirect
+ - debug: msg="{{ 'data' | testns.testredirect.recursive_redirect }}"
+ ignore_errors: yes
+ register: redirect_failure
+ - assert:
+ that:
+ - redirect_failure is failed
+ - '"recursive collection redirect found for ''testns.testredirect.recursive_redirect''" in redirect_failure.msg'
# legacy filter should mask redirected
- assert:
that: ('' | formerly_core_masked_filter) == 'hello from overridden formerly_core_masked_filter'