# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1232580651 28800
# Node ID 6e23c06353a1529f295109cd79858cdea4dbf0be
# Parent c48f4ad82a02ab19ff0d30d77d492060d0a30145
[TEST] #3 Fix verify_rasds() and verify_devices() in SD 02_reverse.py
Since VSSDC should return RASDs that all correspond to the guest, there's
no need to parse the InstanceID to see if the guest name matches the guest
we've created.
Also, fix the logic of the verify functions to be a little cleaner. Compare
all the properties of the instances, not just the InstanceIDs/DeviceIDs.
Remove parse_instance_id() from verify_devices(); guest and dev_id were not
being used in the function.
Updates from 2 to 3:
-Fix typo in setup_env(). cmxl should be cxml
-Fixed bug in cim_define() that was causing this to fail with LXC
Updates from 1 to 2:
-Removed unnecessary undefine() call
-Moved the verification of the number of RASDs before the for loop - in the
case of LXC, we remove one of the RASDs from this list so we don't verify it,
but we still want to verify the appropriate number of RASDs was returned.
-Print an error message if comparing all the instance properties fails.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r c48f4ad82a02 -r 6e23c06353a1
suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py
--- a/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py Tue Jan 20 18:24:05 2009
-0800
+++ b/suites/libvirt-cim/cimtest/SettingsDefine/02_reverse.py Wed Jan 21 15:30:51 2009
-0800
@@ -55,7 +55,7 @@
from CimTest.Globals import logger
from CimTest.ReturnCodes import PASS, FAIL
from XenKvmLib.const import do_main
-from XenKvmLib.assoc import AssociatorNames
+from XenKvmLib.assoc import AssociatorNames, compare_all_prop
from XenKvmLib.vxml import get_class
from XenKvmLib.classes import get_typed_class
from XenKvmLib.rasd import enum_rasds
@@ -80,7 +80,7 @@
ret = cxml.cim_define(server)
if not ret:
logger.error("Failed to Create the dom: %s", test_dom)
- return FAIL, cmxl
+ return FAIL, cxml
status = cxml.cim_start(server)
if status != PASS:
@@ -101,9 +101,6 @@
return rasd_insts, status
for rasd_cn, rasd_list in rasds.iteritems():
- if virt == "LXC" and rasd_cn == proc_rasd_cn:
- continue
-
for rasd in rasd_list:
guest, dev, status = parse_instance_id(rasd.InstanceID)
if status != PASS:
@@ -135,56 +132,44 @@
return dev_insts, PASS
-def verify_rasd(virt, enum_list, rasds, guest_name):
- proc_rasd_cn = get_typed_class(virt, "ProcResourceAllocationSettingData")
+def verify_rasd(virt, enum_list, rasds):
+ if len(enum_list) != len(rasds):
+ logger.error("Got %d RASDs, expected %d", len(enum_list), len(rasds))
+ return FAIL
+
+ status = FAIL
for rasd in enum_list:
- if virt == "LXC" and rasd.classname == proc_rasd_cn:
- enum_list.remove(rasd)
- continue
-
- guest, dev, status = parse_instance_id(rasd['InstanceID'])
- if status != PASS:
- logger.error("Unable to parse InstanceID: %s",
rasd['InstanceID'])
- return status
-
- if guest != guest_name:
- continue
-
exp_rasd = rasds[rasd.classname]
- if rasd['InstanceID'] == exp_rasd.InstanceID:
- status = PASS
- else:
- logger.info("Got %s instead of %s" % (rasd['InstanceID'],
- exp_rasd.InstanceID))
- status = FAIL
+ if rasd['InstanceID'] != exp_rasd.InstanceID:
+ logger.error("Got %s instead of %s", rasd['InstanceID'],
+ exp_rasd.InstanceID)
+ return FAIL
- if status != PASS:
- logger.error("RASD with id %s not returned", exp_rasd.InstanceID)
+ status = compare_all_prop(rasd, exp_rasd)
+ if status != PASS:
+ logger.error("Verifying instance properties failed.")
+
+ return status
+
+def verify_devices(enum_list, devs):
+ dev = enum_list[0]
+ dev_cn = dev.classname
+
+ if len(enum_list) != 1:
+ logger.error("Got %d %s devices, expected 1", len(enum_list), dev_cn)
return FAIL
- return PASS
+ exp_dev = devs[dev_cn]
-def verify_devices(enum_list, devs):
- for dev in enum_list:
- guest, dev_id, status = parse_instance_id(dev['DeviceID'])
- if status != PASS:
- logger.error("Unable to parse InstanceID: %s",
dev['DeviceID'])
- return status
+ if dev['DeviceID'] != exp_dev.DeviceID:
+ logger.error("Got %s instead of %s", dev['DeviceID'],
exp_dev.DeviceID)
+ return FAIL
- exp_dev = devs[dev.classname]
-
- if dev['DeviceID'] == exp_dev.DeviceID:
- status = PASS
- else:
- logger.info("Got %s instead of %s" % (dev['DeviceID'],
- exp_dev.DeviceID))
- status = FAIL
-
+ status = compare_all_prop(dev, exp_dev)
if status != PASS:
- logger.error("Device with id %s not returned", exp_dev.DeviceID)
- return FAIL
+ return status
return PASS
@@ -196,7 +181,6 @@
status, cxml = setup_env(options.ip, virt)
if status != PASS:
- cxml.undefine(options.ip)
return status
if virt == 'XenFV':
@@ -217,21 +201,24 @@
assoc = AssociatorNames(options.ip, vssdc_cn, vssd_cn,
InstanceID = instIdval)
- status = verify_rasd(virt, assoc, rasds, test_dom)
+ status = verify_rasd(virt, assoc, rasds)
if status != PASS:
raise Exception("Failed to verify RASDs")
- if len(assoc) != len(rasds):
- raise Exception("Got %d RASDs, exp %d" % (len(assoc), len(rasds)))
-
sds_cn = get_typed_class(virt, 'SettingsDefineState')
devs, status = init_device_list(virt, options.ip, test_dom)
if status != PASS:
raise Exception("Unable to build device instance list")
+ proc_cn = get_typed_class(virt, 'ProcResourceAllocationSettingData')
for rasd in assoc:
rasd_cn = rasd.classname
+
+ # LXC guests don't have proc devices
+ if virt == "LXC" and rasd_cn == proc_cn:
+ continue
+
sdc_assoc = AssociatorNames(options.ip, sds_cn, rasd_cn,
InstanceID = rasd['InstanceID'])
diff -r c48f4ad82a02 -r 6e23c06353a1 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Tue Jan 20 18:24:05 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Jan 21 15:30:51 2009 -0800
@@ -501,9 +501,11 @@
res_settings.append(str(self.pasd))
if self.masd is not None:
res_settings.append(str(self.masd))
- if self.nasd is not None or \
- (self.virt == 'LXC' and const.LXC_netns_support is False):
- res_settings.append(str(self.nasd))
+ if self.nasd is not None:
+ if self.virt == 'LXC' and const.LXC_netns_support is False:
+ pass
+ else:
+ res_settings.append(str(self.nasd))
if ref_conf is None:
ref_conf = ' '