mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmdbustest.py: Test with/without timeout values
Because of the different code paths we need to test job handling with all operations. Test now runs virtually everything with timeout == 0 and timeout == 15 so that we test both use cases. Note: If a client passes -1 for the timeout value they need to make sure that their connection time out is also infinite. Otherwise, if the client times out the service side hangs any new dbus calls until the job that is in progress completes. Not sure why this behavior is occuring at this time, but it appears a limitation/bug of the dbus-python library.
This commit is contained in:
parent
5366e87574
commit
cb2b261510
@ -19,6 +19,8 @@ import pyudev
|
|||||||
import os
|
import os
|
||||||
from testlib import *
|
from testlib import *
|
||||||
|
|
||||||
|
g_tmo = 0
|
||||||
|
|
||||||
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
|
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
|
||||||
|
|
||||||
if use_session:
|
if use_session:
|
||||||
@ -81,7 +83,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
self.objs, self.bus = get_objects()
|
self.objs, self.bus = get_objects()
|
||||||
for v in self.objs[VG_INT]:
|
for v in self.objs[VG_INT]:
|
||||||
# print "DEBUG: Removing VG= ", v.Uuid, v.Name
|
# print "DEBUG: Removing VG= ", v.Uuid, v.Name
|
||||||
v.Vg.Remove(-1, {})
|
self.handle_return(v.Vg.Remove(g_tmo, {}))
|
||||||
|
|
||||||
# Check to make sure the PVs we had to start exist, else re-create
|
# Check to make sure the PVs we had to start exist, else re-create
|
||||||
# them
|
# them
|
||||||
@ -97,8 +99,25 @@ class TestDbusService(unittest.TestCase):
|
|||||||
# print('Re-creating PV=', p)
|
# print('Re-creating PV=', p)
|
||||||
self._pv_create(p)
|
self._pv_create(p)
|
||||||
|
|
||||||
|
def handle_return(self, rc):
|
||||||
|
if isinstance(rc, (tuple, list)):
|
||||||
|
# We have a tuple returned
|
||||||
|
if rc[0] != '/':
|
||||||
|
return rc[0]
|
||||||
|
else:
|
||||||
|
return self._wait_for_job(rc[1])
|
||||||
|
else:
|
||||||
|
if rc == '/':
|
||||||
|
return rc
|
||||||
|
else:
|
||||||
|
return self._wait_for_job(rc)
|
||||||
|
|
||||||
def _pv_create(self, device):
|
def _pv_create(self, device):
|
||||||
pv_path = self.objs[MANAGER_INT][0].Manager.PvCreate(device, -1, {})[0]
|
|
||||||
|
pv_path = self.handle_return(
|
||||||
|
self.objs[MANAGER_INT][0].Manager.PvCreate(
|
||||||
|
device, g_tmo, {})
|
||||||
|
)
|
||||||
self.assertTrue(pv_path is not None and len(pv_path) > 0)
|
self.assertTrue(pv_path is not None and len(pv_path) > 0)
|
||||||
return pv_path
|
return pv_path
|
||||||
|
|
||||||
@ -124,11 +143,10 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
vg_name = rs(8, '_vg')
|
vg_name = rs(8, '_vg')
|
||||||
|
|
||||||
vg_path = self.objs[MANAGER_INT][0].Manager.VgCreate(
|
vg_path = self.handle_return(
|
||||||
vg_name,
|
self.objs[MANAGER_INT][0].Manager.VgCreate(
|
||||||
pv_paths,
|
vg_name, pv_paths, g_tmo, {}))
|
||||||
-1,
|
|
||||||
{})[0]
|
|
||||||
self.assertTrue(vg_path is not None and len(vg_path) > 0)
|
self.assertTrue(vg_path is not None and len(vg_path) > 0)
|
||||||
return ClientProxy(self.bus, vg_path)
|
return ClientProxy(self.bus, vg_path)
|
||||||
|
|
||||||
@ -138,19 +156,19 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
def test_vg_delete(self):
|
def test_vg_delete(self):
|
||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
vg.Remove(-1, {})
|
|
||||||
|
self.handle_return(vg.Remove(g_tmo, {}))
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@staticmethod
|
def _pv_remove(self, pv):
|
||||||
def _pv_remove(pv):
|
rc = self.handle_return(pv.Pv.Remove(g_tmo, {}))
|
||||||
rc = pv.Pv.Remove(-1, {})
|
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
def test_pv_remove_add(self):
|
def test_pv_remove_add(self):
|
||||||
target = self.objs[PV_INT][0]
|
target = self.objs[PV_INT][0]
|
||||||
|
|
||||||
# Remove the PV
|
# Remove the PV
|
||||||
rc = TestDbusService._pv_remove(target)
|
rc = self._pv_remove(target)
|
||||||
self.assertTrue(rc == '/')
|
self.assertTrue(rc == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -168,14 +186,19 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
vg = self._vg_create(pv_paths).Vg
|
vg = self._vg_create(pv_paths).Vg
|
||||||
|
|
||||||
lv_meta_path = vg.LvCreateRaid(
|
lv_meta_path = self.handle_return(
|
||||||
"meta_r5", "raid5", mib(4), 0, 0, -1, {})[0]
|
vg.LvCreateRaid(
|
||||||
|
"meta_r5", "raid5", mib(4), 0, 0, g_tmo, {})
|
||||||
|
)
|
||||||
|
|
||||||
lv_data_path = vg.LvCreateRaid(
|
lv_data_path = self.handle_return(
|
||||||
"data_r5", "raid5", mib(16), 0, 0, -1, {})[0]
|
vg.LvCreateRaid(
|
||||||
|
"data_r5", "raid5", mib(16), 0, 0, g_tmo, {})
|
||||||
|
)
|
||||||
|
|
||||||
thin_pool_path = vg.CreateThinPool(
|
thin_pool_path = self.handle_return(
|
||||||
lv_meta_path, lv_data_path, -1, {})[0]
|
vg.CreateThinPool(lv_meta_path, lv_data_path, g_tmo, {})
|
||||||
|
)
|
||||||
|
|
||||||
# Get thin pool client proxy
|
# Get thin pool client proxy
|
||||||
thin_pool = ClientProxy(self.bus, thin_pool_path)
|
thin_pool = ClientProxy(self.bus, thin_pool_path)
|
||||||
@ -197,8 +220,10 @@ class TestDbusService(unittest.TestCase):
|
|||||||
self.assertTrue(cache_pool.CachePool.MetaDataLv != '/')
|
self.assertTrue(cache_pool.CachePool.MetaDataLv != '/')
|
||||||
|
|
||||||
# Cache the thin pool
|
# Cache the thin pool
|
||||||
cached_thin_pool_path = cache_pool.\
|
cached_thin_pool_path = self.handle_return(
|
||||||
CachePool.CacheLv(thin_pool.object_path, -1, {})[0]
|
cache_pool.CachePool.CacheLv(
|
||||||
|
thin_pool.object_path, g_tmo, {})
|
||||||
|
)
|
||||||
|
|
||||||
# Get object proxy for cached thin pool
|
# Get object proxy for cached thin pool
|
||||||
cached_thin_pool_object = ClientProxy(self.bus, cached_thin_pool_path)
|
cached_thin_pool_object = ClientProxy(self.bus, cached_thin_pool_path)
|
||||||
@ -231,7 +256,10 @@ class TestDbusService(unittest.TestCase):
|
|||||||
pv_next = self.objs[PV_INT][1]
|
pv_next = self.objs[PV_INT][1]
|
||||||
|
|
||||||
vg = self._vg_create([pv_initial.object_path]).Vg
|
vg = self._vg_create([pv_initial.object_path]).Vg
|
||||||
path = vg.Extend([pv_next.object_path], -1, {})
|
|
||||||
|
path = self.handle_return(
|
||||||
|
vg.Extend([pv_next.object_path], g_tmo, {})
|
||||||
|
)
|
||||||
self.assertTrue(path == '/')
|
self.assertTrue(path == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -244,7 +272,9 @@ class TestDbusService(unittest.TestCase):
|
|||||||
[self.objs[PV_INT][0].object_path,
|
[self.objs[PV_INT][0].object_path,
|
||||||
self.objs[PV_INT][1].object_path]).Vg
|
self.objs[PV_INT][1].object_path]).Vg
|
||||||
|
|
||||||
path = vg.Reduce(False, [vg.Pvs[0]], -1, {})
|
path = self.handle_return(
|
||||||
|
vg.Reduce(False, [vg.Pvs[0]], g_tmo, {})
|
||||||
|
)
|
||||||
self.assertTrue(path == '/')
|
self.assertTrue(path == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -271,7 +301,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
new_name = 'renamed_' + vg.Name
|
new_name = 'renamed_' + vg.Name
|
||||||
|
|
||||||
path = vg.Rename(new_name, -1, {})
|
path = self.handle_return(vg.Rename(new_name, g_tmo, {}))
|
||||||
self.assertTrue(path == '/')
|
self.assertTrue(path == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -326,8 +356,9 @@ class TestDbusService(unittest.TestCase):
|
|||||||
for i in range(0, 5):
|
for i in range(0, 5):
|
||||||
lv_name = rs(8, '_lv')
|
lv_name = rs(8, '_lv')
|
||||||
|
|
||||||
thin_lv_path = thin_pool.ThinPool.LvCreate(
|
thin_lv_path = self.handle_return(
|
||||||
lv_name, mib(16), -1, {})[0]
|
thin_pool.ThinPool.LvCreate(
|
||||||
|
lv_name, mib(16), g_tmo, {}))
|
||||||
|
|
||||||
self.assertTrue(thin_lv_path != '/')
|
self.assertTrue(thin_lv_path != '/')
|
||||||
|
|
||||||
@ -339,8 +370,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
# Rename the VG
|
# Rename the VG
|
||||||
new_name = 'renamed_' + vg.Name
|
new_name = 'renamed_' + vg.Name
|
||||||
|
path = self.handle_return(vg.Rename(new_name, g_tmo, {}))
|
||||||
|
|
||||||
path = vg.Rename(new_name, -1, {})
|
|
||||||
self.assertTrue(path == '/')
|
self.assertTrue(path == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -366,8 +397,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
def _test_lv_create(self, method, params, vg):
|
def _test_lv_create(self, method, params, vg):
|
||||||
lv = None
|
lv = None
|
||||||
path = method(*params)[0]
|
|
||||||
|
|
||||||
|
path = self.handle_return(method(*params))
|
||||||
self.assertTrue(vg)
|
self.assertTrue(vg)
|
||||||
|
|
||||||
if path:
|
if path:
|
||||||
@ -386,7 +417,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
self._test_lv_create(
|
self._test_lv_create(
|
||||||
vg.LvCreate,
|
vg.LvCreate,
|
||||||
(rs(8, '_lv'), mib(4),
|
(rs(8, '_lv'), mib(4),
|
||||||
dbus.Array([], '(ott)'), -1, {}), vg)
|
dbus.Array([], '(ott)'), g_tmo, {}), vg)
|
||||||
|
|
||||||
def test_lv_create_job(self):
|
def test_lv_create_job(self):
|
||||||
|
|
||||||
@ -404,7 +435,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
self._test_lv_create(
|
self._test_lv_create(
|
||||||
vg.LvCreateLinear,
|
vg.LvCreateLinear,
|
||||||
(rs(8, '_lv'), mib(4), False, -1, {}), vg)
|
(rs(8, '_lv'), mib(4), False, g_tmo, {}), vg)
|
||||||
|
|
||||||
def test_lv_create_striped(self):
|
def test_lv_create_striped(self):
|
||||||
pv_paths = []
|
pv_paths = []
|
||||||
@ -415,7 +446,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
self._test_lv_create(
|
self._test_lv_create(
|
||||||
vg.LvCreateStriped,
|
vg.LvCreateStriped,
|
||||||
(rs(8, '_lv'), mib(4), 2, 8, False,
|
(rs(8, '_lv'), mib(4), 2, 8, False,
|
||||||
-1, {}), vg)
|
g_tmo, {}), vg)
|
||||||
|
|
||||||
def test_lv_create_mirror(self):
|
def test_lv_create_mirror(self):
|
||||||
pv_paths = []
|
pv_paths = []
|
||||||
@ -424,7 +455,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
vg = self._vg_create(pv_paths).Vg
|
vg = self._vg_create(pv_paths).Vg
|
||||||
self._test_lv_create(vg.LvCreateMirror,
|
self._test_lv_create(vg.LvCreateMirror,
|
||||||
(rs(8, '_lv'), mib(4), 2, -1, {}), vg)
|
(rs(8, '_lv'), mib(4), 2, g_tmo, {}), vg)
|
||||||
|
|
||||||
def test_lv_create_raid(self):
|
def test_lv_create_raid(self):
|
||||||
pv_paths = []
|
pv_paths = []
|
||||||
@ -433,8 +464,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
vg = self._vg_create(pv_paths).Vg
|
vg = self._vg_create(pv_paths).Vg
|
||||||
self._test_lv_create(vg.LvCreateRaid,
|
self._test_lv_create(vg.LvCreateRaid,
|
||||||
(rs(8, '_lv'), 'raid4',
|
(rs(8, '_lv'), 'raid4',
|
||||||
mib(16), 2, 8, -1, {}), vg)
|
mib(16), 2, 8, g_tmo, {}), vg)
|
||||||
|
|
||||||
def _create_lv(self, thinpool=False, size=None, vg=None):
|
def _create_lv(self, thinpool=False, size=None, vg=None):
|
||||||
|
|
||||||
@ -450,7 +481,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
return self._test_lv_create(
|
return self._test_lv_create(
|
||||||
vg.LvCreateLinear,
|
vg.LvCreateLinear,
|
||||||
(rs(8, '_lv'), size, thinpool, -1, {}), vg)
|
(rs(8, '_lv'), size, thinpool, g_tmo, {}), vg)
|
||||||
|
|
||||||
def test_lv_create_rounding(self):
|
def test_lv_create_rounding(self):
|
||||||
self._create_lv(size=(mib(2) + 13))
|
self._create_lv(size=(mib(2) + 13))
|
||||||
@ -466,7 +497,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
prev_path = path
|
prev_path = path
|
||||||
|
|
||||||
new_name = 'renamed_' + lv.LvCommon.Name
|
new_name = 'renamed_' + lv.LvCommon.Name
|
||||||
lv.Lv.Rename(new_name, -1, {})
|
|
||||||
|
self.handle_return(lv.Lv.Rename(new_name, g_tmo, {}))
|
||||||
|
|
||||||
path = self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(new_name)
|
path = self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(new_name)
|
||||||
|
|
||||||
@ -480,7 +512,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
"%s" % (tp.object_path))
|
"%s" % (tp.object_path))
|
||||||
|
|
||||||
new_name = 'renamed_' + tp.LvCommon.Name
|
new_name = 'renamed_' + tp.LvCommon.Name
|
||||||
tp.Lv.Rename(new_name, -1, {})
|
self.handle_return(tp.Lv.Rename(new_name, g_tmo, {}))
|
||||||
tp.update()
|
tp.update()
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
self.assertEqual(new_name, tp.LvCommon.Name)
|
self.assertEqual(new_name, tp.LvCommon.Name)
|
||||||
@ -493,17 +525,23 @@ class TestDbusService(unittest.TestCase):
|
|||||||
# thinpool interface too
|
# thinpool interface too
|
||||||
tp = self._create_lv(True)
|
tp = self._create_lv(True)
|
||||||
|
|
||||||
thin_path = tp.ThinPool.LvCreate(
|
thin_path = self.handle_return(
|
||||||
rs(10, '_thin_lv'), mib(8), -1, {})[0]
|
tp.ThinPool.LvCreate(
|
||||||
|
rs(10, '_thin_lv'), mib(8), g_tmo, {})
|
||||||
|
)
|
||||||
|
|
||||||
lv = ClientProxy(self.bus, thin_path)
|
lv = ClientProxy(self.bus, thin_path)
|
||||||
rc = lv.Lv.Rename('rename_test' + lv.LvCommon.Name, -1, {})
|
|
||||||
|
rc = self.handle_return(
|
||||||
|
lv.Lv.Rename('rename_test' + lv.LvCommon.Name, g_tmo, {})
|
||||||
|
)
|
||||||
|
|
||||||
self.assertTrue(rc == '/')
|
self.assertTrue(rc == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
def test_lv_remove(self):
|
def test_lv_remove(self):
|
||||||
lv = self._create_lv().Lv
|
lv = self._create_lv().Lv
|
||||||
rc = lv.Remove(-1, {})
|
rc = self.handle_return(lv.Remove(g_tmo, {}))
|
||||||
self.assertTrue(rc == '/')
|
self.assertTrue(rc == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -511,23 +549,10 @@ class TestDbusService(unittest.TestCase):
|
|||||||
lv_p = self._create_lv()
|
lv_p = self._create_lv()
|
||||||
ss_name = 'ss_' + lv_p.LvCommon.Name
|
ss_name = 'ss_' + lv_p.LvCommon.Name
|
||||||
|
|
||||||
# Test waiting to complete
|
rc = self.handle_return(lv_p.Lv.Snapshot(
|
||||||
ss, job = lv_p.Lv.Snapshot(ss_name, 0, -1, {})
|
ss_name, 0, g_tmo, {}))
|
||||||
self.assertTrue(ss != '/')
|
|
||||||
self.assertTrue(job == '/')
|
|
||||||
|
|
||||||
snapshot = ClientProxy(self.bus, ss)
|
self.assertTrue(rc != '/')
|
||||||
self.assertTrue(snapshot.LvCommon.Name == ss_name)
|
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
|
||||||
|
|
||||||
# Test getting a job returned immediately
|
|
||||||
rc, job = lv_p.Lv.Snapshot('ss2_' + lv_p.LvCommon.Name, 0, 0, {})
|
|
||||||
self.assertTrue(rc == '/')
|
|
||||||
self.assertTrue(job != '/')
|
|
||||||
self._wait_for_job(job)
|
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
|
||||||
|
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
def _wait_for_job(self, j_path):
|
def _wait_for_job(self, j_path):
|
||||||
@ -563,8 +588,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
pv_proxy = ClientProxy(self.bus, pv[0])
|
pv_proxy = ClientProxy(self.bus, pv[0])
|
||||||
|
|
||||||
self._test_lv_create(vg.LvCreate, (rs(8, '_lv'), mib(4),
|
self._test_lv_create(vg.LvCreate, (rs(8, '_lv'), mib(4),
|
||||||
dbus.Array([[pv_proxy.object_path, 0, (pv_proxy.Pv.PeCount - 1)]],
|
dbus.Array([[pv_proxy.object_path, 0, (pv_proxy.Pv.PeCount - 1)]],
|
||||||
'(ott)'), -1, {}), vg)
|
'(ott)'), g_tmo, {}), vg)
|
||||||
|
|
||||||
def test_lv_resize(self):
|
def test_lv_resize(self):
|
||||||
|
|
||||||
@ -590,12 +615,17 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
if len(pv_empty):
|
if len(pv_empty):
|
||||||
p = ClientProxy(self.bus, pv_empty[0])
|
p = ClientProxy(self.bus, pv_empty[0])
|
||||||
rc = lv.Lv.Resize(
|
|
||||||
size,
|
rc = self.handle_return(
|
||||||
dbus.Array([[p.object_path, 0, p.Pv.PeCount - 1]], '(oii)'),
|
lv.Lv.Resize(
|
||||||
-1, {})
|
size,
|
||||||
|
dbus.Array([[p.object_path, 0, p.Pv.PeCount - 1]],
|
||||||
|
'(oii)'),
|
||||||
|
g_tmo, {}))
|
||||||
else:
|
else:
|
||||||
rc = lv.Lv.Resize(size, dbus.Array([], '(oii)'), -1, {})
|
rc = self.handle_return(
|
||||||
|
lv.Lv.Resize(
|
||||||
|
size, dbus.Array([], '(oii)'), g_tmo, {}))
|
||||||
|
|
||||||
self.assertEqual(rc, '/')
|
self.assertEqual(rc, '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
@ -617,7 +647,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
lv = self._create_lv(vg=vg)
|
lv = self._create_lv(vg=vg)
|
||||||
|
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
lv.Lv.Resize(lv.LvCommon.SizeBytes, dbus.Array([], '(oii)'), -1, {})
|
lv.Lv.Resize(lv.LvCommon.SizeBytes, dbus.Array([], '(oii)'),
|
||||||
|
-1, {})
|
||||||
|
|
||||||
def test_lv_move(self):
|
def test_lv_move(self):
|
||||||
lv = self._create_lv()
|
lv = self._create_lv()
|
||||||
@ -625,8 +656,12 @@ class TestDbusService(unittest.TestCase):
|
|||||||
pv_path_move = str(lv.LvCommon.Devices[0][0])
|
pv_path_move = str(lv.LvCommon.Devices[0][0])
|
||||||
|
|
||||||
# Test moving a specific LV
|
# Test moving a specific LV
|
||||||
job = lv.Lv.Move(pv_path_move, (0, 0), dbus.Array([], '(oii)'), 0, {})
|
rc = self.handle_return(
|
||||||
self._wait_for_job(job)
|
lv.Lv.Move(
|
||||||
|
pv_path_move,
|
||||||
|
(0, 0),
|
||||||
|
dbus.Array([], '(oii)'), g_tmo, {}))
|
||||||
|
self.assertTrue(rc == '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
lv.update()
|
lv.update()
|
||||||
@ -638,12 +673,12 @@ class TestDbusService(unittest.TestCase):
|
|||||||
lv_p = self._create_lv()
|
lv_p = self._create_lv()
|
||||||
lv_p.update()
|
lv_p.update()
|
||||||
|
|
||||||
lv_p.Lv.Deactivate(0, -1, {})
|
self.handle_return(lv_p.Lv.Deactivate(0, g_tmo, {}))
|
||||||
lv_p.update()
|
lv_p.update()
|
||||||
self.assertFalse(lv_p.LvCommon.Active)
|
self.assertFalse(lv_p.LvCommon.Active)
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
lv_p.Lv.Activate(0, -1, {})
|
self.handle_return(lv_p.Lv.Activate(0, g_tmo, {}))
|
||||||
|
|
||||||
lv_p.update()
|
lv_p.update()
|
||||||
self.assertTrue(lv_p.LvCommon.Active)
|
self.assertTrue(lv_p.LvCommon.Active)
|
||||||
@ -651,7 +686,9 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
# Try control flags
|
# Try control flags
|
||||||
for i in range(0, 5):
|
for i in range(0, 5):
|
||||||
lv_p.Lv.Activate(1 << i, -1, {})
|
|
||||||
|
self.handle_return(lv_p.Lv.Activate(1 << i, g_tmo, {}))
|
||||||
|
|
||||||
self.assertTrue(lv_p.LvCommon.Active)
|
self.assertTrue(lv_p.LvCommon.Active)
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -661,8 +698,10 @@ class TestDbusService(unittest.TestCase):
|
|||||||
# Test moving without being LV specific
|
# Test moving without being LV specific
|
||||||
vg = ClientProxy(self.bus, lv.LvCommon.Vg).Vg
|
vg = ClientProxy(self.bus, lv.LvCommon.Vg).Vg
|
||||||
pv_to_move = str(lv.LvCommon.Devices[0][0])
|
pv_to_move = str(lv.LvCommon.Devices[0][0])
|
||||||
job = vg.Move(pv_to_move, (0, 0), dbus.Array([], '(oii)'), 0, {})
|
|
||||||
self._wait_for_job(job)
|
rc = self.handle_return(vg.Move(
|
||||||
|
pv_to_move, (0, 0), dbus.Array([], '(oii)'), 0, {}))
|
||||||
|
self.assertEqual(rc, '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
# Test Vg.Move
|
# Test Vg.Move
|
||||||
@ -680,10 +719,11 @@ class TestDbusService(unittest.TestCase):
|
|||||||
# Fetch the destination
|
# Fetch the destination
|
||||||
pv = ClientProxy(self.bus, dst).Pv
|
pv = ClientProxy(self.bus, dst).Pv
|
||||||
|
|
||||||
# Test range, move it to the middle of the new destination and blocking
|
# Test range, move it to the middle of the new destination
|
||||||
# blocking for it to complete
|
job = self.handle_return(
|
||||||
job = vg.Move(
|
vg.Move(
|
||||||
location, (0, 0), [(dst, pv.PeCount / 2, 0), ], -1, {})
|
location, (0, 0),
|
||||||
|
[(dst, pv.PeCount / 2, 0), ], g_tmo, {}))
|
||||||
self.assertEqual(job, '/')
|
self.assertEqual(job, '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -720,9 +760,10 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
vg_proxy.update()
|
vg_proxy.update()
|
||||||
if vg_proxy.Vg.FreeCount > 0:
|
if vg_proxy.Vg.FreeCount > 0:
|
||||||
obj_path, job = vg_proxy.Vg.LvCreateLinear(
|
job = self.handle_return(
|
||||||
rs(8, "_lv"), mib(4), False, -1, {})
|
vg_proxy.Vg.LvCreateLinear(
|
||||||
self.assertTrue(job == '/')
|
rs(8, "_lv"), mib(4), False, g_tmo, {}))
|
||||||
|
self.assertTrue(job != '/')
|
||||||
else:
|
else:
|
||||||
# We ran out of space, test will probably fail
|
# We ran out of space, test will probably fail
|
||||||
break
|
break
|
||||||
@ -777,14 +818,19 @@ class TestDbusService(unittest.TestCase):
|
|||||||
pvs.append(ClientProxy(self.bus, p).Pv)
|
pvs.append(ClientProxy(self.bus, p).Pv)
|
||||||
|
|
||||||
for tags_value in [['hello'], ['foo', 'bar']]:
|
for tags_value in [['hello'], ['foo', 'bar']]:
|
||||||
rc = vg.PvTagsAdd(vg.Pvs, tags_value, -1, {})
|
|
||||||
|
rc = self.handle_return(
|
||||||
|
vg.PvTagsAdd(vg.Pvs, tags_value, g_tmo, {}))
|
||||||
self.assertTrue(rc == '/')
|
self.assertTrue(rc == '/')
|
||||||
|
|
||||||
for p in pvs:
|
for p in pvs:
|
||||||
p.update()
|
p.update()
|
||||||
self.assertTrue(sorted(tags_value) == p.Tags)
|
self.assertTrue(sorted(tags_value) == p.Tags)
|
||||||
|
|
||||||
vg.PvTagsDel(vg.Pvs, tags_value, -1, {})
|
rc = self.handle_return(
|
||||||
|
vg.PvTagsDel(vg.Pvs, tags_value, g_tmo, {}))
|
||||||
|
self.assertEqual(rc, '/')
|
||||||
|
|
||||||
for p in pvs:
|
for p in pvs:
|
||||||
p.update()
|
p.update()
|
||||||
self.assertTrue([] == p.Tags)
|
self.assertTrue([] == p.Tags)
|
||||||
@ -794,10 +840,12 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
t = ['Testing', 'tags']
|
t = ['Testing', 'tags']
|
||||||
|
|
||||||
vg.TagsAdd(t, -1, {})
|
self.handle_return(vg.TagsAdd(t, g_tmo, {}))
|
||||||
|
|
||||||
vg.update()
|
vg.update()
|
||||||
self.assertTrue(t == vg.Tags)
|
self.assertTrue(t == vg.Tags)
|
||||||
vg.TagsDel(t, -1, {})
|
|
||||||
|
self.handle_return(vg.TagsDel(t, g_tmo, {}))
|
||||||
vg.update()
|
vg.update()
|
||||||
self.assertTrue([] == vg.Tags)
|
self.assertTrue([] == vg.Tags)
|
||||||
|
|
||||||
@ -805,15 +853,18 @@ class TestDbusService(unittest.TestCase):
|
|||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
lv = self._test_lv_create(
|
lv = self._test_lv_create(
|
||||||
vg.LvCreateLinear,
|
vg.LvCreateLinear,
|
||||||
(rs(8, '_lv'), mib(4), False, -1, {}),
|
(rs(8, '_lv'), mib(4), False, g_tmo, {}),
|
||||||
vg)
|
vg)
|
||||||
|
|
||||||
t = ['Testing', 'tags']
|
t = ['Testing', 'tags']
|
||||||
|
|
||||||
lv.Lv.TagsAdd(t, -1, {})
|
self.handle_return(
|
||||||
|
lv.Lv.TagsAdd(t, g_tmo, {}))
|
||||||
lv.update()
|
lv.update()
|
||||||
self.assertTrue(t == lv.LvCommon.Tags)
|
self.assertTrue(t == lv.LvCommon.Tags)
|
||||||
lv.Lv.TagsDel(t, -1, {})
|
|
||||||
|
self.handle_return(
|
||||||
|
lv.Lv.TagsDel(t, g_tmo, {}))
|
||||||
lv.update()
|
lv.update()
|
||||||
self.assertTrue([] == lv.LvCommon.Tags)
|
self.assertTrue([] == lv.LvCommon.Tags)
|
||||||
|
|
||||||
@ -821,7 +872,9 @@ class TestDbusService(unittest.TestCase):
|
|||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
|
|
||||||
for p in ['anywhere', 'contiguous', 'cling', 'normal']:
|
for p in ['anywhere', 'contiguous', 'cling', 'normal']:
|
||||||
rc = vg.AllocationPolicySet(p, -1, {})
|
rc = self.handle_return(
|
||||||
|
vg.AllocationPolicySet(p, g_tmo, {}))
|
||||||
|
|
||||||
self.assertEqual(rc, '/')
|
self.assertEqual(rc, '/')
|
||||||
vg.update()
|
vg.update()
|
||||||
|
|
||||||
@ -834,7 +887,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
# BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1280496
|
# BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1280496
|
||||||
# TODO: Add a test back for larger values here when bug is resolved
|
# TODO: Add a test back for larger values here when bug is resolved
|
||||||
for p in [0, 1, 10, 100, 100, 1024, 2 ** 32 - 1]:
|
for p in [0, 1, 10, 100, 100, 1024, 2 ** 32 - 1]:
|
||||||
rc = vg.MaxPvSet(p, -1, {})
|
rc = self.handle_return(
|
||||||
|
vg.MaxPvSet(p, g_tmo, {}))
|
||||||
self.assertEqual(rc, '/')
|
self.assertEqual(rc, '/')
|
||||||
vg.update()
|
vg.update()
|
||||||
self.assertTrue(vg.MaxPv == p, "Expected %s != Actual %s" %
|
self.assertTrue(vg.MaxPv == p, "Expected %s != Actual %s" %
|
||||||
@ -846,7 +900,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
# BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1280496
|
# BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1280496
|
||||||
# TODO: Add a test back for larger values here when bug is resolved
|
# TODO: Add a test back for larger values here when bug is resolved
|
||||||
for p in [0, 1, 10, 100, 100, 1024, 2 ** 32 - 1]:
|
for p in [0, 1, 10, 100, 100, 1024, 2 ** 32 - 1]:
|
||||||
rc = vg.MaxLvSet(p, -1, {})
|
rc = self.handle_return(vg.MaxLvSet(p, g_tmo, {}))
|
||||||
self.assertEqual(rc, '/')
|
self.assertEqual(rc, '/')
|
||||||
vg.update()
|
vg.update()
|
||||||
self.assertTrue(vg.MaxLv == p, "Expected %s != Actual %s" %
|
self.assertTrue(vg.MaxLv == p, "Expected %s != Actual %s" %
|
||||||
@ -861,7 +915,7 @@ class TestDbusService(unittest.TestCase):
|
|||||||
if False:
|
if False:
|
||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
prev_uuid = vg.Uuid
|
prev_uuid = vg.Uuid
|
||||||
rc = vg.UuidGenerate(-1, {})
|
rc = self.handle_return(vg.UuidGenerate(g_tmo, {}))
|
||||||
self.assertEqual(rc, '/')
|
self.assertEqual(rc, '/')
|
||||||
vg.update()
|
vg.update()
|
||||||
self.assertTrue(vg.Uuid != prev_uuid, "Expected %s != Actual %s" %
|
self.assertTrue(vg.Uuid != prev_uuid, "Expected %s != Actual %s" %
|
||||||
@ -871,20 +925,23 @@ class TestDbusService(unittest.TestCase):
|
|||||||
vg = self._vg_create().Vg
|
vg = self._vg_create().Vg
|
||||||
self._test_lv_create(
|
self._test_lv_create(
|
||||||
vg.LvCreateLinear,
|
vg.LvCreateLinear,
|
||||||
(rs(8, '_lv'), mib(4), False, -1, {}),
|
(rs(8, '_lv'), mib(4), False, g_tmo, {}),
|
||||||
vg)
|
vg)
|
||||||
|
|
||||||
vg.update()
|
vg.update()
|
||||||
|
|
||||||
vg.Deactivate(0, -1, {})
|
rc = self.handle_return(vg.Deactivate(0, g_tmo, {}))
|
||||||
|
self.assertEqual(rc, '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
vg.Activate(0, -1, {})
|
rc = self.handle_return(vg.Activate(0, g_tmo, {}))
|
||||||
|
|
||||||
|
self.assertEqual(rc, '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
# Try control flags
|
# Try control flags
|
||||||
for i in range(0, 5):
|
for i in range(0, 5):
|
||||||
vg.Activate(1 << i, -1, {})
|
self.handle_return(vg.Activate(1 << i, g_tmo, {}))
|
||||||
|
|
||||||
def test_pv_resize(self):
|
def test_pv_resize(self):
|
||||||
|
|
||||||
@ -897,12 +954,13 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
new_size = original_size / 2
|
new_size = original_size / 2
|
||||||
|
|
||||||
pv.ReSize(new_size, -1, {})
|
self.handle_return(pv.ReSize(new_size, g_tmo, {}))
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
pv.update()
|
pv.update()
|
||||||
|
|
||||||
self.assertTrue(pv.SizeBytes != original_size)
|
self.assertTrue(pv.SizeBytes != original_size)
|
||||||
pv.ReSize(0, -1, {})
|
self.handle_return(pv.ReSize(0, g_tmo, {}))
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
pv.update()
|
pv.update()
|
||||||
self.assertTrue(pv.SizeBytes == original_size)
|
self.assertTrue(pv.SizeBytes == original_size)
|
||||||
@ -917,11 +975,14 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
pv = ClientProxy(self.bus, vg.Pvs[0]).Pv
|
pv = ClientProxy(self.bus, vg.Pvs[0]).Pv
|
||||||
|
|
||||||
pv.AllocationEnabled(False, -1, {})
|
self.handle_return(pv.AllocationEnabled(False, g_tmo, {}))
|
||||||
|
|
||||||
pv.update()
|
pv.update()
|
||||||
self.assertFalse(pv.Allocatable)
|
self.assertFalse(pv.Allocatable)
|
||||||
|
|
||||||
pv.AllocationEnabled(True, -1, {})
|
self.handle_return(pv.AllocationEnabled(True, g_tmo, {}))
|
||||||
|
|
||||||
|
self.handle_return(pv.AllocationEnabled(True, g_tmo, {}))
|
||||||
pv.update()
|
pv.update()
|
||||||
self.assertTrue(pv.Allocatable)
|
self.assertTrue(pv.Allocatable)
|
||||||
|
|
||||||
@ -938,24 +999,30 @@ class TestDbusService(unittest.TestCase):
|
|||||||
mgr = self._manager().Manager
|
mgr = self._manager().Manager
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
mgr.PvScan(
|
self.handle_return(
|
||||||
False, True, dbus.Array([], 's'),
|
mgr.PvScan(False, True, dbus.Array([], 's'),
|
||||||
dbus.Array([], '(ii)'), -1, {}), '/')
|
dbus.Array([], '(ii)'), g_tmo, {})), '/')
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
mgr.PvScan(
|
self.handle_return(
|
||||||
False, False,
|
mgr.PvScan(
|
||||||
dbus.Array([], 's'),
|
False, False,
|
||||||
dbus.Array([], '(ii)'), -1, {}), '/')
|
dbus.Array([], 's'),
|
||||||
|
dbus.Array([], '(ii)'), g_tmo, {})), '/')
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
block_path = []
|
block_path = []
|
||||||
for d in devices:
|
for d in devices:
|
||||||
block_path.append(d['DEVNAME'])
|
block_path.append(d['DEVNAME'])
|
||||||
|
|
||||||
self.assertEqual(mgr.PvScan(False, True,
|
self.assertEqual(
|
||||||
block_path,
|
self.handle_return(
|
||||||
dbus.Array([], '(ii)'), -1, {}), '/')
|
mgr.PvScan(
|
||||||
|
False, True,
|
||||||
|
block_path,
|
||||||
|
dbus.Array([], '(ii)'), g_tmo, {})), '/')
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@ -963,18 +1030,23 @@ class TestDbusService(unittest.TestCase):
|
|||||||
for d in devices:
|
for d in devices:
|
||||||
mm.append((int(d['MAJOR']), int(d['MINOR'])))
|
mm.append((int(d['MAJOR']), int(d['MINOR'])))
|
||||||
|
|
||||||
self.assertEqual(mgr.PvScan(False, True,
|
self.assertEqual(
|
||||||
block_path,
|
|
||||||
mm, -1, {}), '/')
|
self.handle_return(
|
||||||
|
mgr.PvScan
|
||||||
|
(False, True,
|
||||||
|
block_path,
|
||||||
|
mm, g_tmo, {})
|
||||||
|
), '/')
|
||||||
|
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
mgr.PvScan(
|
self.handle_return(
|
||||||
False, True,
|
mgr.PvScan(
|
||||||
dbus.Array([], 's'),
|
False, True,
|
||||||
mm, -1, {}), '/')
|
dbus.Array([], 's'),
|
||||||
|
mm, g_tmo, {})), '/')
|
||||||
self.assertEqual(self._refresh(), 0)
|
self.assertEqual(self._refresh(), 0)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -994,32 +1066,37 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
lv_p = self._create_lv(size=mib(16))
|
lv_p = self._create_lv(size=mib(16))
|
||||||
ss_name = lv_p.LvCommon.Name + '_snap'
|
ss_name = lv_p.LvCommon.Name + '_snap'
|
||||||
snapshot_path = lv_p.Lv.Snapshot(ss_name, ss_size, -1, {})[0]
|
|
||||||
|
snapshot_path = self.handle_return(
|
||||||
|
lv_p.Lv.Snapshot(ss_name, ss_size, g_tmo, {}))
|
||||||
|
|
||||||
ss = ClientProxy(self.bus, snapshot_path)
|
ss = ClientProxy(self.bus, snapshot_path)
|
||||||
|
|
||||||
# Write some data to snapshot so merge takes some time
|
# Write some data to snapshot so merge takes some time
|
||||||
TestDbusService._write_some_data(ss.LvCommon.Path, ss_size / 2)
|
TestDbusService._write_some_data(ss.LvCommon.Path, ss_size / 2)
|
||||||
|
|
||||||
job_path = ss.Snapshot.Merge(0, {})
|
job_path = self.handle_return(ss.Snapshot.Merge(g_tmo, {}))
|
||||||
|
self.assertEqual(job_path, '/')
|
||||||
self.assertTrue(job_path != '/')
|
|
||||||
self._wait_for_job(job_path)
|
|
||||||
|
|
||||||
def test_snapshot_merge_thin(self):
|
def test_snapshot_merge_thin(self):
|
||||||
# Create a thin LV, snapshot it and merge it
|
# Create a thin LV, snapshot it and merge it
|
||||||
tp = self._create_lv(True)
|
tp = self._create_lv(True)
|
||||||
|
|
||||||
thin_path = tp.ThinPool.LvCreate(
|
thin_path = self.handle_return(
|
||||||
rs(10, '_thin_lv'), mib(10), -1, {})[0]
|
tp.ThinPool.LvCreate(
|
||||||
|
rs(10, '_thin_lv'), mib(10), g_tmo, {}))
|
||||||
|
|
||||||
lv_p = ClientProxy(self.bus, thin_path)
|
lv_p = ClientProxy(self.bus, thin_path)
|
||||||
|
|
||||||
ss_name = lv_p.LvCommon.Name + '_snap'
|
ss_name = lv_p.LvCommon.Name + '_snap'
|
||||||
snapshot_path = lv_p.Lv.Snapshot(ss_name, 0, -1, {})[0]
|
snapshot_path = self.handle_return(
|
||||||
|
lv_p.Lv.Snapshot(ss_name, 0, g_tmo, {}))
|
||||||
|
|
||||||
ss = ClientProxy(self.bus, snapshot_path)
|
ss = ClientProxy(self.bus, snapshot_path)
|
||||||
job_path = ss.Snapshot.Merge(0, {})
|
job_path = self.handle_return(
|
||||||
self.assertTrue(job_path != '/')
|
ss.Snapshot.Merge(g_tmo, {})
|
||||||
self._wait_for_job(job_path)
|
)
|
||||||
|
self.assertTrue(job_path == '/')
|
||||||
|
|
||||||
def _create_cache_pool(self, vg=None):
|
def _create_cache_pool(self, vg=None):
|
||||||
|
|
||||||
@ -1029,8 +1106,9 @@ class TestDbusService(unittest.TestCase):
|
|||||||
md = self._create_lv(size=(mib(8)), vg=vg)
|
md = self._create_lv(size=(mib(8)), vg=vg)
|
||||||
data = self._create_lv(size=(mib(8)), vg=vg)
|
data = self._create_lv(size=(mib(8)), vg=vg)
|
||||||
|
|
||||||
cache_pool_path = vg.CreateCachePool(
|
cache_pool_path = self.handle_return(
|
||||||
md.object_path, data.object_path, -1, {})[0]
|
vg.CreateCachePool(
|
||||||
|
md.object_path, data.object_path, g_tmo, {}))
|
||||||
|
|
||||||
cp = ClientProxy(self.bus, cache_pool_path)
|
cp = ClientProxy(self.bus, cache_pool_path)
|
||||||
|
|
||||||
@ -1050,24 +1128,32 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
lv_to_cache = self._create_lv(size=mib(8), vg=vg)
|
lv_to_cache = self._create_lv(size=mib(8), vg=vg)
|
||||||
|
|
||||||
c_lv_path = cache_pool.CachePool.CacheLv(
|
c_lv_path = self.handle_return(
|
||||||
lv_to_cache.object_path, -1, {})[0]
|
cache_pool.CachePool.CacheLv(
|
||||||
|
lv_to_cache.object_path, g_tmo, {}))
|
||||||
|
|
||||||
cached_lv = ClientProxy(self.bus, c_lv_path)
|
cached_lv = ClientProxy(self.bus, c_lv_path)
|
||||||
|
|
||||||
uncached_lv_path = \
|
uncached_lv_path = self.handle_return(
|
||||||
cached_lv.CachedLv.DetachCachePool(destroy_cache, -1, {})[0]
|
cached_lv.CachedLv.DetachCachePool(
|
||||||
|
destroy_cache, g_tmo, {}))
|
||||||
|
|
||||||
self.assertTrue('/com/redhat/lvmdbus1/Lv' in
|
self.assertTrue('/com/redhat/lvmdbus1/Lv' in
|
||||||
uncached_lv_path)
|
uncached_lv_path)
|
||||||
|
|
||||||
vg.Remove(-1, {})
|
rc = self.handle_return(vg.Remove(g_tmo, {}))
|
||||||
|
self.assertTrue(rc == '/')
|
||||||
|
|
||||||
def test_vg_change(self):
|
def test_vg_change(self):
|
||||||
vg_proxy = self._vg_create()
|
vg_proxy = self._vg_create()
|
||||||
result = vg_proxy.Vg.Change(-1, {'-a': 'ay'})
|
|
||||||
|
result = self.handle_return(vg_proxy.Vg.Change(
|
||||||
|
g_tmo, {'-a': 'ay'}))
|
||||||
self.assertTrue(result == '/')
|
self.assertTrue(result == '/')
|
||||||
result = vg_proxy.Vg.Change(-1, {'-a': 'n'})
|
|
||||||
|
result = self.handle_return(
|
||||||
|
vg_proxy.Vg.Change(g_tmo, {'-a': 'n'})
|
||||||
|
)
|
||||||
self.assertTrue(result == '/')
|
self.assertTrue(result == '/')
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -1081,7 +1167,8 @@ class TestDbusService(unittest.TestCase):
|
|||||||
|
|
||||||
# Pv device path
|
# Pv device path
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
mgr.PvCreate("/dev/space in name", -1, {})
|
self.handle_return(
|
||||||
|
mgr.PvCreate("/dev/space in name", g_tmo, {}))
|
||||||
|
|
||||||
# VG Name testing...
|
# VG Name testing...
|
||||||
# Go through all bad characters
|
# Go through all bad characters
|
||||||
@ -1089,37 +1176,48 @@ class TestDbusService(unittest.TestCase):
|
|||||||
bad_chars = TestDbusService._invalid_vg_lv_name_characters()
|
bad_chars = TestDbusService._invalid_vg_lv_name_characters()
|
||||||
for c in bad_chars:
|
for c in bad_chars:
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
mgr.VgCreate("name%s" % (c), pv_paths, -1, {})
|
self.handle_return(
|
||||||
|
mgr.VgCreate("name%s" % (c), pv_paths, g_tmo, {}))
|
||||||
|
|
||||||
# Bad names
|
# Bad names
|
||||||
for bad in [".", ".."]:
|
for bad in [".", ".."]:
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
mgr.VgCreate(bad, pv_paths, -1, {})
|
self.handle_return(
|
||||||
|
mgr.VgCreate(bad, pv_paths, g_tmo, {}))
|
||||||
|
|
||||||
# Exceed name length
|
# Exceed name length
|
||||||
for i in [128, 1024, 4096]:
|
for i in [128, 1024, 4096]:
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
mgr.VgCreate('T' * i, pv_paths, -1, {})
|
self.handle_return(
|
||||||
|
mgr.VgCreate('T' * i, pv_paths, g_tmo, {}))
|
||||||
|
|
||||||
# Create a VG and try to create LVs with different bad names
|
# Create a VG and try to create LVs with different bad names
|
||||||
vg_path = mgr.VgCreate("test", pv_paths, -1, {})[0]
|
vg_path = self.handle_return(
|
||||||
|
mgr.VgCreate("test", pv_paths, g_tmo, {}))
|
||||||
|
|
||||||
vg_proxy = ClientProxy(self.bus, vg_path)
|
vg_proxy = ClientProxy(self.bus, vg_path)
|
||||||
|
|
||||||
for c in bad_chars:
|
for c in bad_chars:
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
vg_proxy.Vg.LvCreateLinear(rs(8, '_lv') + c,
|
self.handle_return(
|
||||||
mib(4), False, -1, {})
|
vg_proxy.Vg.LvCreateLinear(
|
||||||
|
rs(8, '_lv') + c,
|
||||||
|
mib(4), False, g_tmo, {}))
|
||||||
|
|
||||||
for r in ("_cdata", "_cmeta", "_corig", "_mimage", "_mlog",
|
for r in ("_cdata", "_cmeta", "_corig", "_mimage", "_mlog",
|
||||||
"_pmspare", "_rimage", "_rmeta", "_tdata", "_tmeta", "_vorigin"):
|
"_pmspare", "_rimage", "_rmeta", "_tdata", "_tmeta", "_vorigin"):
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
vg_proxy.Vg.LvCreateLinear(rs(8, '_lv') + r,
|
self.handle_return(
|
||||||
mib(4), False, -1, {})
|
vg_proxy.Vg.LvCreateLinear(
|
||||||
|
rs(8, '_lv') + r,
|
||||||
|
mib(4), False, g_tmo, {}))
|
||||||
|
|
||||||
for r in ("snapshot", "pvmove"):
|
for r in ("snapshot", "pvmove"):
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
vg_proxy.Vg.LvCreateLinear(r + rs(8, '_lv'),
|
self.handle_return(
|
||||||
mib(4), False, -1, {})
|
vg_proxy.Vg.LvCreateLinear(
|
||||||
|
r + rs(8, '_lv'),
|
||||||
|
mib(4), False, g_tmo, {}))
|
||||||
|
|
||||||
_ALLOWABLE_TAG_CH = string.ascii_letters + string.digits + "._-+/=!:&#"
|
_ALLOWABLE_TAG_CH = string.ascii_letters + string.digits + "._-+/=!:&#"
|
||||||
|
|
||||||
@ -1131,27 +1229,35 @@ class TestDbusService(unittest.TestCase):
|
|||||||
mgr = self.objs[MANAGER_INT][0].Manager
|
mgr = self.objs[MANAGER_INT][0].Manager
|
||||||
pv_paths = [self.objs[PV_INT][0].object_path]
|
pv_paths = [self.objs[PV_INT][0].object_path]
|
||||||
|
|
||||||
vg_path = mgr.VgCreate("test", pv_paths, -1, {})[0]
|
vg_path = self.handle_return(
|
||||||
|
mgr.VgCreate("test", pv_paths, g_tmo, {}))
|
||||||
vg_proxy = ClientProxy(self.bus, vg_path)
|
vg_proxy = ClientProxy(self.bus, vg_path)
|
||||||
|
|
||||||
for c in self._invalid_tag_characters():
|
for c in self._invalid_tag_characters():
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
vg_proxy.Vg.TagsAdd([c], -1, {})
|
self.handle_return(
|
||||||
|
vg_proxy.Vg.TagsAdd(
|
||||||
|
[c], g_tmo, {}))
|
||||||
|
|
||||||
for c in self._invalid_tag_characters():
|
for c in self._invalid_tag_characters():
|
||||||
with self.assertRaises(dbus.exceptions.DBusException):
|
with self.assertRaises(dbus.exceptions.DBusException):
|
||||||
vg_proxy.Vg.TagsAdd(["a%sb" % (c)], -1, {})
|
self.handle_return(
|
||||||
|
vg_proxy.Vg.TagsAdd(
|
||||||
|
["a%sb" % (c)], g_tmo, {}))
|
||||||
|
|
||||||
def test_tag_names(self):
|
def test_tag_names(self):
|
||||||
mgr = self.objs[MANAGER_INT][0].Manager
|
mgr = self.objs[MANAGER_INT][0].Manager
|
||||||
pv_paths = [self.objs[PV_INT][0].object_path]
|
pv_paths = [self.objs[PV_INT][0].object_path]
|
||||||
|
|
||||||
vg_path = mgr.VgCreate("test", pv_paths, -1, {})[0]
|
vg_path = self.handle_return(
|
||||||
|
mgr.VgCreate("test", pv_paths, g_tmo, {}))
|
||||||
vg_proxy = ClientProxy(self.bus, vg_path)
|
vg_proxy = ClientProxy(self.bus, vg_path)
|
||||||
|
|
||||||
for i in range(1, 64):
|
for i in range(1, 64):
|
||||||
tag = rs(i, "", self._ALLOWABLE_TAG_CH)
|
tag = rs(i, "", self._ALLOWABLE_TAG_CH)
|
||||||
r = vg_proxy.Vg.TagsAdd([tag], -1, {})
|
|
||||||
|
r = self.handle_return(
|
||||||
|
vg_proxy.Vg.TagsAdd([tag], g_tmo, {}))
|
||||||
self.assertTrue(r == '/')
|
self.assertTrue(r == '/')
|
||||||
vg_proxy.update()
|
vg_proxy.update()
|
||||||
|
|
||||||
@ -1165,12 +1271,15 @@ class TestDbusService(unittest.TestCase):
|
|||||||
mgr = self.objs[MANAGER_INT][0].Manager
|
mgr = self.objs[MANAGER_INT][0].Manager
|
||||||
pv_paths = [self.objs[PV_INT][0].object_path]
|
pv_paths = [self.objs[PV_INT][0].object_path]
|
||||||
|
|
||||||
vg_path = mgr.VgCreate("test", pv_paths, -1, {})[0]
|
vg_path = self.handle_return(
|
||||||
|
mgr.VgCreate("test", pv_paths, g_tmo, {}))
|
||||||
vg_proxy = ClientProxy(self.bus, vg_path)
|
vg_proxy = ClientProxy(self.bus, vg_path)
|
||||||
|
|
||||||
tag = '--h/K.6g0A4FOEatf3+k_nI/Yp&L_u2oy-=j649x:+dUcYWPEo6.IWT0c'
|
tag = '--h/K.6g0A4FOEatf3+k_nI/Yp&L_u2oy-=j649x:+dUcYWPEo6.IWT0c'
|
||||||
|
|
||||||
r = vg_proxy.Vg.TagsAdd([tag], -1, {})
|
r = self.handle_return(
|
||||||
|
vg_proxy.Vg.TagsAdd([tag], g_tmo, {})
|
||||||
|
)
|
||||||
self.assertTrue(r == '/')
|
self.assertTrue(r == '/')
|
||||||
vg_proxy.update()
|
vg_proxy.update()
|
||||||
|
|
||||||
@ -1190,9 +1299,14 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
print('\n *** Testing fork & exec *** \n')
|
print('\n *** Testing fork & exec *** \n')
|
||||||
unittest.main(exit=False)
|
unittest.main(exit=False)
|
||||||
|
g_tmo = 15
|
||||||
|
unittest.main(exit=False)
|
||||||
# Test lvm shell
|
# Test lvm shell
|
||||||
print('\n *** Testing lvm shell *** \n')
|
print('\n *** Testing lvm shell *** \n')
|
||||||
if set_execution(True):
|
if set_execution(True):
|
||||||
|
g_tmo = 0
|
||||||
|
unittest.main(exit=False)
|
||||||
|
g_tmo = 15
|
||||||
unittest.main()
|
unittest.main()
|
||||||
else:
|
else:
|
||||||
print("WARNING: Unable to dynamically configure "
|
print("WARNING: Unable to dynamically configure "
|
||||||
|
Loading…
Reference in New Issue
Block a user