chore: Update testing instructions

Update the testing instructions and file exclusions in galaxy.yml, so
they still make sense in a released version of this collection.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This commit is contained in:
Felix Matouschek
2024-04-17 11:17:43 +02:00
parent 88189f432b
commit 161b219e3e
4 changed files with 104 additions and 3 deletions

View File

@@ -1,9 +1,88 @@
# Testing
## Continuous integration
## Sanity and unit tests
The `hack/e2e-setup.sh` script contains the steps necessary to reproduce the CI test environment, which relies on `kubectl` and `kind`.
Sanity and unit tests can be run in two ways:
- with `tox` and the `tox-ansible` plugin (both need to be installed on the dev machine)
- with `ansible-test`
For development purposes `tox` and `tox-ansible` are better suited, as they allow
debugging of issues in the collection on the developer's machine.
For verification purposes of the collection the compatibility with `ansible-test`
is ensured.
### Running tests with tox-ansible
Run sanity tests with `tox-ansible` like so:
```
make test-sanity
```
Run unit tests with `tox-ansible` like so:
```
make test-unit
```
### Running tests with ansible-test
In order to test changes with `ansible-test`, it is recommended to bind mount
the repository to `~/.ansible/collections/ansible_collections/kubevirt/core`
if you did not check it out into this location.
This can be done with:
```
mkdir -p ~/.ansible/collections/ansible_collections/kubevirt/core
sudo mount --bind <project_dir>/kubevirt.core ~/.ansible/collections/ansible_collections/kubevirt/core
cd ~/.ansible/collections/ansible_collections/kubevirt/core
```
Run sanity tests with `ansible-test` like so:
```
ANSIBLE_TEST_PREFER_PODMAN=1 ansible-test sanity --docker
```
Run unit tests with `ansible-test` like so:
```
ANSIBLE_TEST_PREFER_PODMAN=1 ansible-test units --docker
```
## Integration tests
Integration tests require a working cluster and can be run with
`ansible-test`.
### Continuous integration
The `hack/e2e-setup.sh` script contains the steps necessary to reproduce the
CI integration test environment, which relies on `docker` or `podman`,
`kubectl` and `kind`.
To create the CI integration test environment on your machine run:
```
make cluster-up
```
To remove the test CI integration test environment run:
```
make cluster-down
```
### Running integration tests with ansible test
Run integration tests with ansible-test like so:
```
ansible-test integration
```
## Example config and playbooks