]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: adds a unit test for `lvm list /dev/sda` 23348/head
authorAndrew Schoen <aschoen@redhat.com>
Mon, 30 Jul 2018 18:52:37 +0000 (13:52 -0500)
committerAndrew Schoen <aschoen@redhat.com>
Tue, 31 Jul 2018 13:50:28 +0000 (08:50 -0500)
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 <aschoen@redhat.com>
src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py

index fba7d73e135d3ad3a7aa9376edbf5a6b7f9c087e..1af1498f013514e7c3f01854f3df0de0c5dc7827 100644 (file)
@@ -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(