diff --git a/build-requirements.txt b/build-requirements.txt deleted file mode 100644 index b6d2452..0000000 --- a/build-requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -# NOTES(lourot): -# * We don't install charmcraft via pip anymore because it anyway spins up a -# container and scp the system's charmcraft snap inside it. So the charmcraft -# snap is necessary on the system anyway. -# * `tox -e build` successfully validated with charmcraft 1.2.1 - -cffi==1.14.6; python_version < '3.6' # cffi 1.15.0 drops support for py35. diff --git a/osci.yaml b/osci.yaml index d502701..2652544 100644 --- a/osci.yaml +++ b/osci.yaml @@ -15,7 +15,7 @@ needs_charm_build: true charm_build_name: ceph-iscsi build_type: charmcraft - charmcraft_channel: 2.0/stable + charmcraft_channel: 2.2/stable - job: name: ceph-iscsi-focal-quincy parent: func-target diff --git a/test-requirements.txt b/test-requirements.txt index 358e1bc..552381d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,9 +8,6 @@ flake8>=2.2.4,<=2.4.1 stestr>=2.2.0 requests>=2.18.4 psutil -# oslo.i18n dropped py35 support -oslo.i18n<4.0.0 git+https://github.com/openstack-charmers/zaza.git#egg=zaza git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack -pytz # workaround for 14.04 pip/tox pyudev # for ceph-* charm unit tests (not mocked?) diff --git a/tox.ini b/tox.ini index c855061..a7703d6 100644 --- a/tox.ini +++ b/tox.ini @@ -7,44 +7,30 @@ skipsdist = True sitepackages = False # NOTE: Avoid false positives by not skipping missing interpreters. skip_missing_interpreters = False -# NOTES: -# * We avoid the new dependency resolver by pinning pip < 20.3, see -# https://github.com/pypa/pip/issues/9187 -# * Pinning dependencies requires tox >= 3.2.0, see -# https://tox.readthedocs.io/en/latest/config.html#conf-requires -# * It is also necessary to pin virtualenv as a newer virtualenv would still -# lead to fetching the latest pip in the func* tox targets, see -# https://stackoverflow.com/a/38133283 -# * It is necessary to declare setuptools as a dependency otherwise tox will -# fail very early at not being able to load it. The version pinning is in -# line with `pip.sh`. -requires = pip < 20.3 - virtualenv < 20.0 - setuptools < 50.0.0 -# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci -minversion = 3.2.0 [testenv] +# We use tox mainly for virtual environment management for test requirements +# and do not install the charm code as a Python package into that environment. +# Ref: https://tox.wiki/en/latest/config.html#skip_install +skip_install = True setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 CHARM_DIR={envdir} -install_command = - pip install {opts} {packages} commands = stestr run --slowest {posargs} allowlist_externals = git add-to-archive.py bash charmcraft - rename.sh -passenv = HOME TERM CS_* OS_* TEST_* + {toxinidir}/rename.sh +passenv = + HOME + TERM + CS_* + OS_* + TEST_* deps = -r{toxinidir}/test-requirements.txt -[testenv:py35] -basepython = python3.5 -# python3.5 is irrelevant on a focal+ charm. -commands = /bin/true - [testenv:py36] basepython = python3.6 deps = -r{toxinidir}/requirements.txt @@ -70,6 +56,11 @@ basepython = python3.10 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +[testenv:py311] +basepython = python3.11 +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + [testenv:py3] basepython = python3 deps = -r{toxinidir}/requirements.txt @@ -115,7 +106,6 @@ commands = {posargs} [testenv:build] basepython = python3 -deps = -r{toxinidir}/build-requirements.txt commands = charmcraft clean charmcraft -v pack diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index 577ab7e..7c565f5 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -17,3 +17,15 @@ import mock # Mock out secrets to make py35 happy. sys.modules['secrets'] = mock.MagicMock() + +# Patch out lsb_release() and get_platform() as unit tests should be fully +# insulated from the underlying platform. Unit tests assume that the system is +# ubuntu jammy. +mock.patch( + 'charmhelpers.osplatform.get_platform', return_value='ubuntu' +).start() +mock.patch( + 'charmhelpers.core.host.lsb_release', + return_value={ + 'DISTRIB_CODENAME': 'jammy' + }).start()