From: Sebastian Wagner Date: Mon, 30 Mar 2020 17:51:31 +0000 (+0200) Subject: python-common: raise on emtpy drive groups X-Git-Tag: v15.2.2~80^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bf7a7b710737632be7445a8f8df2ecd3a7ff465d;p=ceph.git python-common: raise on emtpy drive groups adds a test for https://tracker.ceph.com/issues/44758 Signed-off-by: Sebastian Wagner (cherry picked from commit 874ba5049a820d6d8aa772b34c971048641e2143) --- diff --git a/src/python-common/ceph/tests/test_drive_group.py b/src/python-common/ceph/tests/test_drive_group.py index 7de664050865..d0cf37c17b29 100644 --- a/src/python-common/ceph/tests/test_drive_group.py +++ b/src/python-common/ceph/tests/test_drive_group.py @@ -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(): diff --git a/src/python-common/requirements.txt b/src/python-common/requirements.txt index 7ac71f74d22b..eee157ac4439 100644 --- a/src/python-common/requirements.txt +++ b/src/python-common/requirements.txt @@ -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 \ No newline at end of file