From e50fb06792518ff9a5a299172b77e9d22105d372 Mon Sep 17 00:00:00 2001 From: Tony Asleson Date: Sat, 22 Apr 2017 00:06:59 -0500 Subject: [PATCH] lvmdbustest.py: Add nested testing Make sure when a LV is used as a PV the dbus service works correctly. Signed-off-by: Tony Asleson --- test/dbus/lvmdbustest.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py index d88a7743e..50f6ad42f 100755 --- a/test/dbus/lvmdbustest.py +++ b/test/dbus/lvmdbustest.py @@ -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): -- 2.43.5