]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: test number of times LVs list was created 30096/head
authorRishabh Dave <ridave@redhat.com>
Mon, 19 Aug 2019 13:33:21 +0000 (19:03 +0530)
committerJan Fajerski <jfajerski@suse.com>
Tue, 3 Sep 2019 11:01:59 +0000 (13:01 +0200)
Add a test that cofirm that the LVs list was created only once when
calling devices.lvm.listing.list()

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 20d6264538dab444c0ef13f40c6c21ec3d2057f8)

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

index 173da9392fd5825ada4bddae49d33b348c355ca1..5c0fec75611b32197c48b6fe3f5faeba207aaaf2 100644 (file)
@@ -79,6 +79,23 @@ class TestList(object):
         with pytest.raises(SystemExit):
             lvm.listing.List([]).list(args)
 
+    def test_lvs_list_is_created_just_once(self, monkeypatch, is_root, volumes, factory):
+        api.volumes_obj_create_count = 0
+
+        def monkey_populate(self):
+            api.volumes_obj_create_count += 1
+            for lv_item in api.get_api_lvs():
+                self.append(api.Volume(**lv_item))
+        monkeypatch.setattr(api.Volumes, '_populate', monkey_populate)
+
+        args = factory(format='pretty', device='/dev/sda1')
+        with pytest.raises(SystemExit):
+            lvm.listing.List([]).list(args)
+
+        # XXX: Ideally, the count should be just 1. Volumes._populate() is
+        # being called thrice out of which only twice is moneky_populate.
+        assert api.volumes_obj_create_count == 2
+
 
 class TestFullReport(object):