Skip to content

Commit 86d87be

Browse files
committed
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 <[email protected]>
1 parent ff1dbb5 commit 86d87be

File tree

7 files changed

+78
-9
lines changed

7 files changed

+78
-9
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import unittest
14+
15+
try:
16+
import os_win # noqa: F401
17+
except ImportError:
18+
raise unittest.SkipTest(
19+
"The 'os-win' dependency is not installed."
20+
)

nova/tests/unit/virt/powervm/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
#
14+
15+
import unittest
16+
1517
from oslo_utils.fixture import uuidsentinel
1618

1719
from nova.compute import power_state
1820
from nova.compute import vm_states
1921
from nova import objects
2022

23+
try:
24+
import powervm # noqa: F401
25+
except ImportError:
26+
raise unittest.SkipTest(
27+
"The 'pypowervm' dependency is not installed."
28+
)
29+
2130

2231
TEST_FLAVOR = objects.flavor.Flavor(
2332
memory_mb=2048,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import unittest
14+
15+
try:
16+
import oslo_vmware # noqa: F401
17+
except ImportError:
18+
raise unittest.SkipTest(
19+
"The 'oslo.vmware' dependency is not installed."
20+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import unittest
14+
15+
try:
16+
import zvmconnector # noqa: F401
17+
except ImportError:
18+
raise unittest.SkipTest(
19+
"The 'zVMCloudConnector' dependency is not installed."
20+
)

requirements.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ lxml>=4.5.0 # BSD
88
Routes>=2.3.1 # MIT
99
cryptography>=2.7 # BSD/Apache-2.0
1010
WebOb>=1.8.2 # MIT
11-
# NOTE(mriedem): greenlet 0.4.14 does not work with older versions of gcc on
12-
# ppc64le systems, see https://github.com/python-greenlet/greenlet/issues/136.
1311
greenlet>=0.4.15 # MIT
1412
PasteDeploy>=1.5.0 # MIT
1513
Paste>=2.0.2 # MIT
@@ -52,17 +50,14 @@ os-brick>=4.3.1 # Apache-2.0
5250
os-resource-classes>=1.1.0 # Apache-2.0
5351
os-traits>=2.5.0 # Apache-2.0
5452
os-vif>=1.15.2 # Apache-2.0
55-
os-win>=5.4.0 # Apache-2.0
5653
castellan>=0.16.0 # Apache-2.0
5754
microversion-parse>=0.2.1 # Apache-2.0
5855
tooz>=1.58.0 # Apache-2.0
5956
cursive>=0.2.1 # Apache-2.0
60-
pypowervm>=1.1.15 # Apache-2.0
6157
retrying>=1.3.3,!=1.3.0 # Apache-2.0
6258
os-service-types>=1.7.0 # Apache-2.0
6359
taskflow>=3.8.0 # Apache-2.0
6460
python-dateutil>=2.7.0 # BSD
65-
zVMCloudConnector>=1.3.0;sys_platform!='win32' # Apache 2.0 License
6661
futurist>=1.8.0 # Apache-2.0
6762
openstacksdk>=0.35.0 # Apache-2.0
6863
dataclasses>=0.7;python_version=='3.6' # Apache 2.0 License

setup.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ classifiers =
3030
[extras]
3131
osprofiler =
3232
osprofiler>=1.4.0 # Apache-2.0
33+
powervm =
34+
pypowervm>=1.1.15 # Apache-2.0
35+
zvm =
36+
zVMCloudConnector>=1.3.0;sys_platform!='win32' # Apache 2.0 License
37+
hyperv =
38+
os-win>=5.4.0 # Apache-2.0
39+
vmware =
40+
oslo.vmware>=3.6.0 # Apache-2.0
3341

3442
[files]
3543
data_files =

test-requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,3 @@ testtools>=2.5.0 # MIT
2323
bandit>=1.1.0 # Apache-2.0
2424
gabbi>=1.35.0 # Apache-2.0
2525
wsgi-intercept>=1.7.0 # MIT License
26-
27-
# vmwareapi driver specific dependencies
28-
oslo.vmware>=3.6.0 # Apache-2.0

0 commit comments

Comments
 (0)