From 8b86dd02328e331cc01b21bf1072e515bbd6db68 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Wed, 11 Aug 2021 15:56:12 +0200 Subject: Update to Alpine 3.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It also disabled wrong order check as it fails vs kubernetes amongst others. [1] https://github.com/PyCQA/pylint/issues/2175 Change-Id: I3d641c213067428848212a148d25d78051c5674f Signed-off-by: Cédric Ollivier --- .circleci/config.yml | 2 +- ansible/site.gate.yml | 2 +- build.sh | 10 +++++----- docker/benchmarking/Dockerfile | 2 +- docker/cnf/Dockerfile | 2 +- docker/core/Dockerfile | 7 ++++--- docker/healthcheck/Dockerfile | 2 +- docker/security/Dockerfile | 2 +- docker/smoke/Dockerfile | 2 +- functest_kubernetes/cnf_conformance/conformance.py | 2 +- functest_kubernetes/ims/ims.py | 11 +++++------ functest_kubernetes/k8stest.py | 9 +++++---- functest_kubernetes/netperf/netperf.py | 2 +- functest_kubernetes/rally/rally_kubernetes.py | 2 +- functest_kubernetes/security/security.py | 11 ++++++----- tox.ini | 18 +++++++++--------- 16 files changed, 44 insertions(+), 42 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8cc5283d..e3f240d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2 jobs: build: docker: - - image: circleci/python:3.8 + - image: circleci/python:3.9 steps: - checkout - run: diff --git a/ansible/site.gate.yml b/ansible/site.gate.yml index 13197cf0..3c63de89 100644 --- a/ansible/site.gate.yml +++ b/ansible/site.gate.yml @@ -10,7 +10,7 @@ - repo: _ dport: container: alpine - tag: 3.13 + tag: 3.14 steps: - name: build opnfv/functest-kubernetes-core containers: diff --git a/build.sh b/build.sh index 629d975e..8da61c42 100644 --- a/build.sh +++ b/build.sh @@ -32,11 +32,11 @@ done [ ! -z "${amd64_dirs}" ] && (docker rmi \ "${repo}/functest-kubernetes-core:amd64-latest" \ - alpine:3.13 || true) + alpine:3.14 || true) find . -name Dockerfile -exec git checkout {} + find . -name Dockerfile -exec sed -i \ - -e "s|alpine:3.13|arm64v8/alpine:3.13|g" {} + + -e "s|alpine:3.14|arm64v8/alpine:3.14|g" {} + find . -name Dockerfile -exec sed -i \ -e "s|opnfv/functest-kubernetes-core|\ ${repo}/functest-kubernetes-core:arm64-latest|g" {} + @@ -56,11 +56,11 @@ for dir in ${arm64_dirs}; do done [ ! -z "${arm64_dirs}" ] && (docker rmi "${repo}/functest-kubernetes-core:arm64-latest" \ - arm64v8/alpine:3.13 || true) + arm64v8/alpine:3.14 || true) find . -name Dockerfile -exec git checkout {} + find . -name Dockerfile -exec sed -i \ - -e "s|alpine:3.13|arm32v7/alpine:3.13|g" {} + + -e "s|alpine:3.14|arm32v7/alpine:3.14|g" {} + find . -name Dockerfile -exec sed -i \ -e "s|opnfv/functest-kubernetes-core|\ ${repo}/functest-kubernetes-core:arm-latest|g" {} + @@ -80,7 +80,7 @@ for dir in ${arm_dirs}; do done [ ! -z "${arm_dirs}" ] && (docker rmi "${repo}/functest-kubernetes-core:arm-latest" \ - arm32v7/alpine:3.13 || true) + arm32v7/alpine:3.14 || true) find . -name Dockerfile -exec git checkout {} + exit $? diff --git a/docker/benchmarking/Dockerfile b/docker/benchmarking/Dockerfile index 09935bd1..3dc88c2e 100644 --- a/docker/benchmarking/Dockerfile +++ b/docker/benchmarking/Dockerfile @@ -16,5 +16,5 @@ RUN apk --no-cache add --update py3-matplotlib && \ mv plotperf.py plotperf && chmod a+x plotperf) && \ rm -rf perf-tests /tmp/plotperf.py.patch && \ apk del .build-deps -COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.9/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/docker/cnf/Dockerfile b/docker/cnf/Dockerfile index f5a89754..c7cd53d1 100644 --- a/docker/cnf/Dockerfile +++ b/docker/cnf/Dockerfile @@ -29,5 +29,5 @@ RUN apk --no-cache add --update wget curl libc6-compat ncurses && \ ln -s /src/cnf-testsuite/points-all.yml /src/cnf-testsuite/points.yml && \ helm repo add stable https://cncf.gitlab.io/stable && \ rm -rf /src/cnf-testsuite-$CNF_TESTSUITE_TAG.tar.gz /src/cnf-testsuite/.git ;; esac -COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.9/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/docker/core/Dockerfile b/docker/core/Dockerfile index af6d90c5..89e54fc9 100644 --- a/docker/core/Dockerfile +++ b/docker/core/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.13 +FROM alpine:3.14 ARG BRANCH=master ARG OPENSTACK_TAG=master @@ -19,6 +19,7 @@ RUN apk -U upgrade && \ apk add --no-cache py3-pynacl ;; esac && \ sed -i -E /^six=/d /src/requirements/upper-constraints.txt && \ sed -i -E /^distlib=/d /src/requirements/upper-constraints.txt && \ + sed -i -E /^packaging=/d /src/requirements/upper-constraints.txt && \ apk --no-cache add --update py3-distlib\>=0.3.1 \ --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main && \ git init /src/functest-kubernetes && \ @@ -44,6 +45,6 @@ RUN apk -U upgrade && \ mkdir -p /var/lib/rally/database && rally db create && \ rm -r /src/requirements/.git /tmp/Try-a-quick-fix-vs-asynchronuous-issues.patch && \ apk del .build-deps -COPY logging.ini /usr/lib/python3.8/site-packages/xtesting/ci/logging.ini -COPY logging.debug.ini /usr/lib/python3.8/site-packages/xtesting/ci/logging.debug.ini +COPY logging.ini /usr/lib/python3.9/site-packages/xtesting/ci/logging.ini +COPY logging.debug.ini /usr/lib/python3.9/site-packages/xtesting/ci/logging.debug.ini CMD ["run_tests", "-t", "all"] diff --git a/docker/healthcheck/Dockerfile b/docker/healthcheck/Dockerfile index 0a19e3a1..4788413d 100644 --- a/docker/healthcheck/Dockerfile +++ b/docker/healthcheck/Dockerfile @@ -13,5 +13,5 @@ RUN apk --no-cache add --update curl libc6-compat && \ mv /src/kubernetes/test/bin/e2e.test /src/kubernetes/test/bin/ginkgo /usr/local/bin/ && \ chmod +x /usr/local/bin/kubectl /usr/local/bin/e2e.test /usr/local/bin/ginkgo && \ rm -r /src/kubernetes /src/kubernetes-test-linux-$arch.tar.gz -COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.9/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/docker/security/Dockerfile b/docker/security/Dockerfile index 915ebd65..d3434366 100644 --- a/docker/security/Dockerfile +++ b/docker/security/Dockerfile @@ -1,3 +1,3 @@ FROM opnfv/functest-kubernetes-core -COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.9/site-packages/xtesting/ci/testcases.yaml diff --git a/docker/smoke/Dockerfile b/docker/smoke/Dockerfile index 72ad2e6e..d410efb3 100644 --- a/docker/smoke/Dockerfile +++ b/docker/smoke/Dockerfile @@ -1,4 +1,4 @@ FROM opnfv/functest-kubernetes-healthcheck -COPY testcases.yaml /usr/lib/python3.8/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.9/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/functest_kubernetes/cnf_conformance/conformance.py b/functest_kubernetes/cnf_conformance/conformance.py index 13268e24..8956598a 100644 --- a/functest_kubernetes/cnf_conformance/conformance.py +++ b/functest_kubernetes/cnf_conformance/conformance.py @@ -43,7 +43,7 @@ class CNFConformance(testcase.TestCase): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(CNFConformance, self).__init__(**kwargs) + super().__init__(**kwargs) self.output_log_name = 'functest-kubernetes.log' self.output_debug_log_name = 'functest-kubernetes.debug.log' diff --git a/functest_kubernetes/ims/ims.py b/functest_kubernetes/ims/ims.py index 49a66370..18e8c0de 100644 --- a/functest_kubernetes/ims/ims.py +++ b/functest_kubernetes/ims/ims.py @@ -14,9 +14,9 @@ from __future__ import division import abc import logging import os -import time -import subprocess import re +import subprocess +import time import yaml from jinja2 import Template @@ -24,7 +24,6 @@ from kubernetes import client from kubernetes import config from kubernetes import watch import pkg_resources - from xtesting.core import testcase @@ -51,7 +50,7 @@ class Vims(testcase.TestCase): # pylint: disable=too-many-instance-attributes "homestead", "homestead-prov", "ralf", "sprout"] def __init__(self, **kwargs): - super(Vims, self).__init__(**kwargs) + super().__init__(**kwargs) config.load_kube_config() self.corev1 = client.CoreV1Api() self.appsv1 = client.AppsV1Api() @@ -260,7 +259,7 @@ class K8sVims(Vims): "delete_namespaced_service: %s", api_response) except client.rest.ApiException: pass - super(K8sVims, self).clean() + super().clean() class HelmVims(Vims): @@ -293,4 +292,4 @@ class HelmVims(Vims): cmd = ["helm", "uninstall", "clearwater", "-n", self.namespace] output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) self.__logger.debug(output.decode("utf-8")) - super(HelmVims, self).clean() + super().clean() diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py index 2d17a27d..b450dac4 100644 --- a/functest_kubernetes/k8stest.py +++ b/functest_kubernetes/k8stest.py @@ -35,7 +35,7 @@ class E2ETesting(testcase.TestCase): k8s_gcr_repo = os.getenv("MIRROR_REPO", "k8s.gcr.io") def __init__(self, **kwargs): - super(E2ETesting, self).__init__(**kwargs) + super().__init__(**kwargs) self.cmd = [] self.dir_results = "/home/opnfv/functest/results" self.res_dir = os.path.join(self.dir_results, self.case_name) @@ -74,9 +74,10 @@ class E2ETesting(testcase.TestCase): self.__logger.info("Starting k8s test: '%s'.", cmd_line) env = os.environ.copy() env["KUBE_TEST_REPO_LIST"] = "{}/repositories.yml".format(self.res_dir) - process = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, env=env) - boutput = process.stdout.read() + with subprocess.Popen( + cmd_line, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, env=env) as process: + boutput = process.stdout.read() with open(os.path.join(self.res_dir, 'e2e.log'), 'wb') as foutput: foutput.write(boutput) grp = re.search( diff --git a/functest_kubernetes/netperf/netperf.py b/functest_kubernetes/netperf/netperf.py index 3135a6c5..2bd1e1be 100644 --- a/functest_kubernetes/netperf/netperf.py +++ b/functest_kubernetes/netperf/netperf.py @@ -27,7 +27,7 @@ class Netperf(testcase.TestCase): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(Netperf, self).__init__(**kwargs) + super().__init__(**kwargs) self.output_log_name = 'functest-kubernetes.log' self.output_debug_log_name = 'functest-kubernetes.debug.log' diff --git a/functest_kubernetes/rally/rally_kubernetes.py b/functest_kubernetes/rally/rally_kubernetes.py index f5d7e955..3543fa99 100644 --- a/functest_kubernetes/rally/rally_kubernetes.py +++ b/functest_kubernetes/rally/rally_kubernetes.py @@ -36,7 +36,7 @@ class RallyKubernetes(testcase.TestCase): k8s_gcr_repo = os.getenv("MIRROR_REPO", "k8s.gcr.io") def __init__(self, **kwargs): - super(RallyKubernetes, self).__init__(**kwargs) + super().__init__(**kwargs) self.dir_results = "/home/opnfv/functest/results" self.res_dir = os.path.join(self.dir_results, self.case_name) self.output_log_name = 'functest-kubernetes.log' diff --git a/functest_kubernetes/security/security.py b/functest_kubernetes/security/security.py index 052c0ad4..b6f19c75 100644 --- a/functest_kubernetes/security/security.py +++ b/functest_kubernetes/security/security.py @@ -27,6 +27,7 @@ from kubernetes import config from kubernetes import watch import pkg_resources import prettytable + from xtesting.core import testcase @@ -39,7 +40,7 @@ class SecurityTesting(testcase.TestCase): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(SecurityTesting, self).__init__(**kwargs) + super().__init__(**kwargs) config.load_kube_config() self.corev1 = client.CoreV1Api() self.batchv1 = client.BatchV1Api() @@ -133,7 +134,7 @@ class KubeHunter(SecurityTesting): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(KubeHunter, self).__init__(**kwargs) + super().__init__(**kwargs) self.job_name = "kube-hunter" self.ns_generate_name = "kube-hunter-" @@ -181,7 +182,7 @@ class KubeHunter(SecurityTesting): self.__logger.info("\n\n%s\n", msg.get_string()) def run(self, **kwargs): - super(KubeHunter, self).run(**kwargs) + super().run(**kwargs) try: self.process_results(**kwargs) except Exception: # pylint: disable=broad-except @@ -200,13 +201,13 @@ class KubeBench(SecurityTesting): __logger = logging.getLogger(__name__) def __init__(self, **kwargs): - super(KubeBench, self).__init__(**kwargs) + super().__init__(**kwargs) self.job_name = "kube-bench" self.ns_generate_name = "kube-bench-" def run(self, **kwargs): self.job_name = "kube-bench-{}".format(kwargs.get("target", "node")) - super(KubeBench, self).run(**kwargs) + super().run(**kwargs) self.details["report"] = ast.literal_eval(self.pod_log) msg = prettytable.PrettyTable( header_style='upper', padding_width=5, diff --git a/tox.ini b/tox.ini index f4df0a90..01a8286d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,pylint,yamllint,ansiblelint,bashate,py38,bandit,perm +envlist = pep8,pylint,yamllint,ansiblelint,bashate,py39,bandit,perm [testenv] pip_version = pip==20.2.4 @@ -19,17 +19,17 @@ commands = nosetests --with-xunit \ functest_kubernetes [testenv:pep8] -basepython = python3.8 +basepython = python3.9 commands = flake8 [testenv:pylint] -basepython = python3.8 +basepython = python3.9 commands = pylint \ --ignore-imports=y --min-similarity-lines=10 \ - --disable=locally-disabled --reports=n functest_kubernetes + --disable=locally-disabled,wrong-import-order --reports=n functest_kubernetes [testenv:yamllint] -basepython = python3.8 +basepython = python3.9 files = .travis.yml docker @@ -37,25 +37,25 @@ commands = yamllint {[testenv:yamllint]files} [testenv:ansiblelint] -basepython = python3.8 +basepython = python3.9 commands = ansible-lint -x303 ansible/site.yml [testenv:bandit] -basepython = python3.8 +basepython = python3.9 commands = bandit -r functest_kubernetes -x tests -n 5 -ll [testenv:py37] commands = nosetests functest_kubernetes [testenv:bashate] -basepython = python3.8 +basepython = python3.9 files = build.sh functest_kubernetes/ci/download_images.sh commands = bashate -e E005,E006,E042,E043 {[testenv:bashate]files} [testenv:perm] -basepython = python3.8 +basepython = python3.9 whitelist_externals = bash path=. -not -path './.tox/*' -not -path './.git/*' -not -path './doc/pres/reveal.js/*' commands = -- cgit 1.2.3-korg