From 86d87be8db588cc3125d53cd92e271fb45b1a3aa Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 22 Dec 2021 16:25:19 +0000 Subject: [PATCH] Move optional build dependencies to 'extras' ...and start skipping the relevant tests in 'nova.tests.unit.virt' if these dependencies are not present. Thanks to hacking rules N311 and N312, which prevent virt drivers using code from other virt drivers, simply skipping the unit tests for a virt driver module is enough to ensure we never load those modules. This means users that want to use the powervm driver can install the required dependencies using e.g. 'pip install .[powervm]', and packagers can choose to skip packaging a dependency safe in the knowledge that the relevant tests will be skipped. Change-Id: I3787f9afd78cd0a7c7feb4dfe1bcb21437b5a128 Signed-off-by: Stephen Finucane --- nova/tests/unit/virt/hyperv/__init__.py | 20 ++++++++++++++++++++ nova/tests/unit/virt/powervm/__init__.py | 11 ++++++++++- nova/tests/unit/virt/vmwareapi/__init__.py | 20 ++++++++++++++++++++ nova/tests/unit/virt/zvm/__init__.py | 20 ++++++++++++++++++++ requirements.txt | 5 ----- setup.cfg | 8 ++++++++ test-requirements.txt | 3 --- 7 files changed, 78 insertions(+), 9 deletions(-) diff --git a/nova/tests/unit/virt/hyperv/__init__.py b/nova/tests/unit/virt/hyperv/__init__.py index e69de29bb2d1..2190f0570ff8 100644 --- a/nova/tests/unit/virt/hyperv/__init__.py +++ b/nova/tests/unit/virt/hyperv/__init__.py @@ -0,0 +1,20 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import unittest + +try: + import os_win # noqa: F401 +except ImportError: + raise unittest.SkipTest( + "The 'os-win' dependency is not installed." + ) diff --git a/nova/tests/unit/virt/powervm/__init__.py b/nova/tests/unit/virt/powervm/__init__.py index dedb6af7db10..3f8ef7b16717 100644 --- a/nova/tests/unit/virt/powervm/__init__.py +++ b/nova/tests/unit/virt/powervm/__init__.py @@ -11,13 +11,22 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# + +import unittest + from oslo_utils.fixture import uuidsentinel from nova.compute import power_state from nova.compute import vm_states from nova import objects +try: + import powervm # noqa: F401 +except ImportError: + raise unittest.SkipTest( + "The 'pypowervm' dependency is not installed." + ) + TEST_FLAVOR = objects.flavor.Flavor( memory_mb=2048, diff --git a/nova/tests/unit/virt/vmwareapi/__init__.py b/nova/tests/unit/virt/vmwareapi/__init__.py index e69de29bb2d1..206b60cb8fed 100644 --- a/nova/tests/unit/virt/vmwareapi/__init__.py +++ b/nova/tests/unit/virt/vmwareapi/__init__.py @@ -0,0 +1,20 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import unittest + +try: + import oslo_vmware # noqa: F401 +except ImportError: + raise unittest.SkipTest( + "The 'oslo.vmware' dependency is not installed." + ) diff --git a/nova/tests/unit/virt/zvm/__init__.py b/nova/tests/unit/virt/zvm/__init__.py index e69de29bb2d1..a93e19e1be56 100644 --- a/nova/tests/unit/virt/zvm/__init__.py +++ b/nova/tests/unit/virt/zvm/__init__.py @@ -0,0 +1,20 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import unittest + +try: + import zvmconnector # noqa: F401 +except ImportError: + raise unittest.SkipTest( + "The 'zVMCloudConnector' dependency is not installed." + ) diff --git a/requirements.txt b/requirements.txt index 46a611b1debb..c053e1e2202e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,8 +8,6 @@ lxml>=4.5.0 # BSD Routes>=2.3.1 # MIT cryptography>=2.7 # BSD/Apache-2.0 WebOb>=1.8.2 # MIT -# NOTE(mriedem): greenlet 0.4.14 does not work with older versions of gcc on -# ppc64le systems, see https://github.com/python-greenlet/greenlet/issues/136. greenlet>=0.4.15 # MIT PasteDeploy>=1.5.0 # MIT Paste>=2.0.2 # MIT @@ -52,17 +50,14 @@ os-brick>=4.3.1 # Apache-2.0 os-resource-classes>=1.1.0 # Apache-2.0 os-traits>=2.5.0 # Apache-2.0 os-vif>=1.15.2 # Apache-2.0 -os-win>=5.4.0 # Apache-2.0 castellan>=0.16.0 # Apache-2.0 microversion-parse>=0.2.1 # Apache-2.0 tooz>=1.58.0 # Apache-2.0 cursive>=0.2.1 # Apache-2.0 -pypowervm>=1.1.15 # Apache-2.0 retrying>=1.3.3,!=1.3.0 # Apache-2.0 os-service-types>=1.7.0 # Apache-2.0 taskflow>=3.8.0 # Apache-2.0 python-dateutil>=2.7.0 # BSD -zVMCloudConnector>=1.3.0;sys_platform!='win32' # Apache 2.0 License futurist>=1.8.0 # Apache-2.0 openstacksdk>=0.35.0 # Apache-2.0 dataclasses>=0.7;python_version=='3.6' # Apache 2.0 License diff --git a/setup.cfg b/setup.cfg index 3857fd5e473d..99d7cdaf104d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,6 +30,14 @@ classifiers = [extras] osprofiler = osprofiler>=1.4.0 # Apache-2.0 +powervm = + pypowervm>=1.1.15 # Apache-2.0 +zvm = + zVMCloudConnector>=1.3.0;sys_platform!='win32' # Apache 2.0 License +hyperv = + os-win>=5.4.0 # Apache-2.0 +vmware = + oslo.vmware>=3.6.0 # Apache-2.0 [files] data_files = diff --git a/test-requirements.txt b/test-requirements.txt index 3f3c1c0cb5e6..3194e9dd6637 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -23,6 +23,3 @@ testtools>=2.5.0 # MIT bandit>=1.1.0 # Apache-2.0 gabbi>=1.35.0 # Apache-2.0 wsgi-intercept>=1.7.0 # MIT License - -# vmwareapi driver specific dependencies -oslo.vmware>=3.6.0 # Apache-2.0