From: Sage Weil Date: Fri, 11 Jun 2021 19:34:27 +0000 (-0400) Subject: mgr/nfs: test that export <-> block+dict conversions go both ways X-Git-Tag: v17.1.0~1551^2~26 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=16c5cb62f797b0154362678aeed0bf7aebe12f40;p=ceph-ci.git mgr/nfs: test that export <-> block+dict conversions go both ways Fixes: https://tracker.ceph.com/issues/50449 Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/nfs/tests/test_nfs.py b/src/pybind/mgr/nfs/tests/test_nfs.py index 9df9f39054a..cfa8c96d40a 100644 --- a/src/pybind/mgr/nfs/tests/test_nfs.py +++ b/src/pybind/mgr/nfs/tests/test_nfs.py @@ -1,5 +1,6 @@ # flake8: noqa +import pytest from typing import Optional, Tuple, Iterator, List, Any, Dict from contextlib import contextmanager @@ -502,6 +503,37 @@ NFS_CORE_PARAM { # assert export.daemons == set(expected_exports[2]) assert export.cluster_id == cluster_id + @pytest.mark.parametrize( + "block", + [ + export_1, + export_2, + ] + ) + def test_export_from_to_export_block(self, block): + cluster_id = 'foo' + blocks = GaneshaConfParser(block).parse() + export = Export.from_export_block(blocks[0], cluster_id) + newblock = export.to_export_block() + export2 = Export.from_export_block(newblock, cluster_id) + newblock2 = export2.to_export_block() + assert newblock == newblock2 + + @pytest.mark.parametrize( + "block", + [ + export_1, + export_2, + ] + ) + def test_export_from_to_dict(self, block): + cluster_id = 'foo' + blocks = GaneshaConfParser(block).parse() + export = Export.from_export_block(blocks[0], cluster_id) + j = export.to_dict() + export2 = Export.from_dict(j['export_id'], j) + j2 = export2.to_dict() + assert j == j2 """ def test_update_export(self): for cluster_id, info in self.clusters.items():