]> sourceware.org Git - lvm2.git/commitdiff
lvmdbustest.py: Add nested testing
authorTony Asleson <tasleson@redhat.com>
Sat, 22 Apr 2017 05:06:59 +0000 (00:06 -0500)
committerTony Asleson <tasleson@redhat.com>
Wed, 26 Apr 2017 12:30:45 +0000 (07:30 -0500)
Make sure when a LV is used as a PV the dbus service works correctly.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
test/dbus/lvmdbustest.py

index d88a7743e2aac93c77c84301dbcbf418b945ab6a..50f6ad42f24bb80cd4bc41fcd1668c9886da2284 100755 (executable)
@@ -75,7 +75,7 @@ def is_nested_pv(pv_name):
 def _root_pv_name(res, pv_name):
        if not is_nested_pv(pv_name):
                return pv_name
-       vg_name = pv_name.split('/')[2:3][0]
+       vg_name = pv_name.split('/')[2]
        for v in res[VG_INT]:
                if v.Vg.Name == vg_name:
                        pv = ClientProxy(bus, v.Vg.Pvs[0], interfaces=(PV_INT, ))
@@ -120,7 +120,7 @@ def get_objects():
 
        for object_path, v in objects.items():
                proxy = ClientProxy(bus, object_path, v)
-               for interface, prop in v.items():
+               for interface in v.keys():
                        rc[interface].append(proxy)
 
        # At this point we have a full population of everything, we now need to
@@ -1832,6 +1832,39 @@ class TestDbusService(unittest.TestCase):
                cmd = ['pvcreate', target.Pv.Name]
                self._verify_existence(cmd, cmd[0], target.Pv.Name)
 
+       def _create_nested(self, pv_object_path):
+               vg = self._vg_create([pv_object_path])
+               pv = ClientProxy(self.bus, pv_object_path, interfaces=(PV_INT,))
+
+               self.assertEqual(pv.Pv.Vg, vg.object_path)
+               self.assertIn(pv_object_path, vg.Vg.Pvs,
+                                               "Expecting PV object path in Vg.Pvs")
+
+               lv = self._create_lv(vg=vg.Vg, size=vg.Vg.FreeBytes)
+               device_path = '/dev/%s/%s' % (vg.Vg.Name, lv.LvCommon.Name)
+               new_pv_object_path = self._pv_create(device_path)
+
+               vg.update()
+
+               self.assertEqual(lv.LvCommon.Vg, vg.object_path)
+               self.assertIn(lv.object_path, vg.Vg.Lvs,
+                                               "Expecting LV object path in Vg.Lvs")
+
+               new_pv_proxy = ClientProxy(self.bus,
+                                                                       new_pv_object_path,
+                                                                       interfaces=(PV_INT, ))
+               self.assertEqual(new_pv_proxy.Pv.Name, device_path)
+
+               return new_pv_object_path
+
+       def test_nesting(self):
+               # check to see if we handle an LV becoming a PV which has it's own
+               # LV
+               pv_object_path = self.objs[PV_INT][0].object_path
+
+               for i in range(0, 5):
+                       pv_object_path = self._create_nested(pv_object_path)
+
 
 class AggregateResults(object):
 
This page took 0.041267 seconds and 5 git commands to generate.