From e8c1a3da8d98f09a1b455d6eebe17c1345e7bfbc Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=A9dric=20Ollivier?= Date: Fri, 6 Sep 2024 10:58:24 +0200 Subject: [PATCH] Update to Alpine 3.20 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Please note that it also updates python to 3.12. Change-Id: I715194304b37b9cd52affa998a94ba5ec52e7732 Signed-off-by: Cédric Ollivier --- api/conf.py | 6 +++--- docker/core/Dockerfile | 8 ++++---- docker/core/testcases.yaml | 8 ++++---- elements/xtesting/install.d/16-xtesting | 0 tox.ini | 34 ++++++++++++++------------------ upper-constraints.txt | 17 ++++++++-------- xtesting/ci/run_tests.py | 2 +- xtesting/ci/testcases.yaml | 8 ++++---- xtesting/core/testcase.py | 4 ++-- xtesting/tests/unit/ci/test_run_tests.py | 2 +- xtesting/tests/unit/core/test_vnf.py | 12 +++++------ 11 files changed, 49 insertions(+), 52 deletions(-) mode change 100755 => 100644 elements/xtesting/install.d/16-xtesting diff --git a/api/conf.py b/api/conf.py index 1f6645fd..f3c5c796 100644 --- a/api/conf.py +++ b/api/conf.py @@ -16,9 +16,9 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) +import os +import sys +sys.path.insert(0, os.path.abspath('..')) # -- General configuration ------------------------------------------------ diff --git a/docker/core/Dockerfile b/docker/core/Dockerfile index a21eef1a..409cd2d8 100644 --- a/docker/core/Dockerfile +++ b/docker/core/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.17 +FROM alpine:3.20 ARG BRANCH=master ARG OPENSTACK_TAG=master @@ -10,7 +10,7 @@ RUN apk -U upgrade && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ sed -i -E /^packaging==+.*$/d upper-constraints.txt && \ case $(uname -m) in aarch*|arm*) CFLAGS="-O0" \ - pip3 install --no-cache-dir \ + pip3 install --break-system-packages --no-cache-dir \ -cupper-constraints.txt \ -chttps://git.opnfv.org/functest-xtesting/plain/upper-constraints.txt?h=$BRANCH \ lxml ;; esac && \ @@ -18,7 +18,7 @@ RUN apk -U upgrade && \ (cd /src/functest-xtesting && \ git fetch --tags https://gerrit.opnfv.org/gerrit/functest-xtesting $BRANCH && \ git checkout FETCH_HEAD) && \ - pip3 install --no-cache-dir --src /src \ + pip3 install --break-system-packages --no-cache-dir --src /src \ -cupper-constraints.txt \ -chttps://git.opnfv.org/functest-xtesting/plain/upper-constraints.txt?h=$BRANCH \ /src/functest-xtesting && \ @@ -26,7 +26,7 @@ RUN apk -U upgrade && \ addgroup -g 1000 xtesting && adduser -u 1000 -G xtesting -D xtesting && \ mkdir -p /var/lib/xtesting/results && chown -R xtesting: /var/lib/xtesting && \ apk del .build-deps -COPY testcases.yaml /usr/lib/python3.10/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.12/site-packages/xtesting/ci/testcases.yaml USER xtesting WORKDIR /var/lib/xtesting/results CMD ["run_tests", "-t", "all"] diff --git a/docker/core/testcases.yaml b/docker/core/testcases.yaml index deee73b6..3c3bd0b6 100644 --- a/docker/core/testcases.yaml +++ b/docker/core/testcases.yaml @@ -50,7 +50,7 @@ tiers: args: suites: - >- - /usr/lib/python3.10/site-packages/xtesting/samples/HelloWorld.robot + /usr/lib/python3.12/site-packages/xtesting/samples/HelloWorld.robot variable: - 'var01:foo' - 'var02:bar' @@ -64,7 +64,7 @@ tiers: name: behaveframework args: suites: - - /usr/lib/python3.10/site-packages/xtesting/samples/features + - /usr/lib/python3.12/site-packages/xtesting/samples/features tags: - foo - case_name: eighth @@ -76,7 +76,7 @@ tiers: run: name: ansible args: - private_data_dir: /usr/lib/python3.10/site-packages/xtesting/samples + private_data_dir: /usr/lib/python3.12/site-packages/xtesting/samples playbook: helloworld.yml - case_name: nineth project_name: xtesting @@ -88,4 +88,4 @@ tiers: run: name: pytest args: - dir: /usr/lib/python3.10/site-packages/xtesting/samples/fourth.py + dir: /usr/lib/python3.12/site-packages/xtesting/samples/fourth.py diff --git a/elements/xtesting/install.d/16-xtesting b/elements/xtesting/install.d/16-xtesting old mode 100755 new mode 100644 diff --git a/tox.ini b/tox.ini index f3d4523c..aa7f9396 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = docs,pep8,pylint,yamllint,bashate,py310,cover,perm,pre-commit +envlist = docs,pep8,pylint,yamllint,bashate,py312,cover,perm,pre-commit skipsdist = True [testenv] @@ -18,55 +18,51 @@ commands = xtesting/tests/unit [testenv:docs] -basepython = python3.10 +basepython = python3.12 commands = doc8 README.rst api --ignore-path api/build sphinx-build -W -b html api/ api/build [testenv:pep8] -basepython = python3.10 +basepython = python3.12 commands = flake8 [testenv:pylint] -basepython = python3.10 +basepython = python3.12 allowlist_externals = bash commands = pylint --min-similarity-lines=10 \ --disable=locally-disabled --ignore-imports=y --reports=n --extension-pkg-whitelist=lxml xtesting [testenv:yamllint] -basepython = python3.10 -files = - .travis.yml - ansible - xtesting/ci +basepython = python3.12 +files = .travis.yml ansible xtesting/ci commands = yamllint -s {[testenv:yamllint]files} [testenv:bashate] -basepython = python3.10 +basepython = python3.12 files = build.sh commands = bashate {[testenv:bashate]files} [testenv:bandit] -basepython = python3.10 +basepython = python3.12 commands = bandit -r xtesting -x tests -n 5 -ll -s B602 [testenv:cover] -basepython = python3.10 -dirs = - xtesting/tests/unit/ci - xtesting/tests/unit/core - xtesting/tests/unit/utils/test_decorators.py +basepython = python3.12 +dirs = xtesting/tests/unit/ci xtesting/tests/unit/core xtesting/tests/unit/utils/test_decorators.py commands = pytest --cov=xtesting --cov-reset --cov-report html --cov-fail-under=100 \ {[testenv:cover]dirs} [testenv:perm] -basepython = python3.10 +basepython = python3.12 allowlist_externals = bash -path=. -not -path './.tox/*' -not -path './.git/*' -not -path './doc/reveal.js/*' -not -path './elements/xtesting/install.d/*' +path=. -prune -not -path './.tox' -not -path './.git' -not -path './doc/reveal.js' \ + -not -path './elements/xtesting/install.d' -not -name '*.pyc' -not -name '__pycache__' \ + -not -path './doc/api/build' commands = bash -c "\ find {[testenv:perm]path} \( -type f -not -perm 644 -o -type d -not -perm 755 \) \ @@ -75,6 +71,6 @@ commands = find {[testenv:perm]path} -exec file \{\} + | grep CRLF && exit 1 || exit 0" [testenv:pre-commit] -basepython = python3.10 +basepython = python3.12 commands = pre-commit run --all-files --show-diff-on-failure diff --git a/upper-constraints.txt b/upper-constraints.txt index 609c1eda..2cf21e5b 100644 --- a/upper-constraints.txt +++ b/upper-constraints.txt @@ -1,9 +1,10 @@ -robotframework===4.1.2 -bandit===1.7.0 +robotframework===6.1.1 +bandit===1.7.9 behave===1.2.6 -behave-html-formatter===0.9.8 -pylint===2.17.6 -flake8===4.0.1 -ansible-lint===5.2.1 -pre-commit===3.1.1 -astroid===2.15.8 +behave-html-formatter===0.9.10 +pylint===3.2.7 +flake8===7.1.1 +ansible-lint===24.7.0 +pre-commit===3.8.0 +astroid===3.2.4 +sphinx-rtd-theme==3.0.0rc1 diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py index 5b0baf03..0f77f9da 100644 --- a/xtesting/ci/run_tests.py +++ b/xtesting/ci/run_tests.py @@ -302,7 +302,7 @@ class Runner(): if test_case.is_skipped: result = 'SKIP' else: - result = 'PASS' if(test_case.is_successful( + result = 'PASS' if (test_case.is_successful( ) == test_case.EX_OK) else 'FAIL' msg.add_row( [test_case.case_name, test_case.project_name, diff --git a/xtesting/ci/testcases.yaml b/xtesting/ci/testcases.yaml index 59845e60..513a8417 100644 --- a/xtesting/ci/testcases.yaml +++ b/xtesting/ci/testcases.yaml @@ -51,7 +51,7 @@ tiers: args: suites: - >- - /usr/lib/python3.10/site-packages/xtesting/samples/HelloWorld.robot + /usr/lib/python3.12/site-packages/xtesting/samples/HelloWorld.robot variable: - 'var01:foo' - 'var02:bar' @@ -66,7 +66,7 @@ tiers: name: behaveframework args: suites: - - /usr/lib/python3.10/site-packages/xtesting/samples/features + - /usr/lib/python3.12/site-packages/xtesting/samples/features tags: - foo - case_name: eighth @@ -79,7 +79,7 @@ tiers: run: name: ansible args: - private_data_dir: /usr/lib/python3.10/site-packages/xtesting/samples + private_data_dir: /usr/lib/python3.12/site-packages/xtesting/samples playbook: helloworld.yml - case_name: nineth project_name: xtesting @@ -91,4 +91,4 @@ tiers: run: name: pytest args: - dir: /usr/lib/python3.10/site-packages/xtesting/samples/fourth.py + dir: /usr/lib/python3.12/site-packages/xtesting/samples/fourth.py diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py index 380adc5e..4c02e1ca 100644 --- a/xtesting/core/testcase.py +++ b/xtesting/core/testcase.py @@ -79,7 +79,7 @@ class TestCase(metaclass=abc.ABCMeta): if self.is_skipped: result = 'SKIP' else: - result = 'PASS' if(self.is_successful( + result = 'PASS' if (self.is_successful( ) == TestCase.EX_OK) else 'FAIL' msg = prettytable.PrettyTable( header_style='upper', padding_width=5, @@ -106,7 +106,7 @@ class TestCase(metaclass=abc.ABCMeta): assert self.stop_time if self.stop_time < self.start_time: return "XX:XX" - return( + return ( f"{str(int(self.stop_time - self.start_time) // 60).zfill(2)}:" f"{str(int(self.stop_time - self.start_time) % 60).zfill(2)}") diff --git a/xtesting/tests/unit/ci/test_run_tests.py b/xtesting/tests/unit/ci/test_run_tests.py index e2a2712c..1cf300e7 100644 --- a/xtesting/tests/unit/ci/test_run_tests.py +++ b/xtesting/tests/unit/ci/test_run_tests.py @@ -95,7 +95,7 @@ class RunTestsTesting(unittest.TestCase): pass envfile = 'rc_file' with mock.patch('builtins.open', - mock.mock_open(read_data=msg)) as mock_method,\ + mock.mock_open(read_data=msg)) as mock_method, \ mock.patch('os.path.isfile', return_value=True): mock_method.return_value.__iter__ = lambda self: iter( self.readline, '') diff --git a/xtesting/tests/unit/core/test_vnf.py b/xtesting/tests/unit/core/test_vnf.py index 34380a69..1c60d899 100644 --- a/xtesting/tests/unit/core/test_vnf.py +++ b/xtesting/tests/unit/core/test_vnf.py @@ -41,7 +41,7 @@ class VnfBaseTesting(unittest.TestCase): mock_method.assert_called_with() def test_run_deploy_vnf_exc(self): - with mock.patch.object(self.test, 'prepare'),\ + with mock.patch.object(self.test, 'prepare'), \ mock.patch.object(self.test, 'deploy_orchestrator', return_value=True), \ mock.patch.object(self.test, 'deploy_vnf', @@ -51,7 +51,7 @@ class VnfBaseTesting(unittest.TestCase): mock_method.assert_called_with() def test_run_test_vnf_exc(self): - with mock.patch.object(self.test, 'prepare'),\ + with mock.patch.object(self.test, 'prepare'), \ mock.patch.object(self.test, 'deploy_orchestrator', return_value=True), \ mock.patch.object(self.test, 'deploy_vnf', return_value=True), \ @@ -62,7 +62,7 @@ class VnfBaseTesting(unittest.TestCase): mock_method.assert_called_with() def test_run_deploy_orch_ko(self): - with mock.patch.object(self.test, 'prepare'),\ + with mock.patch.object(self.test, 'prepare'), \ mock.patch.object(self.test, 'deploy_orchestrator', return_value=False), \ mock.patch.object(self.test, 'deploy_vnf', @@ -73,7 +73,7 @@ class VnfBaseTesting(unittest.TestCase): testcase.TestCase.EX_TESTCASE_FAILED) def test_run_vnf_deploy_ko(self): - with mock.patch.object(self.test, 'prepare'),\ + with mock.patch.object(self.test, 'prepare'), \ mock.patch.object(self.test, 'deploy_orchestrator', return_value=True), \ mock.patch.object(self.test, 'deploy_vnf', @@ -84,7 +84,7 @@ class VnfBaseTesting(unittest.TestCase): testcase.TestCase.EX_TESTCASE_FAILED) def test_run_vnf_test_ko(self): - with mock.patch.object(self.test, 'prepare'),\ + with mock.patch.object(self.test, 'prepare'), \ mock.patch.object(self.test, 'deploy_orchestrator', return_value=True), \ mock.patch.object(self.test, 'deploy_vnf', @@ -95,7 +95,7 @@ class VnfBaseTesting(unittest.TestCase): testcase.TestCase.EX_TESTCASE_FAILED) def test_run_default(self): - with mock.patch.object(self.test, 'prepare'),\ + with mock.patch.object(self.test, 'prepare'), \ mock.patch.object(self.test, 'deploy_orchestrator', return_value=True), \ mock.patch.object(self.test, 'deploy_vnf', -- 2.16.6