From a6fa400d002619758a1ea682eb43d55635a9fb6e Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Mon, 30 Jul 2018 13:52:37 -0500 Subject: [PATCH] ceph-volume: adds a unit test for `lvm list /dev/sda` This test is to prove that the issue from http://tracker.ceph.com/issues/24957 was fixed by http://tracker.ceph.com/issues/24784 When running lvm list against a raw device it should handle gracefully the situation where there are multiple PVs with the name of the given device. Signed-off-by: Andrew Schoen (cherry picked from commit ef10886f1e061d4273d3c0763ab0827e7e58e9d7) --- .../tests/devices/lvm/test_listing.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py index a49a3e9e6a08f..173da9392fd58 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py @@ -210,6 +210,26 @@ class TestSingleReport(object): assert result['0'][0]['path'] == '/dev/VolGroup/lv' assert result['0'][0]['devices'] == ['/dev/sda1', '/dev/sdb1'] + def test_report_a_ceph_lv_with_multiple_pvs_of_same_name(self, pvolumes, monkeypatch): + tags = 'ceph.osd_id=0,ceph.journal_uuid=x,ceph.type=data' + lv = api.Volume( + lv_name='lv', vg_name='VolGroup', + lv_uuid='aaaa', lv_path='/dev/VolGroup/lv', lv_tags=tags + ) + monkeypatch.setattr(api, 'get_lv_from_argument', lambda device: None) + monkeypatch.setattr(api, 'get_lv', lambda vg_name: lv) + FooPVolume = api.PVolume(vg_name="vg", pv_name='/dev/sda', pv_uuid="0000", pv_tags={}, lv_uuid="aaaa") + BarPVolume = api.PVolume(vg_name="vg", pv_name='/dev/sda', pv_uuid="0000", pv_tags={}) + pvolumes.append(FooPVolume) + pvolumes.append(BarPVolume) + monkeypatch.setattr(api, 'PVolumes', lambda: pvolumes) + listing = lvm.listing.List([]) + result = listing.single_report('/dev/sda') + assert result['0'][0]['name'] == 'lv' + assert result['0'][0]['lv_tags'] == tags + assert result['0'][0]['path'] == '/dev/VolGroup/lv' + assert len(result) == 1 + def test_report_a_ceph_lv_with_no_matching_devices(self, volumes, monkeypatch): tags = 'ceph.osd_id=0,ceph.journal_uuid=x,ceph.type=data' lv = api.Volume( -- 2.39.5