From 684246526092d780cb662910a018f9ececba9452 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Fri, 4 Oct 2019 16:14:37 -0400 Subject: [PATCH] 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 --- .zuul.yaml | 14 -------- TESTING.rst | 18 +++++----- bindep.txt | 1 - doc/source/contributor/alembic_migrations.rst | 4 +-- doc/source/contributor/contribute.rst | 2 +- etc/neutron/rootwrap.d/l3.filters | 1 - lower-constraints.txt | 1 - neutron/tests/common/helpers.py | 10 ------ .../functional/agent/linux/test_ip_lib.py | 2 +- neutron/tests/unit/agent/linux/test_utils.py | 2 -- neutron/tests/unit/common/test_utils.py | 4 +-- neutron/tests/unit/test_wsgi.py | 13 ------- .../drop-python-2-7-9707a901c7d8eab6.yaml | 5 +++ requirements.txt | 1 - setup.cfg | 5 --- tools/pip_install_src_modules.sh | 2 +- tox.ini | 36 ++----------------- 17 files changed, 23 insertions(+), 98 deletions(-) create mode 100644 releasenotes/notes/drop-python-2-7-9707a901c7d8eab6.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 176e1c9ee73..fd836fdfdef 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 diff --git a/TESTING.rst b/TESTING.rst index 62bd47137c7..05bce0749b6 100644 --- a/TESTING.rst +++ b/TESTING.rst @@ -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 diff --git a/bindep.txt b/bindep.txt index aeb6c742422..c52b684efb7 100644 --- a/bindep.txt +++ b/bindep.txt @@ -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] diff --git a/doc/source/contributor/alembic_migrations.rst b/doc/source/contributor/alembic_migrations.rst index 259135d4f18..55db1eaf876 100644 --- a/doc/source/contributor/alembic_migrations.rst +++ b/doc/source/contributor/alembic_migrations.rst @@ -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. diff --git a/doc/source/contributor/contribute.rst b/doc/source/contributor/contribute.rst index 1f067a25371..b45c32273a3 100644 --- a/doc/source/contributor/contribute.rst +++ b/doc/source/contributor/contribute.rst @@ -315,7 +315,7 @@ be the bare minimum you have to complete in order to get you off the ground. `_. * 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 diff --git a/etc/neutron/rootwrap.d/l3.filters b/etc/neutron/rootwrap.d/l3.filters index 317ffbeb83d..301b253469b 100644 --- a/etc/neutron/rootwrap.d/l3.filters +++ b/etc/neutron/rootwrap.d/l3.filters @@ -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 diff --git a/lower-constraints.txt b/lower-constraints.txt index 03b09daea50..55a109a2337 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -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 diff --git a/neutron/tests/common/helpers.py b/neutron/tests/common/helpers.py index 0ee92cea981..cf4b3600cf1 100644 --- a/neutron/tests/common/helpers.py +++ b/neutron/tests/common/helpers.py @@ -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() diff --git a/neutron/tests/functional/agent/linux/test_ip_lib.py b/neutron/tests/functional/agent/linux/test_ip_lib.py index 2bf15ec4fa3..3cc5f80376d 100644 --- a/neutron/tests/functional/agent/linux/test_ip_lib.py +++ b/neutron/tests/functional/agent/linux/test_ip_lib.py @@ -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): diff --git a/neutron/tests/unit/agent/linux/test_utils.py b/neutron/tests/unit/agent/linux/test_utils.py index bb816f0ec39..fb93b17d050 100644 --- a/neutron/tests/unit/agent/linux/test_utils.py +++ b/neutron/tests/unit/agent/linux/test_utils.py @@ -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') diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py index 80461253980..f8b89334998 100644 --- a/neutron/tests/unit/common/test_utils.py +++ b/neutron/tests/unit/common/test_utils.py @@ -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\).' diff --git a/neutron/tests/unit/test_wsgi.py b/neutron/tests/unit/test_wsgi.py index b2214881d74..c26fc7d8882 100644 --- a/neutron/tests/unit/test_wsgi.py +++ b/neutron/tests/unit/test_wsgi.py @@ -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"]}}' diff --git a/releasenotes/notes/drop-python-2-7-9707a901c7d8eab6.yaml b/releasenotes/notes/drop-python-2-7-9707a901c7d8eab6.yaml new file mode 100644 index 00000000000..687c0e7761c --- /dev/null +++ b/releasenotes/notes/drop-python-2-7-9707a901c7d8eab6.yaml @@ -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. diff --git a/requirements.txt b/requirements.txt index 4ba3f71160f..9c34502270a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.cfg b/setup.cfg index 2dbda7f7d72..2dce148b107 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tools/pip_install_src_modules.sh b/tools/pip_install_src_modules.sh index 280b4d85e50..3172f07c1e0 100755 --- a/tools/pip_install_src_modules.sh +++ b/tools/pip_install_src_modules.sh @@ -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" diff --git a/tox.ini b/tox.ini index 42c30c3d44e..2a00d7665d7 100644 --- a/tox.ini +++ b/tox.ini @@ -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