]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: adds a unit test for `lvm list /dev/sda` 23349/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:58:50 +0000 (08:58 -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>
(cherry picked from commit ef10886f1e061d4273d3c0763ab0827e7e58e9d7)

src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py

index a49a3e9e6a08f44246ad06ce86e14380c4809b5e..173da9392fd5825ada4bddae49d33b348c355ca1 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(