Merge pull request #34295 from sebastian-philipp/raise-for-invalid-dg

python-common: raise on empty drive selections

Reviewed-by: Joshua Schmid <jschmid@suse.de>
This commit is contained in:
Sebastian Wagner 2020-03-31 15:25:25 +02:00 committed by GitHub
commit 7ff5d89dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# flake8: noqa
import pytest
import yaml
from ceph.deployment import drive_selection, translate
from ceph.deployment.inventory import Device
@ -28,10 +29,26 @@ def test_DriveGroup(test_input):
assert all([isinstance(x, Device) for x in dg.data_devices.paths])
assert dg.data_devices.paths[0].path == '/dev/sda'
def test_DriveGroup_fail():
@pytest.mark.parametrize("test_input",
[
(
{}
),
(
yaml.safe_load("""
service_type: osd
service_id: mydg
placement:
host_pattern: '*'
data_devices:
limit: 1
""")
)
])
def test_DriveGroup_fail(test_input):
with pytest.raises(ServiceSpecValidationError):
DriveGroupSpec.from_json({})
DriveGroupSpec.from_json(test_input)
def test_drivegroup_pattern():

View File

@ -4,3 +4,4 @@ mock; python_version < '3.3'
mypy==0.770; python_version >= '3'
pytest-mypy; python_version >= '3'
pytest >= 2.1.3; python_version >= '3'
pyyaml