Adapt to recent dependencies

This covers the following updates to fix CI currently broken.

* Fix compatibility with tox 4
* Update hacking to 6.1.0
* Clean up python 2 support and bump minimum supported version to 3.8
* Remove six because python 2 support is removed
* Update job template to use the recent tested python versions
* Replace items by prefixItems to fix schema error

Change-Id: I3b9c5b20aca55332c721d34fd4c41c5b886f60c5
This commit is contained in:
Takashi Kajinami 2024-03-30 15:33:04 +09:00
parent 113ba244f8
commit 636d8c7236
29 changed files with 67 additions and 84 deletions

View File

@ -1,9 +1,7 @@
- project:
templates:
- docs-on-readthedocs
- openstack-python-jobs
- openstack-python36-jobs
- openstack-python37-jobs
- openstack-python3-jobs
vars:
rtd_webhook_id: '47124'
check:

View File

@ -16,7 +16,6 @@ import copy
import logging
import jsonschema
import six
from os_faults.api import base_driver
from os_faults.api import error
@ -27,8 +26,7 @@ from os_faults import registry
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class CloudManagement(base_driver.BaseDriver):
class CloudManagement(base_driver.BaseDriver, metaclass=abc.ABCMeta):
SERVICES = {}
CONTAINERS = {}
SUPPORTED_NETWORKS = []

View File

@ -13,14 +13,11 @@
import abc
import six
from os_faults.api import base_driver
from os_faults.api.utils import public
@six.add_metaclass(abc.ABCMeta)
class Container(base_driver.BaseDriver):
class Container(base_driver.BaseDriver, metaclass=abc.ABCMeta):
def __init__(self, container_name, config, node_cls, cloud_management,
hosts=None):

View File

@ -49,6 +49,7 @@ def list_actions(klazz):
klazz,
predicate=utils.is_public))
RANDOMNESS = {'one', 'random', 'some', 'single'}
ANYTHING = {'all'}
NODE_ALIASES_PATTERN = '|'.join(RANDOMNESS | ANYTHING)

View File

@ -110,7 +110,7 @@ class NodeCollection(utils.ReprMixin):
msg = 'Cannot pick {} from {} node(s)'.format(
count, len(self._hosts))
raise error.NodeCollectionError(msg)
return self._make_instance(random.sample(self._hosts, count))
return self._make_instance(random.sample(self.hosts, count))
def filter(self, criteria_fn):
hosts = list(filter(criteria_fn, self._hosts))

View File

@ -13,13 +13,10 @@
import abc
import six
from os_faults.api import base_driver
@six.add_metaclass(abc.ABCMeta)
class NodeDiscover(base_driver.BaseDriver):
class NodeDiscover(base_driver.BaseDriver, metaclass=abc.ABCMeta):
"""Node discover base driver."""
@abc.abstractmethod

View File

@ -13,15 +13,12 @@
import abc
import six
from os_faults.api import base_driver
from os_faults.api import error
from os_faults import utils
@six.add_metaclass(abc.ABCMeta)
class PowerDriver(base_driver.BaseDriver):
class PowerDriver(base_driver.BaseDriver, metaclass=abc.ABCMeta):
@abc.abstractmethod
def supports(self, host):

View File

@ -13,14 +13,11 @@
import abc
import six
from os_faults.api import base_driver
from os_faults.api.utils import public
@six.add_metaclass(abc.ABCMeta)
class Service(base_driver.BaseDriver):
class Service(base_driver.BaseDriver, metaclass=abc.ABCMeta):
def __init__(self, service_name, config, node_cls, cloud_management,
hosts=None):

View File

@ -31,6 +31,7 @@ def describe_actions(klazz):
return ['%s - %s' % (m[0], m[1].__doc__.split('\n')[0])
for m in sorted(methods)]
SERVICE_ACTIONS = describe_actions(service_pkg.Service)
NODE_ACTIONS = describe_actions(node_collection_pkg.NodeCollection)
@ -163,5 +164,6 @@ def main():
command = ' '.join(command)
os_faults.human_api(destructor, command)
if __name__ == '__main__':
main()

View File

