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: check:
jobs: jobs:
- neutron-functional - neutron-functional
- neutron-functional-python27
- neutron-fullstack - neutron-fullstack
- neutron-rally-task - neutron-rally-task
- neutron-tempest-dvr - neutron-tempest-dvr
@ -57,6 +58,7 @@
gate: gate:
jobs: jobs:
- neutron-functional - neutron-functional
- neutron-functional-python27
- neutron-fullstack - neutron-fullstack
- neutron-tempest-dvr - neutron-tempest-dvr
- neutron-tempest-linuxbridge - neutron-tempest-linuxbridge
@ -79,7 +81,6 @@
- neutron-tempest-with-os-ken-master - neutron-tempest-with-os-ken-master
experimental: experimental:
jobs: jobs:
- neutron-functional-python35
- neutron-functional-with-uwsgi - neutron-functional-with-uwsgi
- neutron-fullstack-with-uwsgi - neutron-fullstack-with-uwsgi
- neutron-tempest-with-uwsgi - neutron-tempest-with-uwsgi
@ -112,20 +113,10 @@
- ^releasenotes/.*$ - ^releasenotes/.*$
- job: - job:
name: neutron-functional-python35 name: neutron-functional-python27
parent: legacy-dsvm-base parent: neutron-functional
run: playbooks/legacy/neutron-functional-python35/run.yaml run: playbooks/legacy/neutron-functional-python27/run.yaml
post-run: playbooks/legacy/neutron-functional-python35/post.yaml post-run: playbooks/legacy/neutron-functional-python27/post.yaml
timeout: 7800
required-projects:
- openstack-infra/devstack-gate
- openstack/neutron
irrelevant-files:
- ^.*\.rst$
- ^doc/.*$
- ^neutron/locale/.*$
- ^releasenotes/.*$
voting: false
- job: - job:
name: neutron-fullstack name: neutron-fullstack

View File

@ -20,6 +20,7 @@ import abc
import contextlib import contextlib
import functools import functools
import inspect import inspect
import logging
import os import os
import os.path import os.path
@ -180,6 +181,17 @@ class DietTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(DietTestCase, self).setUp() 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 # FIXME(amuller): this must be called in the Neutron unit tests base
# class. Moving this may cause non-deterministic failures. Bug #1489098 # class. Moving this may cause non-deterministic failures. Bug #1489098
# for more info. # for more info.

View File

@ -55,7 +55,7 @@ function load_rc_for_rally {
case $VENV in 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 # The following need to be set before sourcing
# configure_for_func_testing. # configure_for_func_testing.
GATE_STACK_USER=stack GATE_STACK_USER=stack

View File

@ -1,5 +1,5 @@
- hosts: all - 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: tasks:
- name: Ensure legacy workspace directory - name: Ensure legacy workspace directory
@ -38,12 +38,12 @@
fi fi
function gate_hook { 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 export -f gate_hook
function post_test_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 export -f post_test_hook

View File

@ -27,6 +27,7 @@
cmd: | cmd: |
set -e set -e
set -x set -x
export USE_PYTHON3=true
export PYTHONUNBUFFERED=true export PYTHONUNBUFFERED=true
export DEVSTACK_GATE_TEMPEST=0 export DEVSTACK_GATE_TEMPEST=0
export DEVSTACK_GATE_EXERCISES=0 export DEVSTACK_GATE_EXERCISES=0

15
tox.ini
View File

@ -44,7 +44,7 @@ setenv = OS_SUDO_TESTING=1
commands = false commands = false
[testenv:functional] [testenv:functional]
basepython = python2.7 basepython = python3
setenv = {[testenv]setenv} setenv = {[testenv]setenv}
{[testenv:common]setenv} {[testenv:common]setenv}
OS_TEST_PATH=./neutron/tests/functional OS_TEST_PATH=./neutron/tests/functional
@ -56,14 +56,14 @@ deps =
{[testenv]deps} {[testenv]deps}
-r{toxinidir}/neutron/tests/functional/requirements.txt -r{toxinidir}/neutron/tests/functional/requirements.txt
[testenv:functional-python35] [testenv:functional-python27]
basepython = python3.5 basepython = python2.7
setenv = {[testenv:functional]setenv} setenv = {[testenv:functional]setenv}
deps = deps =
{[testenv:functional]deps} {[testenv:functional]deps}
[testenv:dsvm-functional] [testenv:dsvm-functional]
basepython = python2.7 basepython = python3
setenv = {[testenv:functional]setenv} setenv = {[testenv:functional]setenv}
{[testenv:dsvm]setenv} {[testenv:dsvm]setenv}
deps = deps =
@ -72,14 +72,13 @@ commands =
{toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin {toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin
stestr run {posargs} stestr run {posargs}
[testenv:dsvm-functional-python35] [testenv:dsvm-functional-python27]
basepython = python3.5 basepython = python2.7
setenv = {[testenv:dsvm-functional]setenv} setenv = {[testenv:dsvm-functional]setenv}
deps = deps =
{[testenv:dsvm-functional]deps} {[testenv:dsvm-functional]deps}
commands = commands =
{toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin {[testenv:dsvm-functional]commands}
stestr run {posargs}
[testenv:dsvm-fullstack] [testenv:dsvm-fullstack]
basepython = python3 basepython = python3