master - lvmdbusd: Initial unit test driver script
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=05eb87ca2defb6...
Commit: 05eb87ca2defb6e7e7bd9759bab566de7cb6e3f0
Parent: ecc040688601ec0f4b35f4250e057db13fd847a0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 16:05:43 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbusd: Initial unit test driver script
It's disabled until we can fix it up.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/api/dbustest.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/test/api/dbustest.sh b/test/api/dbustest.sh
new file mode 100644
index 0000000..f33add0
--- /dev/null
+++ b/test/api/dbustest.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+# Copyright (C) 2016 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+SKIP_WITH_CLVMD=1
+
+. lib/inittest
+
+# Will default to skip until we can get this reviewed
+skip
+
+aux prepare_pvs 6
+
+# This allows us to run without installing
+# com.redhat.lvmdbus1.conf to /etc/dbus-1/system.d/
+# but in normal operation it needs to be on system bus
+export LVMDBUSD_USE_SESSION="True"
+
+# Setup the python path so we can run
+export PYTHONPATH=$abs_top_builddir/daemons
+
+# Where should we be logging the output of the daemon when not running as
+# a systemd service
+# Start the dbus service
+$abs_top_builddir/daemons/lvmdbusd/lvmdbusd --debug --udev > /tmp/lvmdbusd.log 2>&1 &
+
+# Give the service some time to start before we try to run the
+# unit test
+sleep 1
+
+LVM_DBUS_PID=$(ps aux | grep lvmdbus[d] | awk '{print $2}')
+if [ "CHK${LVM_DBUS_PID}" == "CHK" ];then
+ echo "Failed to start lsmdbusd daemon"
+ exit 1
+fi
+
+# Run all the unit tests
+# Are we already logging stdout & stderror?
+$abs_top_builddir/test/dbus/lvmdbustest.py -v > /tmp/lvmdbustest.log 2>&1
+
+# We can run individual unit tests by doing this
+# $abs_top_builddir/test/dbus/lvmdbustest.py -v TestDbusService.test_snapshot_merge
+
+# I'm guessing there is a better way to handle this with the built in test env.
+if [ $? -eq 0 ]; then
+ rm -f /tmp/lvmdbusd.log
+ rm -f /tmp/lvmdbustest.log
+fi
+
+echo "Stopping service"
+kill $LVM_DBUS_PID
8 years, 2 months
master - lvmdbusd: Remove unlimited retries
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ecc040688601ec...
Commit: ecc040688601ec0f4b35f4250e057db13fd847a0
Parent: 21034644b6582a6d9ad571ff51cc57ad5e08b9ff
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 15:53:31 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbusd: Remove unlimited retries
Change while to for loop to prevent the daemon from getting stuck
when lvm is messed up.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/cmdhandler.py | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index 83feb0a..370fb61 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -388,6 +388,9 @@ def lv_detach_cache(lv_full_name, detach_options, destroy_cache):
def pv_retrieve_with_segs(device=None):
d = []
+ err = ""
+ out = ""
+ rc = 0
columns = ['pv_name', 'pv_uuid', 'pv_fmt', 'pv_size', 'pv_free',
'pv_used', 'dev_size', 'pv_mda_size', 'pv_mda_free',
@@ -398,7 +401,7 @@ def pv_retrieve_with_segs(device=None):
# Lvm has some issues where it returns failure when querying pvs when other
# operations are in process, see:
# https://bugzilla.redhat.com/show_bug.cgi?id=1274085
- while True:
+ for i in range(0, 10):
cmd = _dc('pvs', ['-o', ','.join(columns)])
if device:
@@ -413,6 +416,13 @@ def pv_retrieve_with_segs(device=None):
time.sleep(0.2)
log_debug("LVM Bug workaround, retrying pvs command...")
+ if rc != 0:
+ msg = "We were unable to get pvs to return without error after " \
+ "trying 10 times, RC=%d, STDERR=(%s), STDOUT=(%s)" % \
+ (rc, err, out)
+ log_error(msg)
+ raise RuntimeError(msg)
+
return d
8 years, 2 months
master - lvmdbusd: Add env variable to use session bus
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=21034644b6582a...
Commit: 21034644b6582a6d9ad571ff51cc57ad5e08b9ff
Parent: 64aab5885d7afdbd63979b6f8520564ad2eb59ac
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 14:28:11 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbusd: Add env variable to use session bus
export LVMDBUSD_SESSION=True to run on the session bus instead
of the system bus so that we can run the unit test without
installing the dbus conf file.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/main.py | 9 ++++++++-
test/dbus/lvmdbustest.py | 7 ++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 43545b2..c9211f7 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -28,6 +28,7 @@ import sys
from . import udevwatch
from .utils import log_debug
import argparse
+import os
class Lvm(objectmanager.ObjectManager):
@@ -71,6 +72,8 @@ def main():
help="Dump debug messages", default=False,
dest='debug')
+ use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
+
args = parser.parse_args()
cfg.DEBUG = args.debug
@@ -90,7 +93,11 @@ def main():
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
GObject.threads_init()
dbus.mainloop.glib.threads_init()
- cfg.bus = dbus.SystemBus()
+
+ if use_session:
+ cfg.bus = dbus.SessionBus()
+ else:
+ cfg.bus = dbus.SystemBus()
# The base name variable needs to exist for things to work.
# noinspection PyUnusedLocal
base_name = dbus.service.BusName(BASE_INTERFACE, cfg.bus)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 16fffdf..92f5d70 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -44,7 +44,12 @@ def rs(length, suffix, character_set=string.ascii_lowercase):
for _ in range(length)) + suffix
-bus = dbus.SystemBus(mainloop=DBusGMainLoop())
+use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
+
+if use_session:
+ bus = dbus.SessionBus(mainloop=DBusGMainLoop())
+else:
+ bus = dbus.SystemBus(mainloop=DBusGMainLoop())
def mib(s):
8 years, 2 months
master - lvmdbus: Make unit tests work in test env
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=64aab5885d7afd...
Commit: 64aab5885d7afdbd63979b6f8520564ad2eb59ac
Parent: 70d0b210e17884ab8cfc5f2a9be90461afb993c7
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 14:03:31 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbus: Make unit tests work in test env
Reduced the size of LVs created and use actual PE numbers instead of hard
coding them to allow us to work with the loop back devices.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/dbus/lvmdbustest.py | 80 +++++++++++++++++++++++++++-------------------
1 files changed, 47 insertions(+), 33 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index bdeb1a3..16fffdf 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -47,6 +47,10 @@ def rs(length, suffix, character_set=string.ascii_lowercase):
bus = dbus.SystemBus(mainloop=DBusGMainLoop())
+def mib(s):
+ return 1024 * 1024 * s
+
+
class DbusIntrospection(object):
@staticmethod
def introspect(xml_representation):
@@ -368,7 +372,7 @@ class TestDbusService(unittest.TestCase):
# Create some LVs in the VG
for i in range(0, 5):
- lv_t = self._create_lv(size=1024 * 1024 * 16, vg=vg)
+ lv_t = self._create_lv(size=mib(4), vg=vg)
full_name = "%s/%s" % (vg_name_start, lv_t.LvCommon.Name)
lv_path = mgr.LookUpByLvmId(full_name)
self.assertTrue(lv_path == lv_t.object_path)
@@ -432,10 +436,10 @@ class TestDbusService(unittest.TestCase):
# Let's create a thin pool which uses a raid 5 meta and raid5 data
# areas
lv_meta_path = vg.LvCreateRaid(
- "meta_r5", "raid5", 1024 * 1024 * 16, 0, 0, -1, {})[0]
+ "meta_r5", "raid5", mib(4), 0, 0, -1, {})[0]
lv_data_path = vg.LvCreateRaid(
- "data_r5", "raid5", 1024 * 1024 * 512, 0, 0, -1, {})[0]
+ "data_r5", "raid5", mib(16), 0, 0, -1, {})[0]
thin_pool_path = vg.CreateThinPool(
lv_meta_path, lv_data_path, -1, {})[0]
@@ -450,7 +454,7 @@ class TestDbusService(unittest.TestCase):
lv_name = rs(8, '_lv')
thin_lv_path = thin_pool.ThinPool.LvCreate(
- lv_name, 1024 * 1024 * 16, -1, {})[0]
+ lv_name, mib(16), -1, {})[0]
self.assertTrue(thin_lv_path != '/')
@@ -504,7 +508,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create().Vg
self._test_lv_create(
vg.LvCreate,
- (rs(8, '_lv'), 1024 * 1024 * 4,
+ (rs(8, '_lv'), mib(4),
dbus.Array([], '(ott)'), -1, {}), vg)
def test_lv_create_linear(self):
@@ -512,7 +516,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create().Vg
self._test_lv_create(
vg.LvCreateLinear,
- (rs(8, '_lv'), 1024 * 1024 * 4, False, -1, {}), vg)
+ (rs(8, '_lv'), mib(4), False, -1, {}), vg)
def test_lv_create_striped(self):
pv_paths = []
@@ -522,7 +526,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create(pv_paths).Vg
self._test_lv_create(
vg.LvCreateStriped,
- (rs(8, '_lv'), 1024 * 1024 * 4, 2, 8, False,
+ (rs(8, '_lv'), mib(4), 2, 8, False,
-1, {}), vg)
def test_lv_create_mirror(self):
@@ -532,7 +536,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create(pv_paths).Vg
self._test_lv_create(vg.LvCreateMirror,
- (rs(8, '_lv'), 1024 * 1024 * 4, 2, -1, {}), vg)
+ (rs(8, '_lv'), mib(4), 2, -1, {}), vg)
def test_lv_create_raid(self):
pv_paths = []
@@ -542,7 +546,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create(pv_paths).Vg
self._test_lv_create(vg.LvCreateRaid,
(rs(8, '_lv'), 'raid4',
- 1024 * 1024 * 16, 2, 8, -1, {}), vg)
+ mib(16), 2, 8, -1, {}), vg)
def _create_lv(self, thinpool=False, size=None, vg=None):
@@ -554,14 +558,14 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create(pv_paths).Vg
if size is None:
- size = 1024 * 1024 * 128
+ size = mib(4)
return self._test_lv_create(
vg.LvCreateLinear,
(rs(8, '_lv'), size, thinpool, -1, {}), vg)
def test_lv_create_rounding(self):
- self._create_lv(size=1024 * 1024 * 2 + 13)
+ self._create_lv(size=(mib(2) + 13))
def test_lv_create_thin_pool(self):
self._create_lv(True)
@@ -602,7 +606,7 @@ class TestDbusService(unittest.TestCase):
tp = self._create_lv(True)
thin_path = tp.ThinPool.LvCreate(
- rs(10, '_thin_lv'), 1024 * 1024 * 10, -1, {})[0]
+ rs(10, '_thin_lv'), mib(8), -1, {})[0]
lv = ClientProxy(self.bus, thin_path)
rc = lv.Lv.Rename('rename_test' + lv.LvCommon.Name, -1, {})
@@ -668,9 +672,11 @@ class TestDbusService(unittest.TestCase):
pv = vg.Pvs
- self._test_lv_create(vg.LvCreate,
- (rs(8, '_lv'), 1024 * 1024 * 4,
- dbus.Array([[pv[0], 0, 100]], '(ott)'), -1, {}), vg)
+ pv_proxy = ClientProxy(self.bus, pv[0])
+
+ self._test_lv_create(vg.LvCreate, (rs(8, '_lv'), mib(4),
+ dbus.Array([[pv_proxy.object_path, 0, (pv_proxy.Pv.PeCount - 1)]],
+ '(ott)'), -1, {}), vg)
def test_lv_resize(self):
@@ -679,7 +685,7 @@ class TestDbusService(unittest.TestCase):
pv_paths.append(pp.object_path)
vg = self._vg_create(pv_paths).Vg
- lv = self._create_lv(vg=vg)
+ lv = self._create_lv(vg=vg, size=mib(16))
for size in [
lv.LvCommon.SizeBytes + 4194304,
@@ -694,8 +700,10 @@ class TestDbusService(unittest.TestCase):
prev = lv.LvCommon.SizeBytes
if len(pv_empty):
+ p = ClientProxy(self.bus, pv_empty[0])
rc = lv.Lv.Resize(
- size, dbus.Array([[pv_empty[0], 0, 100]], '(oii)'),
+ size,
+ dbus.Array([[p.object_path, 0, p.Pv.PeCount - 1]], '(oii)'),
-1, {})
else:
rc = lv.Lv.Resize(size, dbus.Array([], '(oii)'), -1, {})
@@ -817,17 +825,23 @@ class TestDbusService(unittest.TestCase):
# add a number of LVs and then remove the VG and all the contained
# LVs which appears to consistently run a little slow.
- vg = self._vg_create(pv_paths).Vg
+ vg_proxy = self._vg_create(pv_paths)
for i in range(0, num_lvs):
- obj_path, job = vg.LvCreateLinear(
- rs(8, "_lv"), 1024 * 1024 * 4, False, -1, {})
- self.assertTrue(job == '/')
+
+ vg_proxy.update()
+ if vg_proxy.Vg.FreeCount > 0:
+ obj_path, job = vg_proxy.Vg.LvCreateLinear(
+ rs(8, "_lv"), mib(4), False, -1, {})
+ self.assertTrue(job == '/')
+ else:
+ # We ran out of space, test will probably fail
+ break
# Make sure that we are honoring the timeout
start = time.time()
- remove_job = vg.Remove(1, {})
+ remove_job = vg_proxy.Vg.Remove(1, {})
end = time.time()
@@ -902,7 +916,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create().Vg
lv = self._test_lv_create(
vg.LvCreateLinear,
- (rs(8, '_lv'), 1024 * 1024 * 4, False, -1, {}),
+ (rs(8, '_lv'), mib(4), False, -1, {}),
vg)
t = ['Testing', 'tags']
@@ -968,7 +982,7 @@ class TestDbusService(unittest.TestCase):
vg = self._vg_create().Vg
self._test_lv_create(
vg.LvCreateLinear,
- (rs(8, '_lv'), 1024 * 1024 * 4, False, -1, {}),
+ (rs(8, '_lv'), mib(4), False, -1, {}),
vg)
vg.update()
@@ -1081,9 +1095,9 @@ class TestDbusService(unittest.TestCase):
def test_snapshot_merge(self):
# Create a non-thin LV and merge it
- ss_size = 1024 * 1024 * 512
+ ss_size = mib(8)
- lv_p = self._create_lv(size=1024 * 1024 * 1024)
+ lv_p = self._create_lv(size=mib(16))
ss_name = lv_p.LvCommon.Name + '_snap'
snapshot_path = lv_p.Lv.Snapshot(ss_name, ss_size, -1, {})[0]
ss = ClientProxy(self.bus, snapshot_path)
@@ -1101,7 +1115,7 @@ class TestDbusService(unittest.TestCase):
tp = self._create_lv(True)
thin_path = tp.ThinPool.LvCreate(
- rs(10, '_thin_lv'), 1024 * 1024 * 10, -1, {})[0]
+ rs(10, '_thin_lv'), mib(10), -1, {})[0]
lv_p = ClientProxy(self.bus, thin_path)
@@ -1115,8 +1129,8 @@ class TestDbusService(unittest.TestCase):
def _create_cache_pool(self):
vg = self._vg_create().Vg
- md = self._create_lv(size=(1024 * 1024 * 8), vg=vg)
- data = self._create_lv(size=(1024 * 1024 * 256), vg=vg)
+ md = self._create_lv(size=(mib(8)), vg=vg)
+ data = self._create_lv(size=(mib(8)), vg=vg)
cache_pool_path = vg.CreateCachePool(
md.object_path, data.object_path, -1, {})[0]
@@ -1137,7 +1151,7 @@ class TestDbusService(unittest.TestCase):
for destroy_cache in [True, False]:
vg, cache_pool = self._create_cache_pool()
- lv_to_cache = self._create_lv(size=(1024 * 1024 * 1024), vg=vg)
+ lv_to_cache = self._create_lv(size=mib(8), vg=vg)
c_lv_path = cache_pool.CachePool.CacheLv(
lv_to_cache.object_path, -1, {})[0]
@@ -1196,18 +1210,18 @@ class TestDbusService(unittest.TestCase):
for c in bad_chars:
with self.assertRaises(dbus.exceptions.DBusException):
vg_proxy.Vg.LvCreateLinear(rs(8, '_lv') + c,
- 1024 * 1024 * 4, False, -1, {})
+ mib(4), False, -1, {})
for r in ("_cdata", "_cmeta", "_corig", "_mimage", "_mlog",
"_pmspare", "_rimage", "_rmeta", "_tdata", "_tmeta", "_vorigin"):
with self.assertRaises(dbus.exceptions.DBusException):
vg_proxy.Vg.LvCreateLinear(rs(8, '_lv') + r,
- 1024 * 1024 * 4, False, -1, {})
+ mib(4), False, -1, {})
for r in ("snapshot", "pvmove"):
with self.assertRaises(dbus.exceptions.DBusException):
vg_proxy.Vg.LvCreateLinear(r + rs(8, '_lv'),
- 1024 * 1024 * 4, False, -1, {})
+ mib(4), False, -1, {})
_ALLOWABLE_TAG_CH = string.ascii_letters + string.digits + "._-+/=!:&#"
8 years, 2 months
master - lvmdbusd: background.py, fix stdout parse error
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=70d0b210e17884...
Commit: 70d0b210e17884ab8cfc5f2a9be90461afb993c7
Parent: d7dd8bf9d6ef146d48e5a2d39cf7ae17ca93545b
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 22 14:00:30 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbusd: background.py, fix stdout parse error
It appears that the output of lvconvert --merge can vary some. The code
was blowing up as it was trying to parse a line of stdout to retrieve the
% complete, but the line did not have the needed format and an execption
was thrown. The uncaught exception caused the background thread to exit
without updating the job object, which caused the client to hang forever
waiting. Added a default exception handler to prevent unhandled execptions
causing hangs and removed the parameter skip_first_line as it's no longer
needed. The code checks to see if the line can be parsed before doing so.
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/background.py | 85 ++++++++++++++++++++++++----------------
1 files changed, 51 insertions(+), 34 deletions(-)
diff --git a/daemons/lvmdbusd/background.py b/daemons/lvmdbusd/background.py
index 16ee7a6..4265154 100644
--- a/daemons/lvmdbusd/background.py
+++ b/daemons/lvmdbusd/background.py
@@ -14,8 +14,9 @@ import time
from .cmdhandler import options_to_cli_args
import dbus
from .job import Job, JobState
-from .utils import pv_range_append, pv_dest_ranges
+from .utils import pv_range_append, pv_dest_ranges, log_debug, log_error
from .request import RequestEntry
+import traceback
_rlock = threading.RLock()
_thread_list = list()
@@ -48,11 +49,11 @@ def _create_background_dbus_job(job_state):
return job_obj.dbus_object_path()
-def _move_merge(interface_name, cmd, time_out, skip_first_line=False):
+def _move_merge(interface_name, cmd, time_out):
# Create job object to be used while running the command
rc = '/'
job_state = JobState(None)
- add(cmd, job_state, skip_first_line)
+ add(cmd, job_state)
if time_out == -1:
# Waiting forever
@@ -122,7 +123,7 @@ def merge(interface_name, lv_uuid, lv_name, merge_options, time_out):
dbo = cfg.om.get_object_by_uuid_lvm_id(lv_uuid, lv_name)
if dbo:
cmd = lv_merge_cmd(merge_options, dbo.lvm_id)
- return _move_merge(interface_name, cmd, time_out, True)
+ return _move_merge(interface_name, cmd, time_out)
else:
raise dbus.exceptions.DBusException(
interface_name,
@@ -154,41 +155,57 @@ def empty_cb(disregard):
def background_execute(command, background_job, skip_first_line=False):
- process = subprocess.Popen(command, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=True)
- lines_iterator = iter(process.stdout.readline, b"")
- for line in lines_iterator:
- # Merge ouputs a line before updates, move does not
- if skip_first_line:
- skip_first_line = False
- continue
-
- if len(line) > 10:
- (device, ignore, percentage) = line.decode("utf-8").split(':')
- background_job.Percent = round(float(percentage.strip()[:-1]), 1)
-
- out = process.communicate()
-
- # print "DEBUG: EC %d, STDOUT %s, STDERR %s" % \
- # (process.returncode, out[0], out[1])
-
- if process.returncode == 0:
- background_job.Percent = 100
-
- # Queue up the result so that it gets executed in same thread as others.
- r = RequestEntry(
- -1, process_background_result,
- (background_job, process.returncode, out[1]),
- empty_cb, empty_cb, False)
- cfg.worker_q.put(r)
-
-def add(command, reporting_job, skip_first_line=False):
+ # Wrap this whole operation in an exception handler, otherwise if we
+ # hit a code bug we will silently exit this thread without anyone being
+ # the wiser.
+ try:
+ process = subprocess.Popen(command, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=True)
+ lines_iterator = iter(process.stdout.readline, b"")
+ for line in lines_iterator:
+ line_str = line.decode("utf-8")
+
+ # Check to see if the line has the correct number of separators
+ try:
+ if line_str.count(':') == 2:
+ (device, ignore, percentage) = line_str.split(':')
+ background_job.Percent = \
+ round(float(percentage.strip()[:-1]), 1)
+ except ValueError:
+ log_error("Trying to parse percentage which failed for %s" %
+ line_str)
+
+ out = process.communicate()
+
+ if process.returncode == 0:
+ background_job.Percent = 100
+
+ # Queue up the result so that it gets executed in same thread as others.
+ r = RequestEntry(
+ -1, process_background_result,
+ (background_job, process.returncode, out[1]),
+ empty_cb, empty_cb, False)
+ cfg.worker_q.put(r)
+ except Exception:
+ # In the unlikely event that we blew up, lets notify fill out the
+ # job object so that the client doesn't hang potentially forever!
+ st = traceback.format_exc()
+ error = "Exception in background thread: \n%s" % st
+ log_error(error)
+ r = RequestEntry(
+ -1, process_background_result,
+ (background_job, 1, error),
+ empty_cb, empty_cb, False)
+ cfg.worker_q.put(r)
+
+
+def add(command, reporting_job):
# Create the thread, get it running and then add it to the list
t = threading.Thread(
target=background_execute,
name="thread: " + ' '.join(command),
- args=(command, reporting_job, skip_first_line))
+ args=(command, reporting_job))
t.start()
with _rlock:
8 years, 2 months
master - lvmdbustest.py: Make executable
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d7dd8bf9d6ef14...
Commit: d7dd8bf9d6ef146d48e5a2d39cf7ae17ca93545b
Parent: f4efc2435c29b3bf4375c17937d0d2ab2294e00e
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Feb 19 17:02:45 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 22 16:07:54 2016 -0600
lvmdbustest.py: Make executable
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
0 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
old mode 100644
new mode 100755
8 years, 2 months
master - tests: fix clean up after lvmlockd tests
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f4efc2435c29b3...
Commit: f4efc2435c29b3bf4375c17937d0d2ab2294e00e
Parent: ec81c421793e63373cf6e119fe4bfd60368ee47d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 22 14:13:30 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 22 14:15:17 2016 -0600
tests: fix clean up after lvmlockd tests
---
test/shell/zz-lvmlockd-dlm-remove.sh | 7 ++++++-
test/shell/zz-lvmlockd-sanlock-remove.sh | 5 ++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/test/shell/zz-lvmlockd-dlm-remove.sh b/test/shell/zz-lvmlockd-dlm-remove.sh
index 3848c0e..0526314 100644
--- a/test/shell/zz-lvmlockd-dlm-remove.sh
+++ b/test/shell/zz-lvmlockd-dlm-remove.sh
@@ -19,6 +19,11 @@ test_description='Remove the dlm test setup'
# lvmlockctl -d > lvmlockd-debug.txt
# dlm_tool dump > dlm-debug.txt
+lvmlockctl --stop-lockspaces
+sleep 1
+killall lvmlockd
+sleep 1
+killall lvmlockd || true
+sleep 1
systemctl stop dlm
systemctl stop corosync
-killall lvmlockd
diff --git a/test/shell/zz-lvmlockd-sanlock-remove.sh b/test/shell/zz-lvmlockd-sanlock-remove.sh
index ae5bdef..b01952a 100644
--- a/test/shell/zz-lvmlockd-sanlock-remove.sh
+++ b/test/shell/zz-lvmlockd-sanlock-remove.sh
@@ -26,11 +26,14 @@ vgremove --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_
# lvmlockctl -d > lvmlockd-debug.txt
# sanlock log_dump > sanlock-debug.txt
+lvmlockctl --stop-lockspaces
+sleep 1
killall lvmlockd
sleep 1
+killall lvmlockd || true
+sleep 1
killall sanlock
sleep 1
-
killall -9 lvmlockd || true
killall -9 sanlock || true
8 years, 2 months
master - lvmdbusd: Fix make install for python >= 3.5
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ec81c421793e63...
Commit: ec81c421793e63373cf6e119fe4bfd60368ee47d
Parent: 367fb85e44e0718a335c328ca75cb646539d3148
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Mon Feb 22 18:14:23 2016 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Feb 22 18:16:41 2016 +0100
lvmdbusd: Fix make install for python >= 3.5
python 3.5 renamed .pyo files to .opt-1.pyc.
---
daemons/lvmdbusd/Makefile.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemons/lvmdbusd/Makefile.in b/daemons/lvmdbusd/Makefile.in
index 658fcd8..9ee5b0b 100644
--- a/daemons/lvmdbusd/Makefile.in
+++ b/daemons/lvmdbusd/Makefile.in
@@ -57,7 +57,7 @@ install_lvmdbusd:
$(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(DESTDIR)$(lvmdbusdir)
PYTHON=$(PYTHON3) $(PYCOMPILE) --destdir "$(DESTDIR)" --basedir "$(lvmdbusdir)" $(LVMDBUS_SRCDIR_FILES) $(LVMDBUS_BUILDDIR_FILES)
$(CHMOD) 755 $(DESTDIR)$(lvmdbusdir)/__pycache__
- $(CHMOD) 444 $(DESTDIR)$(lvmdbusdir)/__pycache__/*.pyc $(DESTDIR)$(lvmdbusdir)/__pycache__/*.pyo
+ $(CHMOD) 444 $(DESTDIR)$(lvmdbusdir)/__pycache__/*.py[co]
install_lvm2: install_lvmdbusd
8 years, 2 months
master - spec: Fix 04ab1fa572bb: Remove left-overs
by Marian Csontos
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=367fb85e44e071...
Commit: 367fb85e44e0718a335c328ca75cb646539d3148
Parent: c716813651c2691c44bc709040cd16fbf363a74e
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Mon Feb 22 17:40:12 2016 +0100
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Feb 22 17:50:35 2016 +0100
spec: Fix 04ab1fa572bb: Remove left-overs
---
spec/build.inc | 5 -----
test/api/pytest.sh | 16 ++++++++++++----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/spec/build.inc b/spec/build.inc
index 3ba7840..cd58f3b 100644
--- a/spec/build.inc
+++ b/spec/build.inc
@@ -55,11 +55,6 @@ make install_initscripts DESTDIR=$RPM_BUILD_ROOT
%if %{enable_testsuite}
make -C test install DESTDIR=$RPM_BUILD_ROOT
%endif
-%if %{enable_python3}
-pushd %{py3dir}
-make -C python install DESTDIR=$RPM_BUILD_ROOT
-popd
-%endif
# when building an src.rpm from freestanding specfiles
test -e %{_sourcedir}/source.inc || cp source.inc build.inc packages.inc macros.inc %{_sourcedir}
diff --git a/test/api/pytest.sh b/test/api/pytest.sh
index 33c1095..28a1cd0 100644
--- a/test/api/pytest.sh
+++ b/test/api/pytest.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Copyright (C) 2012-2015 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
@@ -31,9 +31,17 @@ aux prepare_dmeventd
#Locate the python binding library to use.
if [[ -n $abs_top_builddir ]]; then
- python_lib=$(find $abs_top_builddir -name lvm.so)
- # Unable to test python bindings if library not available
- test -n "$python_lib" || skip "lvm2-python-libs not built"
+ python_lib=($(find $abs_top_builddir -name lvm.so))
+ if [[ ${#python_lib[*]} -ne 1 ]]; then
+ if [[ ${#python_lib[*]} -gt 1 ]]; then
+ # Unable to test python bindings if multiple libraries found:
+ echo "Found left over lvm.so: ${python_lib[*]}"
+ false
+ else
+ # Unable to test python bindings if library not available
+ skip "lvm2-python-libs not built"
+ fi
+ fi
export PYTHONPATH=$(dirname $python_lib):$PYTHONPATH
elif rpm -q lvm2-python-libs &>/dev/null; then
8 years, 2 months
master - lvmlockd: invalidate name in lockspace struct after remove
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c716813651c269...
Commit: c716813651c2691c44bc709040cd16fbf363a74e
Parent: 161ae36363f5fa1b1469fd3a42c096c878002b31
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Feb 22 09:32:39 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Feb 22 09:36:35 2016 -0600
lvmlockd: invalidate name in lockspace struct after remove
After the lockspace has been successfully removed,
invalidate the name field in the lockspace struct.
The struct remains on the list of lockspaces until
the struct can be freed later. Until the struct is
freed, its name will prevent another new lockspace
from being created with the same name.
---
daemons/lvmlockd/lvmlockd-core.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 76a7650..c273d25 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -2269,6 +2269,7 @@ static void *lockspace_thread_main(void *arg_in)
struct action *act_op_free = NULL;
struct list_head tmp_act;
struct list_head act_close;
+ char tmp_name[MAX_NAME+1];
int free_vg = 0;
int drop_vg = 0;
int error = 0;
@@ -2634,6 +2635,10 @@ out_act:
ls->drop_vg = drop_vg;
if (ls->lm_type == LD_LM_DLM && !strcmp(ls->name, gl_lsname_dlm))
global_dlm_lockspace_exists = 0;
+ /* Avoid a name collision of the same lockspace is added again before this thread is cleaned up. */
+ memset(tmp_name, 0, sizeof(tmp_name));
+ snprintf(tmp_name, MAX_NAME, "REM:%s", ls->name);
+ memcpy(ls->name, tmp_name, MAX_NAME);
pthread_mutex_unlock(&lockspaces_mutex);
/* worker_thread will join this thread, and free the ls */
@@ -3113,6 +3118,8 @@ static int for_each_lockspace(int do_stop, int do_free, int do_force)
/* FIXME: will free_vg ever not be set? */
+ log_debug("free ls %s", ls->name);
+
if (ls->free_vg) {
/* In future we may need to free ls->actions here */
free_ls_resources(ls);
8 years, 2 months