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 <skaplons@redhat.com>

Change-Id: I8958d0b5b9147ffd1ef2d1cef5dcbf79c8be5cd4
This commit is contained in:
Bernard Cafarelli 2018-06-22 11:58:07 +02:00 committed by Slawek Kaplonski
parent 8914f8247f
commit 9359366d93
7 changed files with 30 additions and 27 deletions

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

15
tox.ini
View File

@ -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