Group ansible-test integration tests

I am writing netscaler.adc ansible collection. This collection is used to configure NetScaler ADC (Application Delivery Controller).

ADC has different form factors, among others, VPX, CPX
VPX – virtual machine based
CPX – container based

I have written 3 integration tests – nsip, ipset, ntpserver

ntpserver feature is not supported in CPX form factor and hence integration test fails.
My integration test CI is on github-actions.

github-actions creates a ADC CPX container against which integration test will be run.

How to skip few of the integration tests?

One this I have explored is to tag every task in every integration tests suite. This becomes cumbersome.

Do we have a not-allowed-list or something related OR grouping of the modules so that only CPX feature modules can be run?

Sumanth

There are two ways to do this:

  1. Wrap the integration test in a block or conditional include_tasks and first test whether the requirements for that test are present before executing it.
  2. Use CI groups: You can run assing to every integration test in its aliases file an arbitrary group this/is/a/group/name (I think zero slashes is also OK, though all group names I saw had at least one) and pass this/is/a/group/name/ as a target name to ansible-test integration: ansible-test integration this/is/a/group/name/. Then only tests from that group will be run.

See for example community.sops/tests/integration/targets/lookup_sops/aliases at main · ansible-collections/community.sops · GitHub, and see community.sops/.github/workflows/ansible-test.yml at main · ansible-collections/community.sops · GitHub for how this could be used with GHA. (If the groups are mostly identical, you can of course use the CI matrix feature from GHA itself, like here: community.docker/.github/workflows/ansible-test.yml at main · ansible-collections/community.docker · GitHub)

For 1., see community.docker/tests/integration/targets/docker_compose_v2/tasks/main.yml at main · ansible-collections/community.docker · GitHub and community.docker/tests/integration/targets/setup_docker_cli_compose/tasks/main.yml at main · ansible-collections/community.docker · GitHub as an example. You can also use an end_play meta task (ansible.builtin.meta module – Execute Ansible ‘actions’ — Ansible Documentation) if you notice that some requirements are not met.

1 Like

Thank you @felixfontein. You have become my ansible mentor :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.