Use Python 3 by default and drop Python 2

Follow the rest of OpenStack and consistently switch to
python3 as default python interpreter and drop python2.

The "functional" tox target was failing with Python 2
as cinder/master has cut the Python 2.7 compatibility.
"functional" now points to the default python3. An explicit
"functional-py37" target has been added as well.

Fix the functional jobs as well:
- move the LVM job to centos-8 and adapt it when needed;
- move the Ceph job to ubuntu-bionic, as there are no
  CentOS 8 Ceph packages (and the CentOS 7 ones do not
  provide Python 3 bindings).

Closes-Bug: #1853372
Change-Id: Iea4f4f53df7400248848399494564910d3870f63
This commit is contained in:
Luigi Toscano 2020-01-10 15:03:23 +01:00
parent 2d055fe8a6
commit 08108b5964
9 changed files with 46 additions and 50 deletions

View File

@ -6,7 +6,6 @@
queue: integrated
jobs:
- openstack-tox-pep8
- cinderlib-tox-py27
- cinderlib-tox-py36
- cinderlib-tox-py37
@ -16,7 +15,6 @@
queue: integrated
jobs:
- openstack-tox-pep8
- cinderlib-tox-py27
- cinderlib-tox-py36
- cinderlib-tox-py37
@ -26,13 +24,6 @@
jobs:
- publish-openstack-python-branch-tarball
- job:
name: cinderlib-tox-py27
parent: openstack-tox-py27
required-projects:
- openstack/os-brick
- openstack/cinder
- job:
name: cinderlib-tox-py36
parent: openstack-tox-py36
@ -54,7 +45,7 @@
- openstack/os-brick
- openstack/cinder
pre-run: playbooks/setup-lvm.yaml
nodeset: centos-7
nodeset: centos-8
vars:
tox_environment:
CL_FTEST_MEMORY_PERSISTENCE: "false"
@ -75,7 +66,8 @@
- openstack/os-brick
- openstack/cinder
pre-run: playbooks/setup-ceph.yaml
nodeset: centos-7
# TODO: move back to centos-8 as soon as Ceph packages are available
nodeset: ubuntu-bionic
vars:
tox_environment:
CL_FTEST_CFG: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/cinderlib'].src_dir }}/cinderlib/tests/functional/ceph.yaml"

View File

@ -5,6 +5,9 @@
build-essential [platform:dpkg test]
gcc [platform:rpm test]
python3 [platform:redhat test]
python3-devel [platform:redhat test]
# gettext and graphviz are needed by doc builds only. For transition,
# have them in both doc and test.
# TODO(jaegerandi): Remove test once infra scripts are updated.

View File

@ -1,8 +1,7 @@
openstackdocstheme>=1.20.0 # Apache-2.0
reno>=2.5.0 # Apache-2.0
doc8>=0.6.0 # Apache-2.0
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD
sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2;python_version>='3.4' # BSD
sphinx!=1.6.6,!=1.6.7,!=2.1.0,>=1.6.2 # BSD
os-api-ref>=1.4.0 # Apache-2.0
sphinxcontrib-apidoc>=0.2.0 # BSD
sphinxcontrib-svg2pdfconverter # BSD

View File

@ -297,7 +297,7 @@ provides a custom configuration YAML file with the backend configuration::
- openstack/os-brick
- openstack/cinder
pre-run: playbooks/setup-ceph.yaml
nodeset: centos-7
nodeset: ubuntu-bionic
vars:
tox_environment:
CL_FTEST_CFG: "cinderlib/tests/functional/ceph.yaml"

View File

@ -22,14 +22,6 @@
vars:
ansible_become: yes
tasks:
# Tox job has in its pre.yaml the ensure-tox role, which installs tox
# from pip, which brings six from pip. This conflicts with ceph-common's
# python-six dependency.
- name: Remove pip's six from the system
pip:
name: six
state: absent
# Leave pyparsing, as it's needed by tox through the packaging library.
- name: Remove Python packages unnecessary for cinderlib
pip:
@ -41,14 +33,17 @@
'oslo_upgradecheck', 'googleapiclient', 'pastedeploy']
state: absent
- name: Install ceph-common and epel-release
- name: Install ceph requirements
yum:
name: ['epel-release', 'ceph-common']
name:
- ceph-common
- python3-rados
- python3-rbd
state: present
- name: Install Docker from epel
- name: Install Docker
yum:
name: 'docker'
name: 'docker.io'
state: present
- name: Start Docker

