Stop testing python 2

Since it's no longer supported past Train, lets stop
running the tests.

Updated docs and made some pep8 code tweaks as well.

Change-Id: I1c171ab906a3b4c66558163ad26947ebf710a276
This commit is contained in:
Brian Haley 2019-10-04 16:14:37 -04:00 committed by Brian Haley
parent 8acf9ea32b
commit 6842465260
17 changed files with 23 additions and 98 deletions

View File

@ -7,7 +7,6 @@
- neutron-tempest-plugin-jobs
- openstack-cover-jobs
- openstack-lower-constraints-jobs
- openstack-python-jobs
- openstack-python3-ussuri-jobs
- publish-openstack-docs-pti
- periodic-stable-jobs
@ -17,8 +16,6 @@
check:
jobs:
- neutron-functional
# TODO(ralonsoh): until the bug 1848944 is fixed or PY2 removed
#- neutron-functional-python27:
- neutron-fullstack
- neutron-rally-task
- neutron-tempest-dvr
@ -68,8 +65,6 @@
gate:
jobs:
- neutron-functional
# TODO(ralonsoh): until the bug 1848944 is fixed or PY2 removed
#- neutron-functional-python27:
- neutron-fullstack
- neutron-tempest-dvr
- neutron-tempest-linuxbridge
@ -139,15 +134,6 @@
# tox.ini file
'{{ devstack_base_dir }}/logs/dsvm-functional-logs': logs
- job:
name: neutron-functional-python27
parent: neutron-functional
description: Run neutron functional tests with Python 2.7
vars:
devstack_localrc:
USE_PYTHON3: false
tox_envlist: dsvm-functional-python27
- job:
name: neutron-fullstack
parent: neutron-functional

View File

@ -132,7 +132,7 @@ __ file-based-sqlite_
.. code-block:: shell
$ OS_TEST_DBAPI_ADMIN_CONNECTION=sqlite:///sqlite.db .tox/py27/bin/python -m \
$ OS_TEST_DBAPI_ADMIN_CONNECTION=sqlite:///sqlite.db .tox/py37/bin/python -m \
testtools.run neutron.tests.unit...
...
(Pdb) self.engine.url
@ -507,7 +507,7 @@ To restrict the pylint check to only the files altered by the latest patch chang
To run only the unit tests::
tox -e py27
tox -e py37
Many changes span across both the neutron and neutron-lib repos, and tox
will always build the test environment using the published module versions
@ -520,7 +520,7 @@ For example, to run against the 'master' branch of neutron-lib::
cd $SRC
git clone https://opendev.org/openstack/neutron-lib
cd $NEUTRON_DIR
env TOX_ENV_SRC_MODULES=$SRC/neutron-lib tox -r -e pep8,py27
env TOX_ENV_SRC_MODULES=$SRC/neutron-lib tox -r -e pep8,py37
To run against a change of your own, repeat the same steps, but use the
directory with your changes, not a fresh clone.
@ -533,7 +533,7 @@ desired gerrit refs for this example)::
cd neutron-lib
git fetch https://opendev.org/openstack/neutron-lib refs/changes/13/635313/6 && git checkout FETCH_HEAD
cd $NEUTRON_DIR
env TOX_ENV_SRC_MODULES=$SRC/neutron-lib tox -r -e pep8,py27
env TOX_ENV_SRC_MODULES=$SRC/neutron-lib tox -r -e pep8,py37
Note that the '-r' is needed to re-create the tox virtual envs, and will also
be needed to restore them to standard when not using this method.
@ -542,7 +542,7 @@ Any pip installable package can be overriden with this environment variable,
not just neutron-lib. To specify multiple packages to override, specify them
as a space separated list to TOX_ENV_SRC_MODULES. Example::
env TOX_ENV_SRC_MODULES="$SRC/neutron-lib $SRC/oslo.db" tox -r -e pep8,py27
env TOX_ENV_SRC_MODULES="$SRC/neutron-lib $SRC/oslo.db" tox -r -e pep8,py37
Functional Tests
~~~~~~~~~~~~~~~~
@ -664,13 +664,13 @@ the dot-separated path you want as an argument to it.
For example, the following would run only a single test or test case::
$ tox -e py27 neutron.tests.unit.test_manager
$ tox -e py27 neutron.tests.unit.test_manager.NeutronManagerTestCase
$ tox -e py27 neutron.tests.unit.test_manager.NeutronManagerTestCase.test_service_plugin_is_loaded
$ tox -e py37 neutron.tests.unit.test_manager
$ tox -e py37 neutron.tests.unit.test_manager.NeutronManagerTestCase
$ tox -e py37 neutron.tests.unit.test_manager.NeutronManagerTestCase.test_service_plugin_is_loaded
If you want to pass other arguments to stestr, you can do the following::
$ tox -e py27 -- neutron.tests.unit.test_manager --serial
$ tox -e py37 -- neutron.tests.unit.test_manager --serial
Coverage

