
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229040244 28800 # Node ID 6a9478ad87fac97af5689f6a4a86f165c6c569bf # Parent 2870da2286667b1ed71b859facd4d19acdbd3ed4 [TEST] Remove try_getinstance() from VSSD - 03_vssd_gi_errs.py try_getinstance() is no longer needed - this function can be implemented using functions from enumclass.py. Plus, a conn needs to be passed to the function, which is poor function design. Removed the "invalid_instid_keyname" case - passing an invalid keyname only tests the CIMOM, it does not test the providers. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 2870da228666 -r 6a9478ad87fa suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py --- a/suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py Thu Dec 11 15:48:57 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py Thu Dec 11 16:04:04 2008 -0800 @@ -35,79 +35,58 @@ # error code : CIM_ERR_NOT_FOUND # error desc : "No such instance (InstanceID)" -# 2) Test by passing Invalid InstID Keyvalue -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_VirtualSystemSettingData.InstanceID="INVALID_InstID_Keyval"' -nl -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (InstanceID)" -# -# Date: 06-03-2008 - import sys -import pywbem +from pywbem import CIM_ERR_NOT_FOUND, CIMError +from pywbem.cim_obj import CIMInstanceName from CimTest.ReturnCodes import PASS, FAIL +from CimTest.Globals import logger from XenKvmLib.const import do_main -from CimTest.Globals import CIM_PASS, CIM_NS, CIM_USER, logger -from XenKvmLib import assoc from XenKvmLib.vxml import get_class -from XenKvmLib.common_util import try_getinstance -from XenKvmLib.test_doms import destroy_and_undefine_all +from XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass platform_sup = ['Xen', 'KVM', 'XenFV', 'LXC'] test_dom = "VSSD_domain" -expr_values = { - "INVALID_InstID_Keyname" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (InstanceID)' }, \ - "INVALID_InstID_Keyval" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (InstanceID)'} -} - -def try_invalid_gi(VSType, name_val, i, field): - classname = "%s_VirtualSystemSettingData" % VSType - keys = {} - temp = name_val[i] - name_val[i] = field - for j in range(len(name_val)/2): - k = j * 2 - keys[name_val[k]] = name_val[k+1] - ret_val = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values[field], bug_no="") - if ret_val != PASS: - logger.error("------ FAILED: %s ------", field) - name_val[i] = temp - return ret_val - @do_main(platform_sup) def main(): options = main.options - status = PASS - if options.virt == 'XenFV': - VSType = 'Xen' - else: - VSType = options.virt + vsxml = get_class(options.virt)(test_dom) ret = vsxml.cim_define(options.ip) if not ret : logger.error("error while define of VS") return FAIL - global conn - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) + cn = get_typed_class(options.virt, 'VirtualSystemManagementCapabilities') - inst_id = "%s:%s" % (VSType, test_dom) - name_val = ['InstanceID', inst_id] - tc_scen = ['INVALID_InstID_Keyname', 'INVALID_InstID_Keyval'] + expr_values = { + 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : "No such instance (InstanceID)" + } - for i in range(len(tc_scen)): - retval = try_invalid_gi(VSType, name_val, i, tc_scen[i]) - if retval != PASS: - status = retval + keys = { 'InstanceID' : 'INVALID_Instid_KeyValue' } + + ref = CIMInstanceName(cn, keybindings=keys) + + status = FAIL + try: + inst = CIM_CimtestClass(options.ip, ref) + + except CIMError, (err_no, err_desc): + exp_rc = expr_values['rc'] + exp_desc = expr_values['desc'] + + if err_no == exp_rc and err_desc.find(exp_desc) >= 0: + logger.info("Got expected exception: %s %s", exp_desc, exp_rc) + status = PASS + else: + logger.error("Unexpected errno %s and desc %s", err_no, err_desc) + logger.error("Got %s %s", err_desc, err_no) + status = FAIL + + if status != PASS: + logger.error("------ FAILED: Invalid InstanceID Key Value.------") vsxml.undefine(options.ip) return status