@ -14,7 +14,7 @@
PORT_SCHEMA = {
'type': 'array',
'items': [
'prefixItems': [
{'enum': ['tcp', 'udp']},
{'type': 'integer', 'minimum': 0, 'maximum': 65535},
{'enum': ['egress', 'ingress']}

View File

@ -11,8 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import ddt
import mock
from os_faults.ansible import executor
from os_faults.api import node_collection
@ -197,7 +198,7 @@ class AnsibleRunnerTestCase(test.TestCase):
err = self.assertRaises(executor.AnsibleExecutionException,
ex.execute, my_hosts, my_tasks, my_statuses)
self.assertEqual(type(err), executor.AnsibleExecutionUnreachable)
self.assertIsInstance(err, executor.AnsibleExecutionUnreachable)
@mock.patch('os_faults.ansible.executor.find_ansible')
@mock.patch('os_faults.ansible.executor.AnsibleRunner.run_playbook')
@ -218,7 +219,7 @@ class AnsibleRunnerTestCase(test.TestCase):
err = self.assertRaises(executor.AnsibleExecutionException,
ex.execute, my_hosts, my_tasks, my_statuses)
self.assertEqual(type(err), executor.AnsibleExecutionException)
self.assertIsInstance(err, executor.AnsibleExecutionException)
@mock.patch('os_faults.ansible.executor.find_ansible')
@mock.patch('copy.deepcopy')

View File

@ -10,8 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import ddt
import mock
from os_faults.api import error
from os_faults.api import human

View File

@ -12,9 +12,7 @@
# limitations under the License.
import copy
import mock
import six
from unittest import mock
from os_faults.api import cloud_management
from os_faults.api import error
@ -81,7 +79,7 @@ class NodeCollectionTestCase(test.TestCase):
collection._check_nodes_types, self.node_collection)
def test_repr(self):
self.assertIsInstance(repr(self.node_collection), six.string_types)
self.assertIsInstance(repr(self.node_collection), str)
def test_len(self):
self.assertEqual(4, len(self.node_collection))

View File

@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from os_faults.api import error
from os_faults.api import node_collection

View File

@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import mock
from unittest import mock
from os_faults.cmd import cmd
from os_faults.tests.unit import test

View File

@ -12,9 +12,9 @@
# limitations under the License.
import os
from unittest import mock
from click import testing
import mock
from os_faults.api import cloud_management
from os_faults.api import node_collection

View File

@ -11,9 +11,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import copy
import ddt
import mock
from os_faults.api import node_collection
from os_faults.drivers.cloud import devstack

View File

@ -11,8 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import ddt
import mock
from os_faults.ansible import executor
from os_faults.api import node_collection

View File

@ -11,8 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import ddt
import mock
from os_faults.api import error
from os_faults.drivers.cloud import universal

View File

@ -11,8 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import ddt
import mock
from pyghmi import exceptions as pyghmi_exc
import os_faults

View File

@ -11,8 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from unittest import mock
import ddt
import mock
from os_faults.api import node_collection
from os_faults.drivers.power import libvirt

View File

@ -12,8 +12,7 @@
# limitations under the License.
import unittest
import mock
from unittest import mock
from os_faults.api.node_collection import Host
from os_faults.api.node_collection import NodeCollection

View File

@ -10,8 +10,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from unittest import mock
import jsonschema
import mock
import os_faults
from os_faults.ansible import executor

View File

@ -12,8 +12,7 @@
import os
import sys
import mock
from unittest import mock
from os_faults.api import base_driver
from os_faults.api import error

View File

@ -11,8 +11,7 @@
# under the License.
import threading
import mock
from unittest import mock
from os_faults.tests.unit import test
from os_faults import utils
@ -44,7 +43,7 @@ class UtilsTestCase(test.TestCase):
tw.start_thread(target)
tw.join_threads()
self.assertEqual(type(tw.errors[0]), MyException)
self.assertIsInstance(tw.errors[0], MyException)
def test_join_threads(self):
thread_1 = mock.Mock()

View File

@ -8,15 +8,9 @@ appdirs>=1.3.0 # MIT License
click>=6.7 # BSD
iso8601>=0.1.11 # MIT
jsonschema>=2.6.0 # MIT
oslo.concurrency>=3.0.0,<4.0.0;python_version=='2.7' # Apache-2.0
oslo.concurrency>=3.0.0;python_version>='3.6' # Apache-2.0
oslo.i18n>=2.1.0,<4.0.0;python_version=='2.7' # Apache-2.0
oslo.i18n>=2.1.0;python_version>='3.6' # Apache-2.0
oslo.serialization>=1.10.0,<3.0.0;python_version=='2.7' # Apache-2.0
oslo.serialization>=1.10.0;python_version>='3.6' # Apache-2.0
oslo.utils>=3.20.0,<4.0.0;python_version=='2.7' # Apache-2.0
oslo.utils>=3.20.0;python_version>='3.6' # Apache-2.0
pyghmi>=1.0.9,<1.5.0;python_version=='2.7' # Apache-2.0
pyghmi>=1.0.9;python_version>='3.6'
oslo.concurrency>=3.0.0 # Apache-2.0
oslo.i18n>=2.1.0 # Apache-2.0
oslo.serialization>=1.10.0 # Apache-2.0
oslo.utils>=3.20.0 # Apache-2.0
pyghmi>=1.0.9
PyYAML>=3.10.0 # MIT
six>=1.9.0 # MIT

View File

@ -1,17 +1,18 @@
[metadata]
name = os_faults
summary = OpenStack fault-injection library
description-file =
description_file =
README.rst
description-content-type = text/x-rst; charset=UTF-8
description_content_type = text/x-rst; charset=UTF-8
author = OpenStack
author-email = openstack-discuss@lists.openstack.org
author_email = openstack-discuss@lists.openstack.org
url = http://os-faults.readthedocs.io/
download_url = https://pypi.org/project/os-faults/
project_urls =
Bug Tracker = https://bugs.launchpad.net/os-faults
Documentation = http://os-faults.readthedocs.io/
Source Code = https://opendev.org/performa/os-faults/
python_requires = >=3.8
classifier =
Environment :: OpenStack
Intended Audience :: Information Technology
@ -19,11 +20,11 @@ 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
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
[files]
packages =

View File

@ -1,8 +1,4 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=1.1.0,<1.2.0 # Apache-2.0
hacking>=6.1.0,<6.2.0 # Apache-2.0
pytest # MIT
pytest-cov # MIT
pytest-html # Mozilla Public License 2.0 (MPL 2.0)

28
tox.ini
View File

@ -1,35 +1,38 @@
[tox]
minversion = 2.6
envlist = pep8,py27,py36,cover
minversion = 3.18.0
envlist = pep8,py3,cover
skipsdist = True
[testenv]
basepython = python3
usedevelop = True
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt}
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
install_command = pip install -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
whitelist_externals =
allowlist_externals =
find
rm
commands =
find . -type f -name "*.pyc" -delete
py.test -vvvv --html={envlogdir}/pytest_results.html --self-contained-html --durations=10 "os_faults/tests/unit" {posargs}
passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
passenv =
http_proxy
HTTP_PROXY
https_proxy
HTTPS_PROXY
no_proxy
NO_PROXY
[testenv:pep8]
basepython = python3
commands = flake8 . doc/ext
[testenv:venv]
basepython = python3
commands = {posargs}
[testenv:cover]
basepython = python3
commands =
py.test --cov-config .coveragerc --cov-report html --cov=os_faults "os_faults/tests/unit"
coverage html -d {envlogdir}
@ -40,7 +43,6 @@ commands =
# 1) create SSH key in os-faults folder: ssh-keygen -t rsa -f os_faults_key -N ''
# 2) copy public key into authorized_keys of user stack: cat os_faults_key.pub >> ~/.ssh/authorized_keys
# 3) run tests normally: tox -e devstack
basepython = python3
setenv = {[testenv]setenv}
OS_TEST_PATH=./os_faults/tests/devstack
OS_DEBUG=True
@ -50,13 +52,11 @@ commands =
py.test -vvvv --html={envlogdir}/pytest_results.html --self-contained-html --durations=10 "os_faults/tests/devstack" {posargs}
[testenv:docs]
basepython = python3
commands =
rm -rf doc/build
python setup.py build_sphinx --warning-is-error
[testenv:releasenotes]
basepython = python3
commands =
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
@ -64,6 +64,8 @@ commands =
# E123 skipped because it is ignored by default in the default pep8.
# E125 skipped until https://github.com/jcrocholl/pep8/issues/126 is resolved.
# E731 skipped as assign a lambda expression
ignore = E123,E125,E731
# W503 line break before binary operator
# W504 line break after binary operator
ignore = E123,E125,E731,W503,W504
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build