X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fpython-common%2Fceph%2Ftests%2Ftest_service_spec.py;h=12a8be84bfd6569018e988813c8e37f8805e6054;hb=1911f103e16ae0d04db10fb41db8217ef4c320d3;hp=4b2c85c4b1fd397a9969a5f5b358d0673cbd7707;hpb=78f773100ed5d2ebc9d99e65a3d7e3a6f541a97e;p=ceph.git diff --git a/ceph/src/python-common/ceph/tests/test_service_spec.py b/ceph/src/python-common/ceph/tests/test_service_spec.py index 4b2c85c4b..12a8be84b 100644 --- a/ceph/src/python-common/ceph/tests/test_service_spec.py +++ b/ceph/src/python-common/ceph/tests/test_service_spec.py @@ -1,10 +1,12 @@ # flake8: noqa import json +import yaml import pytest -from ceph.deployment.service_spec import HostPlacementSpec, PlacementSpec, RGWSpec, \ - servicespec_validate_add, ServiceSpecValidationError +from ceph.deployment.service_spec import HostPlacementSpec, PlacementSpec, RGWSpec, NFSServiceSpec, \ + servicespec_validate_add, ServiceSpec, ServiceSpecValidationError +from ceph.deployment.drive_group import DriveGroupSpec @pytest.mark.parametrize("test_input,expected, require_network", @@ -24,6 +26,7 @@ def test_parse_host_placement_specs(test_input, expected, require_network): assert ret == expected assert str(ret) == test_input + @pytest.mark.parametrize( "test_input,expected", [ @@ -66,23 +69,36 @@ def test_parse_placement_specs_raises(test_input): [("myhost:1.1.1.1/24"), # wrong ip format ("myhost:1"), - # empty string - ("myhost=1"), ]) -def test_parse_host_placement_specs_raises(test_input): +def test_parse_host_placement_specs_raises_wrong_format(test_input): with pytest.raises(ValueError): - ret = HostPlacementSpec.parse(test_input) + HostPlacementSpec.parse(test_input) -def test_rgwspec(): - """ - { - "rgw_zone": "zonename", - "service_type": "rgw", - "rgw_frontend_port": 8080, - "rgw_realm": "realm" +@pytest.mark.parametrize( + "s_type,o_spec,s_id", + [ + ("mgr", ServiceSpec, 'test'), + ("mon", ServiceSpec, 'test'), + ("mds", ServiceSpec, 'test'), + ("rgw", RGWSpec, 'realm.zone'), + ("nfs", NFSServiceSpec, 'test'), + ("osd", DriveGroupSpec, 'test'), + ]) +def test_servicespec_map_test(s_type, o_spec, s_id): + dict_spec = { + "service_id": s_id, + "service_type": s_type, + "placement": + dict(hosts=["host1:1.1.1.1"]) } - """ - example = json.loads(test_rgwspec.__doc__.strip()) - spec = RGWSpec.from_json(example) - assert servicespec_validate_add(spec) is None \ No newline at end of file + spec = ServiceSpec.from_json(dict_spec) + assert isinstance(spec, o_spec) + assert isinstance(spec.placement, PlacementSpec) + assert isinstance(spec.placement.hosts[0], HostPlacementSpec) + assert spec.placement.hosts[0].hostname == 'host1' + assert spec.placement.hosts[0].network == '1.1.1.1' + assert spec.placement.hosts[0].name == '' + assert servicespec_validate_add(spec) is None + ServiceSpec.from_json(spec.to_json()) +