Skip to content

Commit

Permalink
Move optional build dependencies to 'extras'
Browse files Browse the repository at this point in the history
...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 <stephenfin@redhat.com>
  • Loading branch information
stephenfin committed Jan 28, 2022
1 parent ff1dbb5 commit 86d87be
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 9 deletions.
20 changes: 20 additions & 0 deletions 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."
)
11 changes: 10 additions & 1 deletion nova/tests/unit/virt/powervm/__init__.py
Expand Up @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions 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."
)
20 changes: 20 additions & 0 deletions 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."
)
5 changes: 0 additions & 5 deletions requirements.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions setup.cfg
Expand Up @@ -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 =
Expand Down
3 changes: 0 additions & 3 deletions test-requirements.txt
Expand Up @@ -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

0 comments on commit 86d87be

Please sign in to comment.