From c1b25e9a487436c75d2f0fd625b95c6c59563e64 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Thu, 12 Sep 2019 10:22:49 +0200 Subject: Select python 3.6 as default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It switches to Python3 as default due to new OPNFV iruya release date (December) which is very closed to Python2 EOL. Functest Iruya (first release published in April) has supported both Python2 and Python3. Change-Id: I4c1294a5361e591fc7a8a88b3d067fc3b39e00c4 Signed-off-by: Cédric Ollivier --- docker/benchmarking/Dockerfile | 10 +++++----- docker/core/Dockerfile | 15 ++++++++------- docker/healthcheck/Dockerfile | 6 +++--- docker/smoke/Dockerfile | 8 ++++---- docker/tempest/Dockerfile | 6 +++--- docker/vnf/Dockerfile | 6 +++--- functest/core/cloudify.py | 7 +++---- functest/core/singlevm.py | 9 ++++----- functest/core/tenantnetwork.py | 2 +- functest/opnfv_tests/openstack/rally/rally.py | 22 +++++++--------------- .../opnfv_tests/openstack/vping/vping_userdata.py | 2 +- functest/opnfv_tests/sdn/odl/odl.py | 2 +- functest/opnfv_tests/vnf/epc/juju_epc.py | 4 ++-- functest/opnfv_tests/vnf/ims/clearwater.py | 19 ++++++++----------- functest/opnfv_tests/vnf/ims/cloudify_ims.py | 4 ++-- functest/opnfv_tests/vnf/ims/heat_ims.py | 2 +- .../opnfv_tests/vnf/router/cloudify_vrouter.py | 2 +- .../router/test_controller/function_test_exec.py | 2 +- functest/opnfv_tests/vnf/router/utilvnf.py | 2 +- .../vnf/router/vnf_controller/checker.py | 2 +- .../vnf/router/vnf_controller/command_generator.py | 2 +- .../vnf/router/vnf_controller/ssh_client.py | 4 ++-- .../vnf/router/vnf_controller/vm_controller.py | 2 +- .../vnf/router/vnf_controller/vnf_controller.py | 2 +- functest/opnfv_tests/vnf/router/vrouter_base.py | 2 +- functest/tests/unit/utils/test_functest_utils.py | 4 ++-- functest/utils/config.py | 2 +- tox.ini | 18 +++++++++--------- upper-constraints.txt | 2 +- 29 files changed, 79 insertions(+), 91 deletions(-) diff --git a/docker/benchmarking/Dockerfile b/docker/benchmarking/Dockerfile index 67bb21953..6eb1e46fc 100644 --- a/docker/benchmarking/Dockerfile +++ b/docker/benchmarking/Dockerfile @@ -3,24 +3,24 @@ FROM opnfv/functest-tempest:iruya ARG BRANCH=stable/iruya ARG OPENSTACK_TAG=stable/stein ARG TEMPEST_TAG=21.0.0 -ARG VMTP_TAG=2.5.0 +ARG VMTP_TAG=dc79be8a3b566507e1907a70fc9eaf0f1d6c9e9c RUN apk --no-cache add --update libxml2 libxslt && \ apk --no-cache add --virtual .build-deps --update \ - python-dev build-base linux-headers libffi-dev \ + python3-dev build-base linux-headers libffi-dev \ openssl-dev libjpeg-turbo-dev libxml2-dev libxslt-dev && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ sed -i -E s/^tempest==+.*$/-e\ git+https:\\/\\/opendev.org\\/openstack\\/tempest@$TEMPEST_TAG#egg=tempest/ upper-constraints.txt && \ case $(uname -m) in aarch*|arm*) sed -i -E /^PyNaCl=/d upper-constraints.txt ;; esac && \ wget -q -O- https://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH > upper-constraints.opnfv.txt && \ sed -i -E /#egg=functest/d upper-constraints.opnfv.txt && \ - case $(uname -m) in aarch*|arm*) CFLAGS="-O0" pip install --no-cache-dir -cupper-constraints.txt -cupper-constraints.opnfv.txt lxml ;; esac && \ + case $(uname -m) in aarch*|arm*) CFLAGS="-O0" pip3 install --no-cache-dir -cupper-constraints.txt -cupper-constraints.opnfv.txt lxml ;; esac && \ git init /src/vmtp && \ (cd /src/vmtp && \ git fetch --tags https://opendev.org/x/vmtp.git $VMTP_TAG && \ git checkout FETCH_HEAD) && \ update-requirements -s --source /src/openstack-requirements /src/vmtp/ && \ - pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ /src/vmtp && \ mkdir -p /home/opnfv/functest/data/rally/neutron && \ git init /src/neutron && \ @@ -30,5 +30,5 @@ RUN apk --no-cache add --update libxml2 libxslt && \ cp -r /src/neutron/rally-jobs /home/opnfv/functest/data/rally/neutron/rally-jobs && \ rm -r upper-constraints.txt upper-constraints.opnfv.txt /src/vmtp /src/neutron && \ apk del .build-deps -COPY testcases.yaml /usr/lib/python2.7/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.6/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/docker/core/Dockerfile b/docker/core/Dockerfile index c60fb9e47..9903ce2b1 100644 --- a/docker/core/Dockerfile +++ b/docker/core/Dockerfile @@ -4,28 +4,29 @@ ARG BRANCH=stable/iruya ARG OPENSTACK_TAG=stable/stein RUN apk --no-cache add --update \ - python libffi openssl libjpeg-turbo py-pip bash \ + python3 libffi openssl libjpeg-turbo py3-pip bash \ grep sed wget ca-certificates git openssh-client qemu-img iputils && \ apk --no-cache add --virtual .build-deps --update \ - python-dev build-base linux-headers libffi-dev \ + python3-dev build-base linux-headers libffi-dev \ openssl-dev libjpeg-turbo-dev && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ - case $(uname -m) in aarch*|arm*) sed -i -E /^PyNaCl=/d upper-constraints.txt && apk add --no-cache py-pynacl ;; esac && \ + case $(uname -m) in aarch*|arm*) sed -i -E /^PyNaCl=/d upper-constraints.txt && apk add --no-cache py3-pynacl ;; esac && \ wget -q -O- https://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH > upper-constraints.opnfv.txt && \ sed -i -E /#egg=functest/d upper-constraints.opnfv.txt && \ - pip install --no-cache-dir --src /src -cupper-constraints.opnfv.txt -cupper-constraints.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.opnfv.txt -cupper-constraints.txt \ -e git+https://opendev.org/openstack/requirements@$OPENSTACK_TAG#egg=openstack_requirements && \ git init /src/functest && \ (cd /src/functest && \ git fetch --tags https://gerrit.opnfv.org/gerrit/functest $BRANCH && \ git checkout FETCH_HEAD) && \ update-requirements -s --source /src/openstack-requirements /src/functest && \ - pip install --no-cache-dir --src /src -cupper-constraints.opnfv.txt -cupper-constraints.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.opnfv.txt -cupper-constraints.txt \ /src/functest && \ rm -r upper-constraints.txt upper-constraints.opnfv.txt /src/functest && \ - cp /usr/lib/python2.7/site-packages/functest/ci/logging.ini /usr/lib/python2.7/site-packages/xtesting/ci/ && \ - cp /usr/lib/python2.7/site-packages/functest/ci/logging.debug.ini /usr/lib/python2.7/site-packages/xtesting/ci/ && \ + cp /usr/lib/python3.6/site-packages/functest/ci/logging.ini /usr/lib/python3.6/site-packages/xtesting/ci/ && \ + cp /usr/lib/python3.6/site-packages/functest/ci/logging.debug.ini /usr/lib/python3.6/site-packages/xtesting/ci/ && \ bash -c "mkdir -p /var/lib/xtesting /home/opnfv" && \ ln -s /var/lib/xtesting /home/opnfv/functest && \ bash -c "mkdir -p /home/opnfv/functest{/conf,/data,/images,/results} /home/opnfv/repos/vnfs" && \ + ln -s /usr/bin/python3 /usr/bin/python && \ apk del .build-deps diff --git a/docker/healthcheck/Dockerfile b/docker/healthcheck/Dockerfile index 06a83ed20..a41668314 100644 --- a/docker/healthcheck/Dockerfile +++ b/docker/healthcheck/Dockerfile @@ -7,13 +7,13 @@ ARG ODL_TAG=85448c9d97b89989488e675b29b38ac42d8674e4 COPY thirdparty-requirements.txt thirdparty-requirements.txt RUN apk --no-cache add --virtual .build-deps --update \ - python-dev build-base linux-headers libffi-dev openssl-dev && \ + python3-dev build-base linux-headers libffi-dev openssl-dev && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ sed -i -E s/^tempest==+.*$/-e\ git+https:\\/\\/opendev.org\\/openstack\\/tempest@$TEMPEST_TAG#egg=tempest/ upper-constraints.txt && \ case $(uname -m) in aarch*|arm*) sed -i -E /^PyNaCl=/d upper-constraints.txt ;; esac && \ wget -q -O- https://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH > upper-constraints.opnfv.txt && \ sed -i -E /#egg=functest/d upper-constraints.opnfv.txt && \ - pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ -rthirdparty-requirements.txt && \ git init /src/odl_test && \ (cd /src/odl_test && \ @@ -22,5 +22,5 @@ RUN apk --no-cache add --virtual .build-deps --update \ rm -r /src/odl_test/.git thirdparty-requirements.txt upper-constraints.txt \ upper-constraints.opnfv.txt && \ apk del .build-deps -COPY testcases.yaml /usr/lib/python2.7/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.6/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/docker/smoke/Dockerfile b/docker/smoke/Dockerfile index 6ea056502..408eeab03 100644 --- a/docker/smoke/Dockerfile +++ b/docker/smoke/Dockerfile @@ -9,7 +9,7 @@ ARG NEUTRON_TEMPEST_TAG=0.3.0 ARG BARBICAN_TAG=0.1.0 RUN apk --no-cache add --virtual .build-deps --update \ - python-dev build-base linux-headers libffi-dev \ + python3-dev build-base linux-headers libffi-dev \ openssl-dev libjpeg-turbo-dev libxml2-dev libxslt-dev && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ sed -i -E s/^tempest==+.*$/-e\ git+https:\\/\\/opendev.org\\/openstack\\/tempest@$TEMPEST_TAG#egg=tempest/ upper-constraints.txt && \ @@ -31,14 +31,14 @@ RUN apk --no-cache add --virtual .build-deps --update \ git fetch --tags https://opendev.org/openstack/barbican-tempest-plugin.git $BARBICAN_TAG && \ git checkout FETCH_HEAD) && \ update-requirements -s --source /src/openstack-requirements /src/barbican-tempest-plugin/ && \ - pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ /src/patrole /src/barbican-tempest-plugin /src/neutron-tempest-plugin \ networking-bgpvpn networking-sfc && \ mkdir -p /home/opnfv/functest/data/refstack && \ mkdir -p /etc/neutron /etc/cinder /etc/glance /etc/keystone /etc/nova && \ wget -q -O /etc/glance/policy.json https://opendev.org/openstack/glance/raw/branch/$OPENSTACK_TAG/etc/policy.json && \ virtualenv --no-pip --no-setuptools --no-wheel oslo && . oslo/bin/activate && \ - pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ oslo.policy neutron && \ oslopolicy-sample-generator --format json --output-file /etc/neutron/policy.json --namespace neutron && \ deactivate && \ @@ -48,5 +48,5 @@ RUN apk --no-cache add --virtual .build-deps --update \ COPY compute.txt /home/opnfv/functest/data/refstack/compute.txt COPY object.txt /home/opnfv/functest/data/refstack/object.txt COPY platform.txt /home/opnfv/functest/data/refstack/platform.txt -COPY testcases.yaml /usr/lib/python2.7/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.6/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/docker/tempest/Dockerfile b/docker/tempest/Dockerfile index 2835285f6..432750718 100644 --- a/docker/tempest/Dockerfile +++ b/docker/tempest/Dockerfile @@ -8,7 +8,7 @@ ARG RALLY_OPENSTACK_TAG=1.5.0 ARG UJSON_TAG=d25e024f481c5571d15f3c0c406a498ca0467cfd RUN apk --no-cache add --virtual .build-deps --update \ - python-dev build-base linux-headers libffi-dev \ + python3-dev build-base linux-headers libffi-dev \ openssl-dev libjpeg-turbo-dev && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ sed -i -E s/^tempest==+.*$/-e\ git+https:\\/\\/opendev.org\\/openstack\\/tempest@$TEMPEST_TAG#egg=tempest/ upper-constraints.txt && \ @@ -24,9 +24,9 @@ RUN apk --no-cache add --virtual .build-deps --update \ (git clone https://opendev.org/openstack/rally-openstack.git /src/rally-openstack && \ cd /src/rally-openstack && git checkout $RALLY_OPENSTACK_TAG) && \ update-requirements -s --source /src/openstack-requirements /src/rally-openstack && \ - pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ tempest /src/rally-openstack && \ - pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ /src/rally && \ rm -r upper-constraints.txt upper-constraints.opnfv.txt /src/rally /src/rally-openstack && \ mkdir -p /etc/rally && \ diff --git a/docker/vnf/Dockerfile b/docker/vnf/Dockerfile index 200bced2d..835890e17 100644 --- a/docker/vnf/Dockerfile +++ b/docker/vnf/Dockerfile @@ -21,7 +21,7 @@ ENV PATH $GOBIN:$PATH COPY clearwater-heat-singlenet-deps.patch /tmp/clearwater-heat-singlenet-deps.patch RUN apk --no-cache add --update \ ruby ruby-bundler ruby-irb ruby-rdoc \ - procps libxslt libxml2 zlib libffi python3 go musl-dev && \ + procps libxslt libxml2 zlib libffi go musl-dev && \ apk --no-cache add --virtual .build-deps --update \ ruby-dev g++ make libxslt-dev libxml2-dev zlib-dev libffi-dev g++ make && \ wget -q -O- https://opendev.org/openstack/requirements/raw/branch/$OPENSTACK_TAG/upper-constraints.txt > upper-constraints.txt && \ @@ -64,7 +64,7 @@ RUN apk --no-cache add --update \ (cd /src/epc-requirements/abot_charm && \ git fetch --tags https://github.com/RebacaInc/abot_charm.git $ABOT_CHARM && \ git checkout FETCH_HEAD) && \ - python3 -m pip install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ + pip3 install --no-cache-dir --src /src -cupper-constraints.txt -cupper-constraints.opnfv.txt \ juju-wait==$JUJU_WAIT_TAG && \ go get -d github.com/rogpeppe/godeps && \ (cd $GOPATH/src/github.com/rogpeppe/godeps && git checkout $GODEPS_TAG && go install -v github.com/rogpeppe/godeps) && \ @@ -78,5 +78,5 @@ RUN apk --no-cache add --update \ /src/vims-test/build-infra/.git /src/opnfv-vnf-vyos-blueprint/.git \ /tmp/clearwater-heat-singlenet-deps.patch && \ apk del .build-deps -COPY testcases.yaml /usr/lib/python2.7/site-packages/xtesting/ci/testcases.yaml +COPY testcases.yaml /usr/lib/python3.6/site-packages/xtesting/ci/testcases.yaml CMD ["run_tests", "-t", "all"] diff --git a/functest/core/cloudify.py b/functest/core/cloudify.py index 21bfc937e..b5bd1b3c2 100644 --- a/functest/core/cloudify.py +++ b/functest/core/cloudify.py @@ -147,7 +147,7 @@ class Cloudify(singlevm.SingleVm2): self.cfy_client.executions.cancel( execution['id'], force=True) except Exception: # pylint: disable=broad-except - self.__logger.warn("Can't cancel the current exec") + self.__logger.warning("Can't cancel the current exec") execution = self.cfy_client.executions.start( dep_name, 'uninstall', parameters=dict(ignore_failure=True)) wait_for_execution(self.cfy_client, execution, self.__logger) @@ -191,9 +191,8 @@ def wait_for_execution(client, execution, logger, timeout=3600, ): 'execution of operation {0} for deployment {1} ' 'timed out'.format(execution.workflow_id, execution.deployment_id)) - else: - # update the remaining timeout - timeout = deadline - time.time() + # update the remaining timeout + timeout = deadline - time.time() if not execution_ended: execution = client.executions.get(execution.id) diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py index 1da30de34..0473a21da 100644 --- a/functest/core/singlevm.py +++ b/functest/core/singlevm.py @@ -230,11 +230,10 @@ class VmReady1(tenantnetwork.TenantNetwork1): self.__logger.debug( "regex found: '%s' in console\n%s", regex, console) return True - else: - self.__logger.debug( - "try %s: cannot find regex '%s' in console\n%s", - iloop + 1, regex, console) - time.sleep(10) + self.__logger.debug( + "try %s: cannot find regex '%s' in console\n%s", + iloop + 1, regex, console) + time.sleep(10) self.__logger.error("cannot find regex '%s' in console", regex) return False diff --git a/functest/core/tenantnetwork.py b/functest/core/tenantnetwork.py index ae739ac36..604e49ae5 100644 --- a/functest/core/tenantnetwork.py +++ b/functest/core/tenantnetwork.py @@ -33,7 +33,7 @@ from functest.utils import config from functest.utils import env -class NewProject(object): +class NewProject(): """Ease creating new projects/users""" # pylint: disable=too-many-instance-attributes diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 8100edaff..9a04f3873 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -22,7 +22,6 @@ import shutil import subprocess import time -from threading import Timer import pkg_resources import prettytable from ruamel.yaml import YAML @@ -101,7 +100,6 @@ class RallyBase(singlevm.VmReady2): self.run_cmd = '' self.network_extensions = [] self.services = [] - self.task_aborted = False def build_task_args(self, test_name): """Build arguments for the Rally task.""" @@ -425,25 +423,19 @@ class RallyBase(singlevm.VmReady2): else: LOGGER.info('Test scenario: "%s" Failed.', test_name) - def kill_task(self, proc): - """ Kill a task.""" - proc.kill() - self.task_aborted = True - def run_task(self, test_name): """Run a task.""" LOGGER.info('Starting test scenario "%s" ...', test_name) LOGGER.debug('running command: %s', self.run_cmd) proc = subprocess.Popen(self.run_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - self.task_aborted = False - timer = Timer(self.task_timeout, self.kill_task, [proc]) - timer.start() - output = proc.communicate()[0] - if self.task_aborted: - LOGGER.error("Failed to complete task") - raise Exception("Failed to complete task") - timer.cancel() + try: + output = proc.communicate(timeout=self.task_timeout)[0] + except subprocess.TimeoutExpired: + proc.kill() + proc.communicate() + LOGGER.error("Failed to complete run task") + raise Exception("Failed to complete run task") task_id = self.get_task_id(output) LOGGER.debug('task_id : %s', task_id) if task_id is None: diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py index a58184c59..225c167d5 100644 --- a/functest/opnfv_tests/openstack/vping/vping_userdata.py +++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py @@ -88,7 +88,7 @@ class VPingUserdata(singlevm.VmReady2): elif sec % 10 == 0: if "request failed" in p_console: self.logger.debug( - "It seems userdata is not supported in nova boot. " + + "It seems userdata is not supported in nova boot. " "Waiting a bit...") tries += 1 else: diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py index 17600a316..b54f0f54b 100644 --- a/functest/opnfv_tests/sdn/odl/odl.py +++ b/functest/opnfv_tests/sdn/odl/odl.py @@ -189,7 +189,7 @@ class ODLTests(robotframework.RobotFramework): return self.run_suites(suites, **kwargs) -class ODLParser(object): # pylint: disable=too-few-public-methods +class ODLParser(): # pylint: disable=too-few-public-methods """Parser to run ODL test suites.""" def __init__(self): diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index 7c8a925bb..5a0a86b0c 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -148,13 +148,13 @@ class JujuEpc(singlevm.VmReady2): def check_requirements(self): if not os.path.exists("/src/epc-requirements/go/bin/juju"): - self.__logger.warn( + self.__logger.warning( "Juju cannot be cross-compiled (arm and arm64) from the time " "being") self.is_skipped = True self.project.clean() if env.get('NEW_USER_ROLE').lower() == "admin": - self.__logger.warn( + self.__logger.warning( "Defining NEW_USER_ROLE=admin will easily break the testcase " "because Juju doesn't manage tenancy (e.g. subnet " "overlapping)") diff --git a/functest/opnfv_tests/vnf/ims/clearwater.py b/functest/opnfv_tests/vnf/ims/clearwater.py index 64f0428b3..67128b11c 100644 --- a/functest/opnfv_tests/vnf/ims/clearwater.py +++ b/functest/opnfv_tests/vnf/ims/clearwater.py @@ -24,7 +24,7 @@ __author__ = ("Valentin Boucher , " "Helen Yao ") -class ClearwaterTesting(object): +class ClearwaterTesting(): """vIMS clearwater base usable by several orchestrators""" def __init__(self, case_name, bono_ip, ellis_ip): @@ -91,8 +91,7 @@ class ClearwaterTesting(object): 'Account %s is created on Ellis\n%s', params.get('full_name'), account_res) return account_res - else: - raise Exception("Cannot create ellis account") + raise Exception("Cannot create ellis account") except Exception: # pylint: disable=broad-except self.logger.info( "try %s: cannot create ellis account", iloop + 1) @@ -110,8 +109,7 @@ class ClearwaterTesting(object): cookies = req.cookies self.logger.debug('cookies: %s', cookies) return cookies - else: - raise Exception('Failed to get cookies for Ellis') + raise Exception('Failed to get cookies for Ellis') except Exception: # pylint: disable=broad-except self.logger.info( "try %s: cannot get cookies for Ellis", iloop + 1) @@ -128,13 +126,12 @@ class ClearwaterTesting(object): self.logger.info( 'Calling number is created: %s', number_res) return number_res + if req and req.json(): + reason = req.json()['reason'] else: - if req and req.json(): - reason = req.json()['reason'] - else: - reason = req - self.logger.info("cannot create a number: %s", reason) - raise Exception('Failed to create a number') + reason = req + self.logger.info("cannot create a number: %s", reason) + raise Exception('Failed to create a number') except Exception: # pylint: disable=broad-except self.logger.info( "try %s: cannot create a number", iloop + 1) diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index 0f6adf96a..d937cc052 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -103,7 +103,7 @@ class CloudifyIms(cloudify.Cloudify): def check_requirements(self): if env.get('NEW_USER_ROLE').lower() == "admin": - self.__logger.warn( + self.__logger.warning( "Defining NEW_USER_ROLE=admin will easily break the testcase " "because Cloudify doesn't manage tenancy (e.g. subnet " "overlapping)") @@ -250,7 +250,7 @@ class CloudifyIms(cloudify.Cloudify): self.result += vnf_test_rate / 3 * 100 if vnf_test_rate == 0: self.details['test_vnf'].update(status='FAIL') - return True if vnf_test_rate > 0 else False + return bool(vnf_test_rate > 0) def clean(self): """Clean created objects/functions.""" diff --git a/functest/opnfv_tests/vnf/ims/heat_ims.py b/functest/opnfv_tests/vnf/ims/heat_ims.py index 9ea9c5627..4a57a7445 100644 --- a/functest/opnfv_tests/vnf/ims/heat_ims.py +++ b/functest/opnfv_tests/vnf/ims/heat_ims.py @@ -234,7 +234,7 @@ class HeatIms(singlevm.VmReady2): if vnf_test_rate == 0: self.details['test_vnf'].update(status='FAIL') self._monit() - return True if vnf_test_rate > 0 else False + return bool(vnf_test_rate > 0) def clean(self): """Clean created objects/functions.""" diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py index b449d2d81..c793953d3 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -113,7 +113,7 @@ class CloudifyVrouter(cloudify.Cloudify): def check_requirements(self): if env.get('NEW_USER_ROLE').lower() == "admin": - self.__logger.warn( + self.__logger.warning( "Defining NEW_USER_ROLE=admin will easily break the testcase " "because Cloudify doesn't manage tenancy (e.g. subnet " "overlapping)") diff --git a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py index 0b8a69b73..0a56913b7 100644 --- a/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py +++ b/functest/opnfv_tests/vnf/router/test_controller/function_test_exec.py @@ -21,7 +21,7 @@ from functest.opnfv_tests.vnf.router.vnf_controller.vnf_controller import ( VnfController) -class FunctionTestExec(object): +class FunctionTestExec(): """vrouter function test execution class""" logger = logging.getLogger(__name__) diff --git a/functest/opnfv_tests/vnf/router/utilvnf.py b/functest/opnfv_tests/vnf/router/utilvnf.py index a54f6cb0b..2db3b38e5 100644 --- a/functest/opnfv_tests/vnf/router/utilvnf.py +++ b/functest/opnfv_tests/vnf/router/utilvnf.py @@ -43,7 +43,7 @@ NUMBER_OF_DIGITS_FOR_AVG_JITTER = 3 NUMBER_OF_DIGITS_FOR_AVG_PKT_LOSS = 1 -class Utilvnf(object): # pylint: disable=too-many-instance-attributes +class Utilvnf(): # pylint: disable=too-many-instance-attributes """ Utility class of vrouter testcase """ logger = logging.getLogger(__name__) diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/checker.py b/functest/opnfv_tests/vnf/router/vnf_controller/checker.py index a7a70f6d7..d3a216ed0 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/checker.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/checker.py @@ -18,7 +18,7 @@ import re from jinja2 import Environment, FileSystemLoader -class Checker(object): +class Checker(): """vrouter test result check class""" logger = logging.getLogger(__name__) diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/command_generator.py b/functest/opnfv_tests/vnf/router/vnf_controller/command_generator.py index 7d9116bcc..a86a16485 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/command_generator.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/command_generator.py @@ -15,7 +15,7 @@ import logging from jinja2 import Environment, FileSystemLoader -class CommandGenerator(object): +class CommandGenerator(): """command generator class for vrouter testing""" logger = logging.getLogger(__name__) diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py b/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py index 6f4a9cf7f..0969eab3b 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/ssh_client.py @@ -24,7 +24,7 @@ DEFAULT_CONNECT_RETRY_COUNT = 10 DEFAULT_SEND_TIMEOUT = 10 -class SshClient(object): # pylint: disable=too-many-instance-attributes +class SshClient(): # pylint: disable=too-many-instance-attributes """ssh client class for vrouter testing""" logger = logging.getLogger(__name__) @@ -80,7 +80,7 @@ class SshClient(object): # pylint: disable=too-many-instance-attributes retrycount -= 1 if retrycount == 0: - self.logger.warn( + self.logger.warning( "Cannot establish connection to IP '%s'", self.ip_address) self.connected = False return self.connected diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py b/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py index a73855421..b159ddda4 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/vm_controller.py @@ -23,7 +23,7 @@ from functest.opnfv_tests.vnf.router.vnf_controller.ssh_client import ( SshClient) -class VmController(object): +class VmController(): """vm controll class""" logger = logging.getLogger(__name__) diff --git a/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py b/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py index a5b1ad856..7ed287c6e 100644 --- a/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py +++ b/functest/opnfv_tests/vnf/router/vnf_controller/vnf_controller.py @@ -26,7 +26,7 @@ from functest.opnfv_tests.vnf.router.vnf_controller.vm_controller import ( VmController) -class VnfController(object): +class VnfController(): """vrouter controll class""" logger = logging.getLogger(__name__) diff --git a/functest/opnfv_tests/vnf/router/vrouter_base.py b/functest/opnfv_tests/vnf/router/vrouter_base.py index 8cfab341e..932770b9c 100644 --- a/functest/opnfv_tests/vnf/router/vrouter_base.py +++ b/functest/opnfv_tests/vnf/router/vrouter_base.py @@ -24,7 +24,7 @@ from functest.opnfv_tests.vnf.router.test_controller import function_test_exec __author__ = "Shuya Nakama " -class VrouterOnBoardingBase(object): +class VrouterOnBoardingBase(): """vrouter testing base class""" def __init__(self, util, util_info): diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py index 4ec205894..f6a80e264 100644 --- a/functest/tests/unit/utils/test_functest_utils.py +++ b/functest/tests/unit/utils/test_functest_utils.py @@ -82,7 +82,7 @@ class FunctestUtilsTesting(unittest.TestCase): def _get_environ(self, var, *args): # pylint: disable=unused-argument if var == 'INSTALLER_TYPE': return self.installer - elif var == 'DEPLOY_SCENARIO': + if var == 'DEPLOY_SCENARIO': return self.scenario return var @@ -322,7 +322,7 @@ class FunctestUtilsTesting(unittest.TestCase): self.assertEqual( functest_utils.convert_dict_to_ini({"a": "b"}), "a:b") value = functest_utils.convert_dict_to_ini({"a": "b", "c": "d"}) - self.assertTrue(value == "a:b,c:d" or value == "c:d,a:b") + self.assertTrue(value in ('a:b,c:d', 'c:d,a:b')) with self.assertRaises(AssertionError): functest_utils.convert_list_to_ini("") diff --git a/functest/utils/config.py b/functest/utils/config.py index 61d8401c5..c2897d361 100644 --- a/functest/utils/config.py +++ b/functest/utils/config.py @@ -10,7 +10,7 @@ import six from functest.utils import env -class Config(object): +class Config(): def __init__(self): try: # pylint: disable=bad-continuation diff --git a/tox.ini b/tox.ini index f63a1e0c9..fc2f043df 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ commands = nosetests --with-xunit \ functest/tests/unit [testenv:docs] -basepython = python2.7 +basepython = python3.6 commands = doc8 \ --ignore-path api/build \ @@ -32,18 +32,18 @@ commands = sphinx-build -W -n -b html -c docs/lfreleng docs docs/_build/html [testenv:pep8] -basepython = python2.7 +basepython = python3.6 commands = flake8 [testenv:pylint] -basepython = python2.7 +basepython = python3.6 commands = pylint \ --ignore-imports=y --min-similarity-lines=10 \ --disable=locally-disabled functest [testenv:yamllint] -basepython = python2.7 +basepython = python3.6 files = .travis.yml docker @@ -57,7 +57,7 @@ commands = yamllint -s {[testenv:yamllint]files} [testenv:ansiblelint] -basepython = python2.7 +basepython = python3.6 commands = ansible-lint ansible/site.yml @@ -65,7 +65,7 @@ commands = commands = nosetests functest/tests/unit [testenv:bashate] -basepython = python2.7 +basepython = python3.6 files = functest/opnfv_tests/openstack/cinder/write_data.sh functest/opnfv_tests/openstack/cinder/read_data.sh @@ -77,11 +77,11 @@ commands = bashate -e E005,E006,E042,E043 {[testenv:bashate]files} [testenv:bandit] -basepython = python2.7 +basepython = python3.6 commands = bandit -r functest -x tests -n 5 -ll -s B601,B602 [testenv:cover] -basepython = python2.7 +basepython = python3.6 dirs = functest/tests/unit/odl functest/tests/unit/openstack/vping @@ -94,7 +94,7 @@ commands = nosetests --with-coverage --cover-tests \ --cover-min-percentage 100 {[testenv:cover]dirs} [testenv:perm] -basepython = python2.7 +basepython = python3.6 whitelist_externals = bash path=. -not -path './.tox/*' -not -path './.git/*' -not -path './docs/com/pres/reveal.js/*' commands = diff --git a/upper-constraints.txt b/upper-constraints.txt index 3e18c7a0d..9d2cd0837 100644 --- a/upper-constraints.txt +++ b/upper-constraints.txt @@ -9,7 +9,7 @@ git+https://gerrit.opnfv.org/gerrit/clover#egg=clover git+https://gerrit.opnfv.org/gerrit/parser#egg=nfv-heattranslator&subdirectory=tosca2heat/heat-translator git+https://gerrit.opnfv.org/gerrit/parser#egg=nfv-toscaparser&subdirectory=tosca2heat/tosca-parser -e git+https://gerrit.opnfv.org/gerrit/parser#egg=nfv-parser -cloudify-rest-client===4.3.3 +git+https://github.com/collivier/cloudify-rest-client.git@4.3.3-py3#egg=cloudify-rest-client robotframework===3.0.2 robotframework-httplibrary===0.4.2 robotframework-requests===0.4.7 -- cgit 1.2.3-korg