From 36b666bb8821375307713dc1027fc737e54b298f Mon Sep 17 00:00:00 2001 From: Luciano Lo Giudice Date: Tue, 21 Sep 2021 13:53:10 -0300 Subject: [PATCH] Copy over files from release-tools Instead of doing piecemeal modifications to the old files of this charm, use the readily available files from release-tools. --- .zuul.yaml | 4 + copyright | 25 +++-- metadata.yaml | 1 - pip.sh | 18 ++++ requirements.txt | 23 ++++- src/metadata.yaml | 2 + src/test-requirements.txt | 8 +- src/tests/bundles/focal-ussuri.yaml | 1 + src/tests/bundles/focal-victoria.yaml | 1 + src/tests/bundles/groovy-victoria.yaml | 1 + src/tests/bundles/hirsute-wallaby.yaml | 1 + src/tox.ini | 34 ++++++- test-requirements.txt | 56 +++++++++-- tox.ini | 132 ++++++++++++------------- 14 files changed, 209 insertions(+), 98 deletions(-) create mode 100644 .zuul.yaml delete mode 120000 metadata.yaml create mode 100755 pip.sh diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..fd20909 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,4 @@ +- project: + templates: + - openstack-python3-charm-jobs + - openstack-cover-jobs diff --git a/copyright b/copyright index 15a7cc3..fe11c30 100644 --- a/copyright +++ b/copyright @@ -2,16 +2,15 @@ Format: http://dep.debian.net/deps/dep5/ Files: * Copyright: Copyright 2021, Canonical Ltd., All Rights Reserved. -License: GPL-3 - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - . - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - You should have received a copy of the GNU General Public License - along with this program. If not, see . +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); you may + not use this file except in compliance with the License. You may obtain + a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. diff --git a/metadata.yaml b/metadata.yaml deleted file mode 120000 index 0768683..0000000 --- a/metadata.yaml +++ /dev/null @@ -1 +0,0 @@ -src/metadata.yaml \ No newline at end of file diff --git a/pip.sh b/pip.sh new file mode 100755 index 0000000..9a7e6b0 --- /dev/null +++ b/pip.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# This file is managed centrally by release-tools and should not be modified +# within individual charm repos. See the 'global' dir contents for available +# choices of tox.ini for OpenStack Charms: +# https://github.com/openstack-charmers/release-tools +# +# setuptools 58.0 dropped the support for use_2to3=true which is needed to +# install blessings (an indirect dependency of charm-tools). +# +# More details on the beahvior of tox and virtualenv creation can be found at +# https://github.com/tox-dev/tox/issues/448 +# +# This script is wrapper to force the use of the pinned versions early in the +# process when the virtualenv was created and upgraded before installing the +# depedencies declared in the target. +pip install 'pip<20.3' 'setuptools<50.0.0' +pip "$@" diff --git a/requirements.txt b/requirements.txt index d5d4a8d..b786b42 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,22 @@ -simplejson -charm-tools>=2.4.4 +# This file is managed centrally by release-tools and should not be modified +# within individual charm repos. See the 'global' dir contents for available +# choices of *requirements.txt files for OpenStack Charms: +# https://github.com/openstack-charmers/release-tools +# +# NOTE(lourot): This might look like a duplication of test-requirements.txt but +# some tox targets use only test-requirements.txt whereas charm-build uses only +# requirements.txt +setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85 +# Build requirements +charm-tools==2.8.3 + +simplejson + +# Newer versions use keywords that didn't exist in python 3.5 yet (e.g. +# "ModuleNotFoundError") +# NOTE(lourot): This might look like a duplication of test-requirements.txt but +# some tox targets use only test-requirements.txt whereas charm-build uses only +# requirements.txt +importlib-metadata<3.0.0; python_version < '3.6' +importlib-resources<3.0.0; python_version < '3.6' diff --git a/src/metadata.yaml b/src/metadata.yaml index de2907b..83df54e 100644 --- a/src/metadata.yaml +++ b/src/metadata.yaml @@ -13,6 +13,8 @@ tags: series: - bionic - focal + - groovy + - hirsute subordinate: true provides: storage-backend: diff --git a/src/test-requirements.txt b/src/test-requirements.txt index f2912ba..e771023 100644 --- a/src/test-requirements.txt +++ b/src/test-requirements.txt @@ -1,3 +1,9 @@ -# zaza +# This file is managed centrally by release-tools and should not be modified +# within individual charm repos. See the 'global' dir contents for available +# choices of *requirements.txt files for OpenStack Charms: +# https://github.com/openstack-charmers/release-tools +# + +# Functional Test Requirements (let Zaza's dependencies solve all dependencies here!) git+https://github.com/openstack-charmers/zaza.git#egg=zaza git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack diff --git a/src/tests/bundles/focal-ussuri.yaml b/src/tests/bundles/focal-ussuri.yaml index 49ae182..8cc6649 100644 --- a/src/tests/bundles/focal-ussuri.yaml +++ b/src/tests/bundles/focal-ussuri.yaml @@ -55,6 +55,7 @@ applications: keystone-mysql-router: charm: cs:~openstack-charmers/mysql-router cinder: + charm: cs:~openstack-charmers/cinder num_units: 1 storage: block-devices: '40G' diff --git a/src/tests/bundles/focal-victoria.yaml b/src/tests/bundles/focal-victoria.yaml index 7efdb70..cf64baa 100644 --- a/src/tests/bundles/focal-victoria.yaml +++ b/src/tests/bundles/focal-victoria.yaml @@ -55,6 +55,7 @@ applications: keystone-mysql-router: charm: cs:~openstack-charmers/mysql-router cinder: + charm: cs:~openstack-charmers/cinder storage: block-devices: '40G' num_units: 1 diff --git a/src/tests/bundles/groovy-victoria.yaml b/src/tests/bundles/groovy-victoria.yaml index 2f2a893..53a2be6 100644 --- a/src/tests/bundles/groovy-victoria.yaml +++ b/src/tests/bundles/groovy-victoria.yaml @@ -55,6 +55,7 @@ applications: keystone-mysql-router: charm: cs:~openstack-charmers/mysql-router cinder: + charm: cs:~openstack-charmers/cinder storage: block-devices: '40G' num_units: 1 diff --git a/src/tests/bundles/hirsute-wallaby.yaml b/src/tests/bundles/hirsute-wallaby.yaml index 4de4f4b..b9bbe72 100644 --- a/src/tests/bundles/hirsute-wallaby.yaml +++ b/src/tests/bundles/hirsute-wallaby.yaml @@ -55,6 +55,7 @@ applications: keystone-mysql-router: charm: cs:~openstack-charmers/mysql-router cinder: + charm: cs:~openstack-charmers/cinder storage: block-devices: '40G' num_units: 1 diff --git a/src/tox.ini b/src/tox.ini index ce45106..b40d295 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -1,25 +1,46 @@ +# Source charm (with zaza): ./src/tox.ini +# This file is managed centrally by release-tools and should not be modified +# within individual charm repos. See the 'global' dir contents for available +# choices of tox.ini for OpenStack Charms: +# https://github.com/openstack-charmers/release-tools + [tox] envlist = pep8 skipsdist = True +# NOTE: Avoid build/test env pollution by not enabling sitepackages. +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 +requires = pip < 20.3 + virtualenv < 20.0 +# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci +minversion = 3.18.0 [testenv] setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 -whitelist_externals = juju -passenv = HOME TERM CS_API_* OS_* AMULET_* +allowlist_externals = juju +passenv = HOME TERM CS_* OS_* TEST_* deps = -r{toxinidir}/test-requirements.txt install_command = pip install {opts} {packages} [testenv:pep8] basepython = python3 -deps=charm-tools commands = charm-proof [testenv:func-noop] basepython = python3 commands = - true + functest-run-suite --help [testenv:func] basepython = python3 @@ -31,5 +52,10 @@ basepython = python3 commands = functest-run-suite --keep-model --smoke +[testenv:func-target] +basepython = python3 +commands = + functest-run-suite --keep-model --bundle {posargs} + [testenv:venv] commands = {posargs} diff --git a/test-requirements.txt b/test-requirements.txt index f5cb22b..af069e1 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,51 @@ -mock>=1.2 -flake8 -coverage>=4.5.2 -os-testr>=0.4.1 +# This file is managed centrally by release-tools and should not be modified +# within individual charm repos. See the 'global' dir contents for available +# choices of *requirements.txt files for OpenStack Charms: +# https://github.com/openstack-charmers/release-tools +# +setuptools<50.0.0 # https://github.com/pypa/setuptools/commit/04e3df22df840c6bb244e9b27bc56750c44b7c85 + +stestr>=2.2.0 + +# Dependency of stestr. Workaround for +# https://github.com/mtreinish/stestr/issues/145 +cliff<3.0.0 + +# Dependencies of stestr. Newer versions use keywords that didn't exist in +# python 3.5 yet (e.g. "ModuleNotFoundError") +importlib-metadata<3.0.0; python_version < '3.6' +importlib-resources<3.0.0; python_version < '3.6' + +# Some Zuul nodes sometimes pull newer versions of these dependencies which +# dropped support for python 3.5: +osprofiler<2.7.0;python_version<'3.6' +stevedore<1.31.0;python_version<'3.6' +debtcollector<1.22.0;python_version<'3.6' +oslo.utils<=3.41.0;python_version<'3.6' + +requests>=2.18.4 charms.reactive -git+https://github.com/openstack/charms.openstack.git#egg=charms-openstack -git+https://github.com/juju/charm-helpers.git#egg=charmhelpers + +# Newer mock seems to have some syntax which is newer than python3.5 (e.g. +# f'{something}' +mock>=1.2,<4.0.0; python_version < '3.6' +mock>=1.2; python_version >= '3.6' + +nose>=1.3.7 +coverage>=3.6 +git+https://github.com/openstack/charms.openstack.git#egg=charms.openstack +# +# Revisit for removal / mock improvement: +# +# NOTE(lourot): newer versions of cryptography require a Rust compiler to build, +# see +# * https://github.com/openstack-charmers/zaza/issues/421 +# * https://mail.python.org/pipermail/cryptography-dev/2021-January/001003.html +# +netifaces # vault +psycopg2-binary # vault +tenacity # vault +pbr==5.6.0 # vault +cryptography<3.4 # vault, keystone-saml-mellon +lxml # keystone-saml-mellon +hvac # vault, barbican-vault diff --git a/tox.ini b/tox.ini index 5ee0451..22159df 100644 --- a/tox.ini +++ b/tox.ini @@ -1,65 +1,85 @@ -# Classic charm (with zaza): ./tox.ini +# Source charm: ./tox.ini # This file is managed centrally by release-tools and should not be modified # within individual charm repos. See the 'global' dir contents for available # choices of tox.ini for OpenStack Charms: # https://github.com/openstack-charmers/release-tools -# -# TODO: Distill the func test requirements from the lint/unit test -# requirements. They are intertwined. Also, Zaza itself should specify -# all of its own requirements and if it doesn't, fix it there. + [tox] -envlist = pep8,py3 skipsdist = True +envlist = pep8,py3 # NOTE: Avoid build/test env pollution by not enabling sitepackages. sitepackages = False # NOTE: Avoid false positives by not skipping missing interpreters. skip_missing_interpreters = False -requires = pip < 20.3 - virtualenv < 20.0 +# 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 +requires = + pip < 20.3 + virtualenv < 20.0 + setuptools<50.0.0 + +# NOTE: https://wiki.canonical.com/engineering/OpenStack/InstallLatestToxOnOsci +minversion = 3.18.0 [testenv] setenv = VIRTUAL_ENV={envdir} PYTHONHASHSEED=0 - CHARM_DIR={envdir} + TERM=linux + LAYER_PATH={toxinidir}/layers + INTERFACE_PATH={toxinidir}/interfaces + JUJU_REPOSITORY={toxinidir}/build +passenv = http_proxy https_proxy INTERFACE_PATH LAYER_PATH JUJU_REPOSITORY install_command = - pip install {opts} {packages} -commands = stestr run --slowest {posargs} -whitelist_externals = juju -passenv = HOME TERM CS_* OS_* TEST_* -deps = -r{toxinidir}/test-requirements.txt - -r{toxinidir}/requirements.txt + {toxinidir}/pip.sh install {opts} {packages} +deps = + -r{toxinidir}/requirements.txt -[testenv:py35] -basepython = python3.5 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +[testenv:build] +basepython = python3 +commands = + charm-build --log-level DEBUG --use-lock-file-branches -o {toxinidir}/build/builds src {posargs} -[testenv:py36] -basepython = python3.6 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -[testenv:py37] -basepython = python3.7 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -[testenv:py38] -basepython = python3.8 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +[testenv:add-build-lock-file] +basepython = python3 +commands = + charm-build --log-level DEBUG --write-lock-file -o {toxinidir}/build/builds src {posargs} [testenv:py3] basepython = python3 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} + +[testenv:py35] +basepython = python3.5 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} + +[testenv:py36] +basepython = python3.6 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} + +[testenv:py37] +basepython = python3.7 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} + +[testenv:py38] +basepython = python3.8 +deps = -r{toxinidir}/test-requirements.txt +commands = stestr run --slowest {posargs} [testenv:pep8] basepython = python3 -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt -commands = flake8 {posargs} unit_tests src - charm-proof +deps = flake8==3.9.2 + charm-tools==2.8.3 +commands = flake8 {posargs} src unit_tests [testenv:cover] # Technique based heavily upon @@ -93,36 +113,6 @@ omit = basepython = python3 commands = {posargs} -[testenv:func-noop] -basepython = python3 -commands = - functest-run-suite --help - -[testenv:func] -basepython = python3 -commands = - functest-run-suite --keep-model - -[testenv:func-smoke] -basepython = python3 -commands = - functest-run-suite --keep-model --smoke - -[testenv:func-dev] -basepython = python3 -commands = - functest-run-suite --keep-model --dev - -[testenv:func-target] -basepython = python3 -commands = - functest-run-suite --keep-model --bundle {posargs} - [flake8] -ignore = E402,E226 -exclude = */charmhelpers - -[testenv:build] -basepython = python3 -commands = - charm-build --log-level DEBUG -o {toxinidir}/build src {posargs} +# E402 ignore necessary for path append before sys module import in actions +ignore = E402,W503,W504