[PATCH] [TEST] #2 Fix verify_rasds() and verify_devices() in SD 02_reverse.py

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1232505043 28800 # Node ID c9633428563c23db5154195f9a5fe645a0b4a3eb # Parent c48f4ad82a02ab19ff0d30d77d492060d0a30145 [TEST] #2 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: -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@us.ibm.com> diff -r c48f4ad82a02 -r c9633428563c 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 Tue Jan 20 18:30:43 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 @@ -135,56 +135,50 @@ return dev_insts, PASS -def verify_rasd(virt, enum_list, rasds, guest_name): +def verify_rasd(virt, enum_list, rasds): proc_rasd_cn = get_typed_class(virt, "ProcResourceAllocationSettingData") + 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 +190,6 @@ status, cxml = setup_env(options.ip, virt) if status != PASS: - cxml.undefine(options.ip) return status if virt == 'XenFV': @@ -217,13 +210,10 @@ 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)

In the setup_env(), line no 83 we have misspelled name, we have cmxl instead of cxml. Sorry for not reporting this in the first review. -- Thanks and Regards, Deepti B. Kalakeri IBM Linux Technology Center deeptik@linux.vnet.ibm.com
participants (2)
-
Deepti B Kalakeri
-
Kaitlin Rupert