From bf7a7b710737632be7445a8f8df2ecd3a7ff465d Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Mon, 30 Mar 2020 19:51:31 +0200 Subject: [PATCH] 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) --- .../ceph/tests/test_drive_group.py | 23 ++++++++++++++++--- src/python-common/requirements.txt | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/python-common/ceph/tests/test_drive_group.py b/src/python-common/ceph/tests/test_drive_group.py index 7de6640508659..d0cf37c17b290 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 7ac71f74d22b2..eee157ac44399 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 -- 2.39.5