
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1236749279 25200 # Node ID 676a8b05baa09b69052d519c7b438b301bea849c # Parent a78b6f23ebaa8a38fa591e420d742aa03cd9e515 [TEST]#4 Fix ElementCapabilities/03_forward_errs.py with provider's updated err message Updates from 3 to 4: Define exp_desc and exp_rc inside of main() Updates from 2 to 3: Get correct CS Name instead of hard code of "Xen_ComputerSystem" Updates from 1 to 2: Use a variable to assign revision value to be calculated for comparison Also fix the line to meet 80 length Tested for KVM/LXC with current sources and rpm Signed-off-by: Guolian Yun<yunguol@cn.ibm.com> diff -r a78b6f23ebaa -r 676a8b05baa0 suites/libvirt-cim/cimtest/ElementCapabilities/03_forward_errs.py --- a/suites/libvirt-cim/cimtest/ElementCapabilities/03_forward_errs.py Mon Mar 09 00:27:12 2009 -0700 +++ b/suites/libvirt-cim/cimtest/ElementCapabilities/03_forward_errs.py Tue Mar 10 22:27:59 2009 -0700 @@ -27,13 +27,11 @@ from XenKvmLib import enumclass from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS -from XenKvmLib.const import do_main +from XenKvmLib.const import do_main, get_provider_version from CimTest.ReturnCodes import PASS, FAIL sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] - -exp_rc = 6 #CIM_ERR_NOT_FOUND -exp_desc = "No such instance" +libvirt_ec_changes = 815 def try_assoc(ref, ref_class, exp_rc, exp_desc, options): conn = assoc.myWBEMConnection('http://%s' % options.ip, @@ -42,23 +40,24 @@ status = FAIL rc = -1 names = [] - + ec = get_typed_class(options.virt, "ElementCapabilities") try: - names = conn.AssociatorNames(ref, AssocClass = get_typed_class(options.virt, "ElementCapabilities")) + names = conn.AssociatorNames(ref, AssocClass = ec) rc = 0 except pywbem.CIMError, (rc, desc): if rc == exp_rc and desc.find(exp_desc) >= 0: logger.info("Got expected rc code and error string") status = PASS else: - logger.error("Unexpected rc code %s and description %s\n", rc, desc) + logger.error("Unexpected rc code %s and description %s\n", rc, + desc) except Exception, details: logger.error("Unknown exception happened") logger.error(details) if rc == 0: - logger.error("ElementCapabilities associator should NOT return excepted \ - result with a wrong key name and value of %s input", ref_class) + logger.error("ElementCapabilities associator should NOT" \ + " return records with a wrong key name and value") status = FAIL return status @@ -66,6 +65,9 @@ @do_main(sup_types) def main(): + exp_rc = 6 #CIM_ERR_NOT_FOUND + exp_desc = "No such instance" + options = main.options rc = PASS @@ -73,7 +75,8 @@ cs = get_typed_class(options.virt, "ComputerSystem") instanceref = CIMInstanceName(hs, - keybindings = {"Name" : "wrong", "CreationClassName" : "wrong"}) + keybindings = {"Name" : "wrong", + "CreationClassName" : "wrong"}) rc = try_assoc(instanceref, hs, exp_rc, exp_desc, options) if rc != PASS: @@ -81,7 +84,13 @@ return status instance_cs = CIMInstanceName(cs, - keybindings = {"Name" : "wrong", "CreationClassName" : "Xen_ComputerSystem"}) + keybindings = {"Name" : "wrong", + "CreationClassName" : cs}) + + curr_cim_rev, changeset = get_provider_version(options.virt, options.ip) + if curr_cim_rev >= libvirt_ec_changes: + exp_desc = "Referenced domain `wrong' does not exist:" \ + " Domain not found" rc = try_assoc(instance_cs, cs, exp_rc, exp_desc, options) if rc != PASS: status = FAIL