1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #8718/b16263eb backport][stable-8] Clarify contribution guide on integration tests (#8733)

Clarify contribution guide on integration tests (#8718)

* Clarify contribution guide on integration tests

* Improve test guide in CONTRIBUTING.md

* Uppercase Docker

Co-authored-by: Felix Fontein <felix@fontein.de>

* Improve test_name documentation

* Use working example in ansible-test integration docs

Co-authored-by: Felix Fontein <felix@fontein.de>

* Fix test_name in ansible-test integration being documented as required

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b16263ebd7)

Co-authored-by: Matthias Kunnen <matthias.kunnen@gmail.com>
This commit is contained in:
patchback[bot] 2024-08-08 11:32:45 +02:00 committed by GitHub
parent c4b3c94092
commit 55f8456229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -56,6 +56,8 @@ cd ~/dev/ansible_collections/community/general
Then you can run `ansible-test` (which is a part of [ansible-core](https://pypi.org/project/ansible-core/)) inside the checkout. The following example commands expect that you have installed Docker or Podman. Note that Podman has only been supported by more recent ansible-core releases. If you are using Docker, the following will work with Ansible 2.9+. Then you can run `ansible-test` (which is a part of [ansible-core](https://pypi.org/project/ansible-core/)) inside the checkout. The following example commands expect that you have installed Docker or Podman. Note that Podman has only been supported by more recent ansible-core releases. If you are using Docker, the following will work with Ansible 2.9+.
### Sanity tests
The following commands show how to run sanity tests: The following commands show how to run sanity tests:
```.bash ```.bash
@ -66,6 +68,8 @@ ansible-test sanity --docker -v
ansible-test sanity --docker -v plugins/modules/system/pids.py tests/integration/targets/pids/ ansible-test sanity --docker -v plugins/modules/system/pids.py tests/integration/targets/pids/
``` ```
### Unit tests
The following commands show how to run unit tests: The following commands show how to run unit tests:
```.bash ```.bash
@ -79,13 +83,32 @@ ansible-test units --docker -v --python 3.8
ansible-test units --docker -v --python 3.8 tests/unit/plugins/modules/net_tools/test_nmcli.py ansible-test units --docker -v --python 3.8 tests/unit/plugins/modules/net_tools/test_nmcli.py
``` ```
### Integration tests
The following commands show how to run integration tests: The following commands show how to run integration tests:
```.bash #### In Docker
# Run integration tests for the interfaces_files module in a Docker container using the
# fedora35 operating system image (the supported images depend on your ansible-core version):
ansible-test integration --docker fedora35 -v interfaces_file
Integration tests on Docker have the following parameters:
- `image_name` (required): The name of the Docker image. To get the list of supported Docker images, run
`ansible-test integration --help` and look for _target docker images_.
- `test_name` (optional): The name of the integration test.
For modules, this equals the short name of the module; for example, `pacman` in case of `community.general.pacman`.
For plugins, the plugin type is added before the plugin's short name, for example `callback_yaml` for the `community.general.yaml` callback.
```.bash
# Test all plugins/modules on fedora40
ansible-test integration -v --docker fedora40
# Template
ansible-test integration -v --docker image_name test_name
# Example community.general.ini_file module on fedora40 Docker image:
ansible-test integration -v --docker fedora40 ini_file
```
#### Without isolation
```.bash
# Run integration tests for the flattened lookup **without any isolation**: # Run integration tests for the flattened lookup **without any isolation**:
ansible-test integration -v lookup_flattened ansible-test integration -v lookup_flattened
``` ```