From 41ef0f51b7f4d0e3b7c0720d11eca132862a84fb Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 3 May 2018 12:47:53 -0400 Subject: [PATCH] ceph-volume tests verify mapper and /dev devices Signed-off-by: Alfredo Deza (cherry picked from commit 9cfd37344c69ebf1f3d8440f295d79ae05b545e9) --- .../ceph_volume/tests/util/test_disk.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/ceph-volume/ceph_volume/tests/util/test_disk.py b/src/ceph-volume/ceph_volume/tests/util/test_disk.py index dc6f208f7a824..cbe111f04896f 100644 --- a/src/ceph-volume/ceph_volume/tests/util/test_disk.py +++ b/src/ceph-volume/ceph_volume/tests/util/test_disk.py @@ -97,3 +97,29 @@ class TestGetBlockDevs(object): path = os.path.dirname(tmpfile(name='loop0', contents='')) result = disk.get_block_devs(sys_block_path=path, skip_loop=False) assert result == ['loop0'] + + +class TestGetDevDevs(object): + + def test_abspaths_are_included(self, tmpfile): + sda_path = tmpfile(name='sda', contents='') + directory = os.path.dirname(sda_path) + result = disk.get_dev_devs(directory) + assert sorted(result.keys()) == sorted(['sda', sda_path]) + assert result['sda'] == sda_path + assert result[sda_path] == 'sda' + + +class TestGetMapperDevs(object): + + def test_abspaths_and_realpaths_are_included(self, tmpfile): + dm_path = tmpfile(name='dm-0', contents='') + directory = os.path.dirname(dm_path) + sda_path = os.path.join(directory, 'sda') + os.symlink(sda_path, os.path.join(directory, 'sda')) + result = disk.get_mapper_devs(directory) + assert sorted(result.keys()) == sorted([dm_path, sda_path, 'sda', 'dm-0']) + assert result['sda'] == sda_path + assert result['dm-0'] == dm_path + assert result[sda_path] == sda_path + assert result[dm_path] == 'dm-0' -- 2.39.5