View File

@ -10,7 +10,6 @@ libffi-devel [platform:rpm]
# MySQL and PostgreSQL databases since some jobs are set up in
# OpenStack infra that need these like
# periodic-neutron-py27-with-oslo-master and
# periodic-neutron-py35-with-neutron-lib-master.
haproxy
libmysqlclient-dev [platform:dpkg test]

View File

@ -229,8 +229,8 @@ Create and activate the virtualenv
From the root of the neutron (or sub-project) repo directory, run::
tox --notest -r -e py27
source .tox/py27/bin/activate
tox --notest -r -e py37
source .tox/py37/bin/activate
Now you can use the ``test-db-manage`` alias in place of ``neutron-db-manage``
in the script auto-generation instructions below.

View File

@ -315,7 +315,7 @@ be the bare minimum you have to complete in order to get you off the ground.
<http://docs.openstack.org/infra/manual/creators.html#update-the-gerrit-group-members>`_.
* Fix, fix, fix: at this point you have an external base to work on. You can
develop against the new opendev.org project, the same way you work with
any other OpenStack project: you have pep8, docs, and python27 CI jobs that
any other OpenStack project: you have pep8, docs, and python CI jobs that
validate your patches when posted to Gerrit. For instance, one thing you
would need to do is to define an entry point for your plugin or driver in
your own setup.cfg similarly as to how it is done in the `setup.cfg for ODL

View File

@ -65,7 +65,6 @@ keepalived_state_change: CommandFilter, neutron-keepalived-state-change, root
# TODO(mlavalle) These kill filters will be updated once we come up with a
# mechanism to kill using the name of the script being executed by Python
kill_keepalived_monitor_py: KillFilter, root, python, -15
kill_keepalived_monitor_py27: KillFilter, root, python2.7, -15
kill_keepalived_monitor_py3: KillFilter, root, python3, -15
kill_keepalived_monitor_py35: KillFilter, root, python3.5, -15
kill_keepalived_monitor_py36: KillFilter, root, python3.6, -15

View File

@ -147,7 +147,6 @@ traceback2==1.4.0
unittest2==1.1.0
vine==1.1.4
waitress==1.1.0
weakrefmethod==1.0.2
WebOb==1.8.2
WebTest==2.0.27
wrapt==1.7.0

View File

@ -22,8 +22,6 @@ from neutron_lib.agent import topics
from neutron_lib import constants
from neutron_lib import context
from oslo_utils import timeutils
import six
import testtools
import neutron
from neutron.agent.common import ovs_lib
@ -207,14 +205,6 @@ def register_sriovnicswitch_agent(host=HOST,
return _register_agent(agent, plugin)
def requires_py2(testcase):
return testtools.skipUnless(six.PY2, "requires python 2.x")(testcase)
def requires_py3(testcase):
return testtools.skipUnless(six.PY3, "requires python 3.x")(testcase)
def get_not_used_vlan(bridge, vlan_range):
port_vlans = bridge.ovsdb.db_find(
'Port', ('tag', '!=', []), columns=['tag']).execute()

View File

@ -733,7 +733,7 @@ class IpMonitorTestCase(testscenarios.WithScenarios,
if ip_address not in registers:
return False
return True
except (OSError, IOError) as e:
except (OSError, IOError):
return False
def _check_read_file(self, ip_addresses):

View File

@ -27,7 +27,6 @@ import oslo_i18n
from neutron.agent.linux import utils
from neutron.tests import base
from neutron.tests.common import helpers
_marker = object()
@ -173,7 +172,6 @@ class AgentUtilsExecuteTest(base.BaseTestCase):
result = utils.execute(['ls', self.test_file], return_stderr=True)
self.assertEqual((str_data, ''), result)
@helpers.requires_py3
def test_surrogateescape_in_decoding_out_data(self):
bytes_err_data = b'\xed\xa0\xbd'
err_data = bytes_err_data.decode('utf-8', 'surrogateescape')

View File

@ -544,13 +544,13 @@ class TimerTestCase(base.BaseTestCase):
def test__getattr(self):
with utils.Timer() as timer:
time.sleep(1)
self.assertEqual(1, round(timer.total_seconds(), 0))
self.assertEqual(1.0, round(timer.total_seconds(), 0))
self.assertEqual(1, timer.delta.seconds)
def test__enter_with_timeout(self):
with utils.Timer(timeout=10) as timer:
time.sleep(1)
self.assertEqual(1, round(timer.total_seconds(), 0))
self.assertEqual(1.0, round(timer.total_seconds(), 0))
def test__enter_with_timeout_exception(self):
msg = r'Timer timeout expired after 1 second\(s\).'

View File

@ -28,7 +28,6 @@ import webob.exc
from neutron.common import ipv6_utils
from neutron.tests import base
from neutron.tests.common import helpers
from neutron import wsgi
CONF = cfg.CONF
@ -520,18 +519,6 @@ class JSONDictSerializerTest(base.BaseTestCase):
self.assertEqual(expected_json, result)
# The tested behaviour is only meant to be witnessed in Python 2, so it is
# OK to skip this test with Python 3.
@helpers.requires_py2
def test_json_with_utf8(self):
input_dict = dict(servers=dict(a=(2, '\xe7\xbd\x91\xe7\xbb\x9c')))
expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}'
serializer = wsgi.JSONDictSerializer()
result = serializer.serialize(input_dict)
result = result.replace(b'\n', b'').replace(b' ', b'')
self.assertEqual(expected_json, result)
def test_json_with_unicode(self):
input_dict = dict(servers=dict(a=(2, u'\u7f51\u7edc')))
expected_json = b'{"servers":{"a":[2,"\\u7f51\\u7edc"]}}'

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
Python 2.7 support has been dropped. The minimum version of Python now
supported by Neutron is Python 3.6.

View File

@ -49,7 +49,6 @@ ovs>=2.8.0 # Apache-2.0
ovsdbapp>=0.9.1 # Apache-2.0
psutil>=3.2.2 # BSD
pyroute2>=0.5.3;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
weakrefmethod>=1.0.2;python_version=='2.7' # PSF
python-novaclient>=9.1.0 # Apache-2.0
openstacksdk>=0.31.2 # Apache-2.0

View File

@ -13,8 +13,6 @@ classifier =
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
@ -266,6 +264,3 @@ domain = neutron neutron-log-error neutron-log-info neutron-log-warning
domain = neutron
output_dir = neutron/locale
input_file = neutron/locale/neutron.pot
[wheel]
universal = 1

View File

@ -6,7 +6,7 @@
# Why, you ask? Because you made changes to neutron-lib, and you want
# run the unit tests together. E.g.:
#
# env TOX_ENV_SRC_MODULES="$HOME/src/neutron-lib" tox -e py27
# env TOX_ENV_SRC_MODULES="$HOME/src/neutron-lib" tox -e py37
toxinidir="$1"

36
tox.ini
View File

@ -1,9 +1,10 @@
[tox]
envlist = docs,py27,py37,pep8
envlist = docs,py37,pep8
minversion = 2.3.2
skipsdist = True
[testenv]
basepython = python3
setenv = VIRTUAL_ENV={envdir}
OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
@ -26,18 +27,15 @@ commands =
# mode. To do this define the TRACE_FAILONLY environmental variable.
[testenv:debug]
basepython = python3
envdir = {toxworkdir}/shared
commands = oslo_debug_helper -t neutron/tests {posargs}
[testenv:common]
basepython = python3
# Fake job to define environment variables shared between dsvm/non-dsvm jobs
setenv = OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:180}
commands = false
[testenv:dsvm]
basepython = python3
# Fake job to define environment variables shared between dsvm jobs
setenv = OS_SUDO_TESTING=1
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
@ -47,7 +45,6 @@ setenv = OS_SUDO_TESTING=1
commands = false
[testenv:functional]
basepython = python3
setenv = {[testenv]setenv}
{[testenv:common]setenv}
OS_TEST_PATH=./neutron/tests/functional
@ -59,14 +56,7 @@ deps =
{[testenv]deps}
-r{toxinidir}/neutron/tests/functional/requirements.txt
[testenv:functional-python27]
basepython = python2.7
setenv = {[testenv:functional]setenv}
deps =
{[testenv:functional]deps}
[testenv:dsvm-functional]
basepython = python3
setenv = {[testenv:functional]setenv}
{[testenv:dsvm]setenv}
deps =
@ -75,16 +65,7 @@ commands =
{toxinidir}/tools/deploy_rootwrap.sh {toxinidir} {envdir}/etc {envdir}/bin
stestr run {posargs}
[testenv:dsvm-functional-python27]
basepython = python2.7
setenv = {[testenv:dsvm-functional]setenv}
deps =
{[testenv:dsvm-functional]deps}
commands =
{[testenv:dsvm-functional]commands}
[testenv:dsvm-fullstack]
basepython = python3
setenv = {[testenv]setenv}
{[testenv:common]setenv}
{[testenv:dsvm]setenv}
@ -99,13 +80,11 @@ commands =
stestr run --concurrency 4 {posargs}
[testenv:releasenotes]
basepython = python3
envdir = {toxworkdir}/docs
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:pep8]
basepython = python3
envdir = {toxworkdir}/shared
deps =
{[testenv]deps}
@ -127,7 +106,6 @@ whitelist_externals =
bash
[testenv:cover]
basepython = python3
envdir = {toxworkdir}/shared
setenv =
{[testenv]setenv}
@ -140,17 +118,14 @@ commands =
coverage xml -o cover/coverage.xml
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:docs]
basepython = python3
envdir = {toxworkdir}/docs
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b html doc/source doc/build/html
[testenv:pdf-docs]
basepython = python3
envdir = {toxworkdir}/docs
deps = {[testenv:docs]deps}
whitelist_externals =
@ -160,7 +135,6 @@ commands =
make -C doc/build/pdf
[testenv:linkcheck]
basepython = python3
envdir = {toxworkdir}/docs
deps = -r{toxinidir}/doc/requirements.txt
commands = sphinx-build -W -b linkcheck doc/source doc/build/linkcheck
@ -189,7 +163,6 @@ import_exceptions = neutron._i18n
local-check-factory = neutron.hacking.checks.factory
[testenv:bandit]
basepython = python3
envdir = {toxworkdir}/shared
# B104: Possible binding to all interfaces
# B303: blacklist calls: md5, sha1
@ -199,7 +172,6 @@ deps = -r{toxinidir}/test-requirements.txt
commands = bandit -r neutron -x tests -n5 -s B104,B303,B311,B604
[testenv:bashate]
basepython = python3
envdir = {toxworkdir}/shared
commands = bash -c "find {toxinidir} \
-not \( -type d -name .tox\* -prune \) \
@ -213,19 +185,16 @@ commands = bash -c "find {toxinidir} \
-print0 | xargs -0 bashate -v -iE006 -eE005,E042,E043"
[testenv:genconfig]
basepython = python3
envdir = {toxworkdir}/shared
commands = {toxinidir}/tools/generate_config_file_samples.sh
[testenv:genpolicy]
basepython = python3
envdir = {toxworkdir}/shared
commands = oslopolicy-sample-generator --config-file=etc/oslo-policy-generator/policy.conf
# This environment can be used to quickly validate that all needed system
# packages required to successfully execute test targets are installed
[testenv:bindep]
basepython = python3
# Do not install any requirements. We want this to be fast and work even if
# system dependencies are missing, since it's used to tell you what system
# dependencies are missing! This also means that bindep must be installed
@ -234,7 +203,6 @@ deps = bindep
commands = bindep test
[testenv:lower-constraints]
basepython = python3
setenv = OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:60}
deps =
-c{toxinidir}/lower-constraints.txt