]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: raise on emtpy drive groups
authorSebastian Wagner <sebastian.wagner@suse.com>
Mon, 30 Mar 2020 17:51:31 +0000 (19:51 +0200)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 7 Apr 2020 09:36:27 +0000 (11:36 +0200)
adds a test for https://tracker.ceph.com/issues/44758

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
(cherry picked from commit 874ba5049a820d6d8aa772b34c971048641e2143)

src/python-common/ceph/tests/test_drive_group.py
src/python-common/requirements.txt

index 7de6640508659e711c6412c085e57f6fc8317c30..d0cf37c17b29024f8e599bd476a2095a97b8bd24 100644 (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():
index 7ac71f74d22b260e562b35f2cd123fd314c8969a..eee157ac4439929f25d29cfaeeaa79ca2b9895a3 100644 (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
\ No newline at end of file