From 9359366d93316afb8e774f69fbdb5832934e1607 Mon Sep 17 00:00:00 2001 From: Bernard Cafarelli Date: Fri, 22 Jun 2018 11:58:07 +0200 Subject: [PATCH] Switch default functional tests to python3, add job for python2 As a part of the python 3 community goal, this converts the functional tests to run with python3 by default, and in Zuul. As discussed at the Stein PTG in Denver, unit and functional tests will still run on both versions, so this adds a python2 job for functional tests. This patch also suppress logging levels from some external libraries to avoid issues with subunit.parser and python 3. For details see bug reported for Cinder [1]. [1] https://bugs.launchpad.net/cinder/+bug/1728640 Co-Authored-By: Slawek Kaplonski Change-Id: I8958d0b5b9147ffd1ef2d1cef5dcbf79c8be5cd4 --- .zuul.yaml | 21 ++++++------------- neutron/tests/base.py | 12 +++++++++++ neutron/tests/contrib/gate_hook.sh | 2 +- .../post.yaml | 0 .../run.yaml | 6 +++--- playbooks/legacy/neutron-functional/run.yaml | 1 + tox.ini | 15 +++++++------ 7 files changed, 30 insertions(+), 27 deletions(-) rename playbooks/legacy/{neutron-functional-python35 => neutron-functional-python27}/post.yaml (100%) rename playbooks/legacy/{neutron-functional-python35 => neutron-functional-python27}/run.yaml (89%) diff --git a/.zuul.yaml b/.zuul.yaml index 951ec0773a2..d2b2b8147b1 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -15,6 +15,7 @@ check: jobs: - neutron-functional + - neutron-functional-python27 - neutron-fullstack - neutron-rally-task - neutron-tempest-dvr @@ -57,6 +58,7 @@ gate: jobs: - neutron-functional + - neutron-functional-python27 - neutron-fullstack - neutron-tempest-dvr - neutron-tempest-linuxbridge @@ -79,7 +81,6 @@ - neutron-tempest-with-os-ken-master experimental: jobs: - - neutron-functional-python35 - neutron-functional-with-uwsgi - neutron-fullstack-with-uwsgi - neutron-tempest-with-uwsgi @@ -112,20 +113,10 @@ - ^releasenotes/.*$ - job: - name: neutron-functional-python35 - parent: legacy-dsvm-base - run: playbooks/legacy/neutron-functional-python35/run.yaml - post-run: playbooks/legacy/neutron-functional-python35/post.yaml - timeout: 7800 - required-projects: - - openstack-infra/devstack-gate - - openstack/neutron - irrelevant-files: - - ^.*\.rst$ - - ^doc/.*$ - - ^neutron/locale/.*$ - - ^releasenotes/.*$ - voting: false + name: neutron-functional-python27 + parent: neutron-functional + run: playbooks/legacy/neutron-functional-python27/run.yaml + post-run: playbooks/legacy/neutron-functional-python27/post.yaml - job: name: neutron-fullstack diff --git a/neutron/tests/base.py b/neutron/tests/base.py index e1d80ce71b9..a45f78b08e8 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -20,6 +20,7 @@ import abc import contextlib import functools import inspect +import logging import os import os.path @@ -180,6 +181,17 @@ class DietTestCase(base.BaseTestCase): def setUp(self): super(DietTestCase, self).setUp() + # Suppress some log messages during test runs, otherwise it may cause + # issues with subunit parser when running on Python 3. It happened for + # example for neutron-functional tests. + # With this suppress of log levels DEBUG logs will not be captured by + # stestr on pythonlogging stream and will not cause this parser issue. + supress_logs = ['neutron', 'neutron_lib', 'stevedore', 'oslo_policy', + 'oslo_concurrency', 'oslo_db', 'alembic', 'ovsdbapp'] + for supress_log in supress_logs: + logger = logging.getLogger(supress_log) + logger.setLevel(logging.ERROR) + # FIXME(amuller): this must be called in the Neutron unit tests base # class. Moving this may cause non-deterministic failures. Bug #1489098 # for more info. diff --git a/neutron/tests/contrib/gate_hook.sh b/neutron/tests/contrib/gate_hook.sh index 78d1a730326..38e967c0c29 100644 --- a/neutron/tests/contrib/gate_hook.sh +++ b/neutron/tests/contrib/gate_hook.sh @@ -55,7 +55,7 @@ function load_rc_for_rally { case $VENV in -"dsvm-functional"|"dsvm-fullstack"|"dsvm-functional-python35") +"dsvm-functional"|"dsvm-functional-python27"|"dsvm-fullstack") # The following need to be set before sourcing # configure_for_func_testing. GATE_STACK_USER=stack diff --git a/playbooks/legacy/neutron-functional-python35/post.yaml b/playbooks/legacy/neutron-functional-python27/post.yaml similarity index 100% rename from playbooks/legacy/neutron-functional-python35/post.yaml rename to playbooks/legacy/neutron-functional-python27/post.yaml diff --git a/playbooks/legacy/neutron-functional-python35/run.yaml b/playbooks/legacy/neutron-functional-python27/run.yaml similarity index 89% rename from playbooks/legacy/neutron-functional-python35/run.yaml rename to playbooks/legacy/neutron-functional-python27/run.yaml index 062c19c51d7..538a66a8909 100644 --- a/playbooks/legacy/neutron-functional-python35/run.yaml +++ b/playbooks/legacy/neutron-functional-python27/run.yaml @@ -1,5 +1,5 @@ - hosts: all - name: Neutron functional test suite running with Python 3.5 + name: Autoconverted job legacy-neutron-dsvm-functional from old job gate-neutron-dsvm-functional-ubuntu-xenial-nv tasks: - name: Ensure legacy workspace directory @@ -38,12 +38,12 @@ fi function gate_hook { - bash -xe $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh dsvm-functional-python35 + bash -xe $BASE/new/neutron/neutron/tests/contrib/gate_hook.sh dsvm-functional-python27 } export -f gate_hook function post_test_hook { - bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-functional-python35 + bash -xe $BASE/new/neutron/neutron/tests/contrib/post_test_hook.sh dsvm-functional-python27 } export -f post_test_hook diff --git a/playbooks/legacy/neutron-functional/run.yaml b/playbooks/legacy/neutron-functional/run.yaml index 1ebd4ca9d1e..397178ca01d 100644 --- a/playbooks/legacy/neutron-functional/run.yaml +++ b/playbooks/legacy/neutron-functional/run.yaml @@ -27,6 +27,7 @@ cmd: | set -e set -x + export USE_PYTHON3=true export PYTHONUNBUFFERED=true export DEVSTACK_GATE_TEMPEST=0 export DEVSTACK_GATE_EXERCISES=0 diff --git a/tox.ini b/tox.ini index 932ee32d130..d08f380c232 100644 --- a/tox.ini +++ b/tox.ini @@ -44,7 +44,7 @@ setenv = OS_SUDO_TESTING=1 commands = false [testenv:functional] -basepython = python2.7 +basepython = python3 setenv = {[testenv]setenv} {[testenv:common]setenv} OS_TEST_PATH=./neutron/tests/functional @@ -56,14 +56,14 @@ deps = {[testenv]deps} -r{toxinidir}/neutron/tests/functional/requirements.txt -[testenv:functional-python35] -basepython = python3.5 +[testenv:functional-python27] +basepython = python2.7 setenv = {[testenv:functional]setenv} deps = {[testenv:functional]deps} [testenv:dsvm-functional] -basepython = python2.7 +basepython = python3 setenv = {[testenv:functional]setenv} {[testenv:dsvm]setenv} deps = @@ -72,14 +72,13 @@ commands = {toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin stestr run {posargs} -[testenv:dsvm-functional-python35] -basepython = python3.5 +[testenv:dsvm-functional-python27] +basepython = python2.7 setenv = {[testenv:dsvm-functional]setenv} deps = {[testenv:dsvm-functional]deps} commands = - {toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin - stestr run {posargs} + {[testenv:dsvm-functional]commands} [testenv:dsvm-fullstack] basepython = python3