On 06/25/2014 08:01 AM, mulhern wrote:
Signed-off-by: mulhern <amulhern(a)redhat.com>
---
tests/devicelibs_test/mdraid_test.py | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/tests/devicelibs_test/mdraid_test.py b/tests/devicelibs_test/mdraid_test.py
index cba8487..b9943d4 100755
--- a/tests/devicelibs_test/mdraid_test.py
+++ b/tests/devicelibs_test/mdraid_test.py
@@ -66,6 +66,11 @@ class MDRaidAsRootTestCase(loopbackedtestcase.LoopBackedTestCase):
super(MDRaidAsRootTestCase, self).tearDown()
+ def testNonMDRaid(self):
+ # invoking mdexamine on a device that is not an array member yields {}
+ info = mdraid.mdexamine(self.loopDevices[0])
+ self.assertEqual(info, {})
+
def testMDRaidAsRoot(self):
##
## mdcreate
@@ -75,6 +80,35 @@ class MDRaidAsRootTestCase(loopbackedtestcase.LoopBackedTestCase):
# wait for raid to settle
time.sleep(2)
+ info = mdraid.mdexamine(self._dev_name)
+ self.assertEqual(info, {})
+
+ info = mdraid.mdexamine(self.loopDevices[0])
+
+ names = [
+ 'DEVICE',
+ 'MD_ARRAY_SIZE',
+ 'MD_DEV_UUID',
+ 'MD_DEVICES',
+ 'MD_EVENTS',
+ 'MD_LEVEL',
+ 'MD_METADATA',
+ 'MD_NAME',
+ 'MD_UPDATE_TIME',
+ 'MD_UUID'
+ ]
+
+ # info contains values for exactly names
+ for n in names:
+ self.assertIn(n, info, msg="name '%s' not in info" % n)
+
+ for n in info.keys():
+ self.assertIn(n, names, msg="unexpected name '%s' in info"
% n)
+
+ # check names with predictable values
+ self.assertEqual(info['MD_DEVICES'], '2')
+ self.assertEqual(info['MD_LEVEL'], 'raid1')
+
# fail
self.assertRaises(MDRaidError, mdraid.mdcreate, "/dev/md1",
"raid1", ["/not/existing/dev0", "/not/existing/dev1"])
IIRC the set of output fields ("names" above) varies depending on the
metadata version used on the member device. That doesn't have to mean
changes to this patch, but you should be aware of it.
David