This is urgent due to ansible-core dropping support for python 2.7. This causes our tox -e py27 unit test to fail:
ERROR: Could not find a version that satisfies the requirement ansible-core==2.12.* (from versions: 0.0.1a1, 2.11.0b1, 2.11.0b2, 2.11.0b3, 2.11.0b4, 2.11.0rc1, 2.11.0rc2, 2.11.0, 2.11.1rc1, 2.11.1, 2.11.2rc1, 2.11.2, 2.11.3rc1, 2.11.3, 2.11.4rc1, 2.11.4, 2.11.5rc1, 2.11.5, 2.11.6rc1, 2.11.6, 2.11.7rc1)
It isn't clear from the error, but because ansible-core requires python >= 3.8, we get this error.
Instead, we should use ansible-test units which is designed for this purpose. And - it covers python 2.6 and 2.7, as well as all supported python 3.x versions (when using --docker - note that if you dnf install podman-docker you can use podman instead of the "real" docker)
However, it will take a good bit of effort to make our unit testing work with ansible-test.
get rid of py26 and py27 from all .github/workflows/tox.yml
These do not work and cause unnecessary test failures
support for --docker is more important than without
That is - tests must work with ansible-test units --docker and ansible-test sanity --docker. If they don't work without --docker, that is ok, at least for now.
change lsrrole2collection.py
This must convert the unit tests into the format expected by ansible-test units and ansible-test sanity.
The tests must be in `$namespace/$name/tests/unit/plugins/modules/$rolename/test*.py`
The tests must use the FQCN to load the python code from the module and module_utils. This will be quite problematic for the network role especially.
Must convert test requirements into tests/unit/requirements.txt - See https://github.com/ansible-collections/ansible.posix/blob/main/tests/unit/requirements.txt for example. We can probably use pytest_extra_requirements.txt. I think kernel_settings will be quite problematic as it uses tuned as a requirement, which also has system requirements (bindep.txt?)
We may have to change the individual tests/unit/*.py files in each role in order to support this, or to make it easier to convert.
fix ansible-test sanity to make import and compile tests work
If we convert roles to collections correctly, and get the requirements.txt correct, this may make the sanity import and compile tests work, so we don't have to ignore them
should still be able to use tox -e py38 or even pytest directly
For role developers who just want to run tests directly on their local git clone without converting to collection format.
add an ansible-test-units test to tox-lsr
So that developers can easily run this
in github CI - get rid of pyxx tests - add an ansible-test-units test
add a github CI test which uses tox-lsr ansible-test-units
This is urgent due to ansible-core dropping support for python 2.7. This causes our
tox -e py27
unit test to fail:It isn't clear from the error, but because ansible-core requires python >= 3.8, we get this error.
Instead, we should use
ansible-test units
which is designed for this purpose. And - it covers python 2.6 and 2.7, as well as all supported python 3.x versions (when using--docker
- note that if youdnf install podman-docker
you can usepodman
instead of the "real"docker
)We already have support for ansible-test in tox-lsr: https://github.com/linux-system-roles/tox-lsr/blob/main/src/tox_lsr/config_files/tox-default.ini#L244 and https://github.com/linux-system-roles/tox-lsr/blob/main/src/tox_lsr/test_scripts/runansible-test.sh
However, it will take a good bit of effort to make our unit testing work with ansible-test.
get rid of py26 and py27 from all .github/workflows/tox.yml These do not work and cause unnecessary test failures
support for
--docker
is more important than without That is - tests must work withansible-test units --docker
andansible-test sanity --docker
. If they don't work without--docker
, that is ok, at least for now.change lsrrole2collection.py This must convert the unit tests into the format expected by
ansible-test units
andansible-test sanity
. The tests must be in `$namespace/$name/tests/unit/plugins/modules/$rolename/test*.py` The tests must use the FQCN to load the python code from the module and module_utils. This will be quite problematic for the network role especially. Must convert test requirements into tests/unit/requirements.txt - See https://github.com/ansible-collections/ansible.posix/blob/main/tests/unit/requirements.txt for example. We can probably use pytest_extra_requirements.txt. I think kernel_settings will be quite problematic as it uses tuned as a requirement, which also has system requirements (bindep.txt?)We may have to change the individual tests/unit/*.py files in each role in order to support this, or to make it easier to convert.
fix
ansible-test sanity
to make import and compile tests work If we convert roles to collections correctly, and get the requirements.txt correct, this may make the sanity import and compile tests work, so we don't have to ignore themshould still be able to use
tox -e py38
or evenpytest
directly For role developers who just want to run tests directly on their local git clone without converting to collection format.add an
ansible-test-units
test to tox-lsr So that developers can easily run thisin github CI - get rid of
pyxx
tests - add anansible-test-units
test add a github CI test which uses tox-lsransible-test-units