View File

@ -29,11 +29,6 @@
name: lvm2
state: present
- name: Start LVM metadata
service:
name: lvm2-lvmetad
state: started
- name: Create LVM backing file
command: "truncate -s 10G {{vg}}"
args:
@ -59,9 +54,11 @@
- command: "vgscan --cache"
changed_when: false
- name: Install iSCSI package
- name: Install iSCSI packages
package:
name: iscsi-initiator-utils
name:
- iscsi-initiator-utils
- targetcli
state: present
- name: Create initiator name

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
Python 2.7 support has been dropped. OpenStack Train ships the last release
of cinderlib with py2.7 support (1.x). The minimum version of Python now
supported by cinderlib is Python 3.6.

View File

@ -20,8 +20,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

36
tox.ini
View File

@ -1,10 +1,14 @@
[tox]
minversion = 2.0
envlist = py27,py37,pep8
minversion = 3.1
envlist = py37,pep8
skipsdist = True
setenv = VIRTUAL_ENV={envdir}
# this allows tox to infer the base python from the environment name
# and override any basepython configured in this file
ignore_basepython_conflict=true
[testenv]
basepython=python3
setenv = OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
@ -31,7 +35,6 @@ passenv = *_proxy *_PROXY
[testenv:functional]
usedevelop=True
basepython=python2.7
passenv = CL_FTEST_POOL_NAME
setenv = OS_TEST_PATH=./cinderlib/tests/functional
CL_FTEST_CFG={env:CL_FTEST_CFG:{toxinidir}/cinderlib/tests/functional/lvm.yaml}
@ -39,8 +42,8 @@ setenv = OS_TEST_PATH=./cinderlib/tests/functional
ADD_PATHS=/usr/local/sbin:/usr/sbin
sitepackages = True
# Not reusing py27's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/py27
# Not reusing py37's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/py37
# Must run serially or test_stats_with_creation may fail occasionally
commands =
@ -60,22 +63,31 @@ setenv =
{[testenv:functional]setenv}
sitepackages = True
basepython=python3.6
# Not reusing py35's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/py35
# Not reusing py36's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/py36
commands = {[testenv:functional]commands}
whitelist_externals = {[testenv:functional]whitelist_externals}
[testenv:functional-py37]
usedevelop=True
setenv =
{[testenv:functional]setenv}
sitepackages = True
basepython=python3.7
# Not reusing py37's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/py37
commands = {[testenv:functional]commands}
whitelist_externals = {[testenv:functional]whitelist_externals}
[testenv:releasenotes]
# Not reusing doc's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/docs
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
-r{toxinidir}/doc/requirements.txt
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:docs]
basepython = python3
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/doc/requirements.txt
@ -87,7 +99,6 @@ commands =
whitelist_externals = rm
[testenv:pdf-docs]
basepython = python3
deps =
{[testenv:docs]deps}
commands =
@ -107,13 +118,11 @@ whitelist_externals =
# separately, outside of the requirements files, and develop mode disabled
# explicitly to avoid unnecessarily installing the checked-out repo too (this
# further relies on "tox.skipsdist = True" above).
basepython = python3
deps = bindep
commands = bindep {posargs}
usedevelop = False
[testenv:pylint]
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
pylint==2.1.1
@ -123,7 +132,6 @@ commands =
[testenv:cover]
# Also do not run test_coverage_ext tests while gathering coverage as those
# tests conflict with coverage.
basepython = python3
setenv =
{[testenv]setenv}
PYTHON=coverage run --source cinderlib --parallel-mode
@ -134,14 +142,12 @@ commands =
coverage xml -o cover/coverage.xml
[testenv:pep8]
basepython=python3
commands=flake8 {posargs} .
deps=
flake8
-r{toxinidir}/test-requirements.txt
[testenv:fast8]
basepython=python3
# Not reusing Flake8's env due to https://github.com/tox-dev/tox/issues/477
# envdir = {toxworkdir}/flake8
commands={toxinidir}/tools/fast8.sh