[PATCH 0 of 8] [TEST] #2 Rework negative tc to not use try_getinstance()

try_getinstance() really isn't needed anymore as the same functionality can be achieved using the functions in enumclass.py. Removing try_getinstance() requires essentially a re-write of these tests - they're old, so updates are needed anyway. More test re-writes will follow in the next set. Updates; -Only patch 5 of 8 changes - see individual patch for more info

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229119032 28800 # Node ID 8f20aa7573f126da940c3744a711aa76e2b23860 # Parent 3edc8ce197575f0d80407ed8fc7825f981837c6d [TEST] Remove try_getinstance() from VSMC - 02_vsmcap_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 3edc8ce19757 -r 8f20aa7573f1 suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/02_vsmcap_gi_errs.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/02_vsmcap_gi_errs.py Fri Dec 12 13:56:01 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementCapabilities/02_vsmcap_gi_errs.py Fri Dec 12 13:57:12 2008 -0800 @@ -22,8 +22,9 @@ # # Test Case Info: # -------------- -# This tc is used to verify if appropriate exceptions are -# returned by Xen_VirtualSystemManagementCapabilities on giving invalid inputs. +# This tc is used to verify if appropriate exceptions are returned by +# VirtualSystemManagementCapabilities' GetInstance call when specifying +# invalid inputs. # # 1) Test by passing Invalid InstanceID Key Value # Input: @@ -36,66 +37,51 @@ # error code : CIM_ERR_NOT_FOUND # error desc : "No such instance (InstanceID)" # -# 2) Test by giving Invalid InstanceID Key Name -# Input: -# ------ -# wbemcli gi http://localhost:5988/root/virt:\ -# Xen_VirtualSystemManagementCapabilities.Wrong="ManagementCapabilities" -nl -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (InstanceID)" -# -Date 22.02.2008 import sys -import pywbem -from VirtLib import utils -from XenKvmLib import assoc -from optparse import OptionParser -from XenKvmLib.common_util import try_getinstance +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.classes import get_typed_class -from CimTest.ReturnCodes import PASS, FAIL -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS from XenKvmLib.const import do_main +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass sup_types=['Xen', 'KVM', 'XenFV', 'LXC'] - -expr_values = { - "invalid_instid_keyname" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : "No such instance (InstanceID)" }, \ - "invalid_instid_keyvalue" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : "No such instance (InstanceID)" } - } - @do_main(sup_types) def main(): options = main.options - status = PASS - classname = get_typed_class(options.virt, 'VirtualSystemManagementCapabilities') + cn = get_typed_class(options.virt, 'VirtualSystemManagementCapabilities') - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) + expr_values = { + 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : "No such instance (InstanceID)" + } - # 1) Test by passing Invalid InstanceID Key Value - field = 'INVALID_Instid_KeyValue' - keys = { 'InstanceID' : field } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid_keyvalue'], bug_no="") - if ret_value != PASS: + 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("Expected %s %s", exp_desc, exp_rc) + status = FAIL + + if status != PASS: logger.error("------ FAILED: Invalid InstanceID Key Value.------") - status = ret_value - - # 2) Test by giving Invalid InstanceID Key Name - field = 'INVALID_Instid_KeyName' - inst_id = "ManagementCapabilities" - keys = { field : inst_id } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid_keyname'], bug_no="") - if ret_value != PASS: - logger.error("------ FAILED: Invalid InstanceID Key Name.------") - status = ret_value return status

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229119062 28800 # Node ID 5abfd1f9f0efb7d0b9284b7550a040455f576b20 # Parent 8f20aa7573f126da940c3744a711aa76e2b23860 [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 8f20aa7573f1 -r 5abfd1f9f0ef suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py --- a/suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py Fri Dec 12 13:57:12 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VSSD/03_vssd_gi_errs.py Fri Dec 12 13:57:42 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("Expected %s %s", exp_desc, exp_rc) + status = FAIL + + if status != PASS: + logger.error("------ FAILED: Invalid InstanceID Key Value.------") vsxml.undefine(options.ip) return status

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229119151 28800 # Node ID 224d9ab19e585f7770a647e3c6ae132d5cfd4ed7 # Parent 5abfd1f9f0efb7d0b9284b7550a040455f576b20 [TEST] Remove try_getinstance() from VSSSC - 02_vs_sservicecap_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 5abfd1f9f0ef -r 224d9ab19e58 suites/libvirt-cim/cimtest/VirtualSystemSnapshotServiceCapabilities/02_vs_sservicecap_gi_errs.py --- a/suites/libvirt-cim/cimtest/VirtualSystemSnapshotServiceCapabilities/02_vs_sservicecap_gi_errs.py Fri Dec 12 13:57:42 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemSnapshotServiceCapabilities/02_vs_sservicecap_gi_errs.py Fri Dec 12 13:59:11 2008 -0800 @@ -23,13 +23,8 @@ # -------------- # This tc is used to verify if appropriate exceptions are # returned by VirtualSystemSnapshotServiceCapabilities on giving invalid inputs. -# 1) Test by giving invalid Invalid InstanceID Key Name -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# KVM_VirtualSystemSnapshotServiceCapabilities.Wrong="SnapshotCapabilities"' -nl # -# 2) Test by passing Invalid InstanceID Key Value +# 1) Test by passing Invalid InstanceID Key Value # Input: # ------ # wbemcli gi 'http://localhost:5988/root/virt:\ @@ -41,50 +36,53 @@ # ------- # error code : CIM_ERR_NOT_FOUND # error desc : "No such instance (InstanceID)" -# -# Date: 25-03-2008 + import sys -import pywbem -from XenKvmLib import assoc -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS -from CimTest.ReturnCodes import PASS -from XenKvmLib.common_util import try_getinstance +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 XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] -expr_values = { - "invalid_instid" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (InstanceID)' } - } -def verify_fields(): - classname = get_typed_class(options.virt, "VirtualSystemSnapshotServiceCapabilities") - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid'], bug_no="") @do_main(sup_types) def main(): - global options options = main.options - global conn - global keys - global field - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) + virt = options.virt - field = 'INVALID_Instid_KeyName' - keys = { field : "SnapshotCapabilities" } - status = verify_fields() + cn = get_typed_class(virt, 'VirtualSystemSnapshotServiceCapabilities') + + expr_values = { + 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : "No such instance (InstanceID)" + } + + 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("Expected %s %s", exp_desc, exp_rc) + status = FAIL + if status != PASS: - logger.error("------ FAILED: to check INVALID_Instid_KeyName.------") - return status + logger.error("------ FAILED: Invalid InstanceID Key Value.------") - field = 'INVALID_Instid_KeyValue' - keys = { 'InstanceID' : field } - status = verify_fields() - if status != PASS: - logger.error("------ FAILED: to check INVALID_Instid_KeyValue.------") - return status - - return PASS + return status if __name__ == "__main__": sys.exit(main())

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229119175 28800 # Node ID 8feb8f22739358d39e50166712ce069e10bb82af # Parent 224d9ab19e585f7770a647e3c6ae132d5cfd4ed7 [TEST] Remove try_getinstance() from VSSS - 02_vs_sservice_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 224d9ab19e58 -r 8feb8f227393 suites/libvirt-cim/cimtest/VirtualSystemSnapshotService/02_vs_sservice_gi_errs.py --- a/suites/libvirt-cim/cimtest/VirtualSystemSnapshotService/02_vs_sservice_gi_errs.py Fri Dec 12 13:59:11 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemSnapshotService/02_vs_sservice_gi_errs.py Fri Dec 12 13:59:35 2008 -0800 @@ -24,236 +24,113 @@ # This tc is used to verify if appropriate exceptions are # returned by VirtualSystemSnapshotService on giving invalid inputs. # -# Date: 24-03-2008 -import sys -import pywbem -from XenKvmLib import assoc -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS -from CimTest.ReturnCodes import PASS -from XenKvmLib.common_util import try_getinstance -from XenKvmLib.const import do_main -from XenKvmLib.classes import get_typed_class -from XenKvmLib.common_util import get_host_info - -sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] -expr_values = { - "INVALID_CCName" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (CreationClassName)' }, \ - "INVALID_Name" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (Name)' }, \ - "INVALID_SCCName" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (SystemCreationClassName)'}, \ - "INVALID_SName" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (SystemName)' }, - } - - -def verify_fields(keys): - classname = get_typed_class(options.virt, "VirtualSystemSnapshotService") - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values[field], bug_no="") - -def err_invalid_ccname(): -# 1) Test by giving invalid CreationClassName Key Name # Input: # ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# Wrong="KVM_VirtualSystemSnapshotService",Name="SnapshotService",\ -# SystemCreationClassName="KVM_HostSystem",SystemName="mx3650a.in.ibm.com"' -nl -# -# 2) Test by passing Invalid CreationClassName Key Value -# Input: -# ------ +# Invalid values for the following: +# CreationClassName +# Name +# SystemCreationClassName +# SystemName +# +# Format: +# -------- # wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ # CreationClassName="Wrong",Name="SnapshotService",\ # SystemCreationClassName="KVM_HostSystem",SystemName="mx3650a.in.ibm.com"' -nl # -# Inboth the cases the following exception is verified. -# # Output: # ------- # error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (CreationClassName)" - keys = { field : ccn, \ - 'Name' : name, \ - 'SystemCreationClassName' : sccn, \ - 'SystemName' : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_CCName_KeyName.------") - return status - keys = { 'CreationClassName' : field, \ - 'Name' : name, \ - 'SystemCreationClassName' : sccn, \ - 'SystemName' : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_CCName_KeyValue.------") - return status - return PASS +# error desc : "No such instance (CreationClassName)" (varies by key name) -def err_invalid_name(): -# 1) Test by giving invalid Name Key Name -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# CreationClassName="KVM_VirtualSystemSnapshotService",Wrong="SnapshotService",\ -# SystemCreationClassName="KVM_HostSystem",SystemName="mx3650a.in.ibm.com"' -nl -# -# 2) Test by passing Invalid CreationClassName Key Value -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# CreationClassName="KVM_VirtualSystemSnapshotService",Name="Wrong",\ -# SystemCreationClassName="KVM_HostSystem",SystemName="mx3650a.in.ibm.com"' -nl -# -# Inboth the cases the following exception is verified. -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (Name)" -# - keys = { 'CreationClassName' : ccn, \ - field : name, \ - 'SystemCreationClassName' : sccn, \ - 'SystemName' : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_Name_KeyName.------") - return status - keys = { 'CreationClassName' : ccn, \ - 'Name' : field, \ - 'SystemCreationClassName' : sccn, \ - 'SystemName' : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_Name_KeyValue.------") - return status - return PASS +import sys +import pywbem +from pywbem import CIM_ERR_NOT_FOUND, CIMError +from pywbem.cim_obj import CIMInstanceName +from CimTest.Globals import logger +from CimTest.ReturnCodes import PASS, FAIL +from XenKvmLib.const import do_main +from XenKvmLib.classes import get_typed_class +from XenKvmLib.common_util import get_host_info +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass, EnumInstances -def err_invalid_sccname(): -# 1) Test by giving invalid SystemCreationClassName Key Name -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# CreationClassName="KVM_VirtualSystemSnapshotService",Name="SnapshotService",\ -# Wrong="KVM_HostSystem",SystemName="mx3650a.in.ibm.com"' -nl -# -# 2) Test by passing Invalid CreationClassName Key Value -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# CreationClassName="KVM_VirtualSystemSnapshotService",Name="SnapshotService",\ -# SystemCreationClassName="Wrong",SystemName="mx3650a.in.ibm.com"' -nl -# -# Inboth the cases the following exception is verified. -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (SystemCreationClassName)" -# - keys = { 'CreationClassName' : ccn, \ - 'Name' : name, \ - field : sccn, \ - 'SystemName' : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_SCCName_KeyName.------") - return status - keys = { 'CreationClassName' : ccn, \ - 'Name' : name, \ - 'SystemCreationClassName' : field, \ - 'SystemName' : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_SCCName_KeyValue.------") - return status - return PASS +sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] +expected_values = { + "invalid_ccname" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (CreationClassName)' }, + "invalid_sccname" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (SystemCreationClassName)' }, + "invalid_name" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (Name)'}, + "invalid_sysval" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (SystemName)' }, + } -def err_invalid_sname(): -# 1) Test by giving invalid SystemName Key Name -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# CreationClassName="KVM_VirtualSystemSnapshotService",Name="SnapshotService",\ -# SystemCreationClassName="KVM_HostSystem",Wrong="mx3650a.in.ibm.com"' -nl -# -# 2) Test by passing Invalid CreationClassName Key Value -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:KVM_VirtualSystemSnapshotService. \ -# CreationClassName="KVM_VirtualSystemSnapshotService",Name="SnapshotService",\ -# SystemCreationClassName="KVM_HostSystem",SystemName="Wrong"' -nl -# -# Inboth the cases the following exception is verified. -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (SystemName)" -# - keys = { 'CreationClassName' : ccn, \ - 'Name' : name, \ - 'SystemCreationClassName' : sccn, \ - field : sys_name - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_SName_KeyName.------") - return status - keys = { 'CreationClassName' : ccn, \ - 'Name' : name, \ - 'SystemCreationClassName' : sccn, \ - 'SystemName' : field - } - status = verify_fields(keys) - if status != PASS: - logger.error("------ FAILED: to check INVALID_SName_KeyValue.------") - return status - return PASS +def get_vsss_inst(virt, ip, cn): + try: + enum_list = EnumInstances(ip, cn) + + if enum_list < 1: + logger.error("No %s instances returned", cn) + return None, FAIL + + return enum_list[0], PASS + + except Exception, details: + logger.error(details) + + return None, FAIL @do_main(sup_types) def main(): - global options options = main.options - global conn - global field - global ccn - global name, sys_name, sccn - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) + ccn = get_typed_class(options.virt, "VirtualSystemSnapshotService") - name = "SnapshotService" - status, host_inst = get_host_info(options.ip, options.virt) + + vsss, status = get_vsss_inst(options.virt, options.ip, ccn) if status != PASS: return status - - sccn = host_inst.CreationClassName - sys_name = host_inst.Name - field = 'INVALID_CCName' - status = err_invalid_ccname() - if status != PASS: - return status - field = 'INVALID_Name' - status = err_invalid_name() - if status != PASS: - return status - field = 'INVALID_SCCName' - status = err_invalid_sccname() - if status != PASS: - return status - field = 'INVALID_SName' - status = err_invalid_sname() - if status != PASS: - return status - return PASS + key_vals = { 'SystemName' : vsss.SystemName, + 'CreationClassName' : vsss.CreationClassName, + 'SystemCreationClassName' : vsss.SystemCreationClassName, + 'Name' : vsss.Name + } + + tc_scen = { + 'invalid_ccname' : 'CreationClassName', + 'invalid_sccname' : 'SystemCreationClassName', + 'invalid_name' : 'Name', + 'invalid_sysval' : 'SystemName', + } + + for tc, field in tc_scen.iteritems(): + status = FAIL + + keys = key_vals.copy() + keys[field] = tc + expr_values = expected_values[tc] + + ref = CIMInstanceName(ccn, keybindings=keys) + + 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, desc %s", err_no, err_desc) + logger.error("Expected %s %s", exp_desc, exp_rc) + + if status != PASS: + logger.error("------ FAILED: %s ------", tc) + break + + return status if __name__ == "__main__": sys.exit(main())

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229361894 28800 # Node ID 509194d22352d8c6ca7c0426225ab11b05c7e9f7 # Parent 8feb8f22739358d39e50166712ce069e10bb82af [TEST] #2 Remove try_getinstance() from VSMSD - 02_vsmsd_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. Updates: -Change "return PASS" to "return status" Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 8feb8f227393 -r 509194d22352 suites/libvirt-cim/cimtest/VirtualSystemMigrationSettingData/02_vsmsd_gi_errs.py --- a/suites/libvirt-cim/cimtest/VirtualSystemMigrationSettingData/02_vsmsd_gi_errs.py Fri Dec 12 13:59:35 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationSettingData/02_vsmsd_gi_errs.py Mon Dec 15 09:24:54 2008 -0800 @@ -23,70 +23,64 @@ # -------------- # This tc is used to verify if appropriate exceptions are # returned by Xen_VSMSD on giving invalid inputs. -# 1) Test by giving invalid Invalid InstanceID Key Name -# Input: -# ------ -# wbemcli gi http://localhost:5988/root/virt:\ -# Xen_VirtualSystemMigrationSettingData.Wrong="MigrationSettingData" -nl # -# 2) Test by passing Invalid InstanceID Key Value +# 1) Test by passing Invalid InstanceID Key Value # Input: # ------ # wbemcli gi http://localhost:5988/root/virt:\ # Xen_VirtualSystemMigrationSettingData.InstanceID="Wrong" -nl -# -# Inboth the cases the following exception is verified. # # Output: # ------- # error code : CIM_ERR_NOT_FOUND # error desc : "No such instance (InstanceID)" # -# Date: 06-03-2008 + import sys -import pywbem -from XenKvmLib import assoc -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS -from CimTest.ReturnCodes import PASS -from XenKvmLib.common_util import try_getinstance +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 XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass platform_sup = ['Xen', 'XenFV', 'KVM', 'LXC'] -expr_values = { - "invalid_instid" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (InstanceID)' } - } -def verify_fields(): - classname = get_typed_class(options.virt, "VirtualSystemMigrationSettingData") - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid'], bug_no="") - - @do_main(platform_sup) def main(): - global options options = main.options - global conn - global keys - global field - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) - field = 'INVALID_Instid_KeyName' - keys = { field : "MigrationSettingData" } - status = verify_fields() + expr_values = { + 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (InstanceID)' + } + + cn = get_typed_class(options.virt, 'VirtualSystemMigrationSettingData') + + 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("Expected %s %s", exp_desc, exp_rc) + status = FAIL + if status != PASS: - logger.error("------ FAILED: to check INVALID_Instid_KeyName.------") - return status + logger.error("------ FAILED: Invalid InstanceID Key Value.------") - field = 'INVALID_Instid_KeyValue' - keys = { 'InstanceID' : field } - status = verify_fields() - if status != PASS: - logger.error("------ FAILED: to check INVALID_Instid_KeyValue.------") - return status - - return PASS + return status if __name__ == "__main__": sys.exit(main())

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229040450 28800 # Node ID 7d8eb937a93563b457c12f5c9fe5955aecda55f2 # Parent 509194d22352d8c6ca7c0426225ab11b05c7e9f7 [TEST] Remove try_getinstance() from VSMigC - 02_vsmc_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 509194d22352 -r 7d8eb937a935 suites/libvirt-cim/cimtest/VirtualSystemMigrationCapabilities/02_vsmc_gi_errs.py --- a/suites/libvirt-cim/cimtest/VirtualSystemMigrationCapabilities/02_vsmc_gi_errs.py Mon Dec 15 09:24:54 2008 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationCapabilities/02_vsmc_gi_errs.py Thu Dec 11 16:07:30 2008 -0800 @@ -23,67 +23,63 @@ # Test Case Info: # -------------- # This tc is used to verify if appropriate exceptions are -# returned by Xen_VSMC on giving invalid inputs. -# 1) Test by giving invalid Invalid InstanceID Key Name -# Input: -# ------ -# wbemcli gi http://localhost:5988/root/virt:\ -# Xen_VirtualSystemMigrationCapabilities.Wrong="RPCC" -nl +# returned by VirtualSystemMigrationCapabilities on giving invalid inputs. # -# 2) Test by passing Invalid InstanceID Key Value +# 1) Test by passing Invalid InstanceID Key Value # Input: # ------ # wbemcli gi http://localhost:5988/root/virt:\ # Xen_VirtualSystemMigrationCapabilities.InstanceID="Wrong" -nl # -# Inboth the cases the following exception is verified. -# # Output: # ------- # error code : CIM_ERR_NOT_FOUND # error desc : "No such instance (InstanceID)" -# -# -Date 20.02.2008 import sys -import pywbem -from XenKvmLib import assoc -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS +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.ReturnCodes import PASS, FAIL -from XenKvmLib.common_util import try_getinstance from XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] - -expr_values = { - "invalid_instid" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (InstanceID)' } - } @do_main(sup_types) def main(): options = main.options - status = PASS - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) - classname = get_typed_class(options.virt, 'VirtualSystemMigrationCapabilities') + cn = get_typed_class(options.virt, 'VirtualSystemMigrationCapabilities') - field = 'INVALID_Instid_KeyName' - keys = { field : "RPCC" } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid'], bug_no="") - if ret_value != PASS: - logger.error("------ FAILED: Invalid InstanceID Key Name.------") - status = ret_value + expr_values = { + 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : "No such instance (InstanceID)" + } - field = 'INVALID_Instid_KeyValue' - keys = { 'InstanceID' : field } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid'], bug_no="") - if ret_value != PASS: + 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("Expected %s %s", exp_desc, exp_rc) + status = FAIL + + if status != PASS: logger.error("------ FAILED: Invalid InstanceID Key Value.------") - status = ret_value return status if __name__ == "__main__":

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229361992 28800 # Node ID 556c38de77803f533d093012a86ec93efc2162c9 # Parent 7d8eb937a93563b457c12f5c9fe5955aecda55f2 [TEST] Remove try_getinstance() from RPCS - 02_rcps_gi_errors.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 7d8eb937a935 -r 556c38de7780 suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/02_rcps_gi_errors.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/02_rcps_gi_errors.py Thu Dec 11 16:07:30 2008 -0800 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationService/02_rcps_gi_errors.py Mon Dec 15 09:26:32 2008 -0800 @@ -20,272 +20,117 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # This tc is used to verify if appropriate exceptions are -# returned by Xen_RCPS on giving invalid inputs. +# returned by ResourcePoolConfigurationService on giving invalid inputs. # -# -# Date : 17-02-2008 - -import sys -import pywbem -from CimTest.ReturnCodes import PASS -from XenKvmLib import assoc -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS -from XenKvmLib.common_util import get_host_info, try_getinstance -from XenKvmLib.const import do_main -from XenKvmLib.classes import get_typed_class - -platform_sup = ['Xen', 'KVM', 'XenFV', 'LXC'] -expr_values = { - "invalid_sysname" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (SystemName)' }, \ - "invalid_sccname" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance \ -(SystemCreationClassName)' }, \ - "invalid_name" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (Name)' }, \ - "invalid_ccname" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (CreationClassName)'} - } - - - -def err_invalid_ccname_keyname(conn, classname, hostname, sccname, field): -# Input: +# Input values for the following keys: +# ------------------------------------ +# CreationClassName +# Name +# SystemCreationClassName +# SystemName +# +# Format # ------ # wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.Wrong="Xen_ResourcePoolConfigurationService"\ -# ,Name="RPCS",SystemCreationClassName="Xen_HostSystem",SystemName="mx3650a.in.ibm.com"' -# +# Xen_ResourcePoolConfigurationService.CreationClassName="Wrong",\ +# Name="RPCS",SystemCreationClassName="Xen_HostSystem",\ +# SystemName="mx3650a.in.ibm.com"' +# # Output: # ------- # error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (CreationClassName)" +# error desc : "No such instance (CreationClassName)" (varies by key name) # - keys = { - field : classname, \ - 'Name' : 'RPCS', \ - 'SystemCreationClassName' : sccname, \ - 'SystemName' : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_ccname'], bug_no="") -def err_invalid_ccname_keyvalue(conn, classname, hostname, sccname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName="Wrong",\ -# Name="RPCS",SystemCreationClassName="Xen_HostSystem",SystemName="mx3650a.in.ibm.com"' -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (CreationClassName)" -# - keys = { - 'CreationClassName' : field, \ - 'Name' : 'RPCS', \ - 'SystemCreationClassName' : sccname, \ - 'SystemName' : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_ccname'], bug_no="") +import sys +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 XenKvmLib.classes import get_typed_class +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass, EnumInstances -def err_invalid_name_keyname(conn, classname, hostname, sccname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName=\ -# "Xen_ResourcePoolConfigurationService",Wrong="RCPS",\ -# SystemCreationClassName="Xen_HostSystem",SystemName="mx3650a.in.ibm.com"' -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (Name)" -# - keys = { - 'CreationClassName' : classname, \ - field : 'RPCS', \ - 'SystemCreationClassName' : sccname, \ - 'SystemName' : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_name'], bug_no="") +platform_sup = ['Xen', 'KVM', 'XenFV', 'LXC'] +expected_values = { + "invalid_ccname" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (CreationClassName)' }, + "invalid_sccname" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (SystemCreationClassName)' }, + "invalid_name" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (Name)'}, + "invalid_sysval" : { 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : 'No such instance (SystemName)' }, + } -def err_invalid_name_keyvalue(conn, classname, hostname, sccname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName=\ -# "Xen_ResourcePoolConfigurationService",Name="Wrong",\ -# SystemCreationClassName="Xen_HostSystem",SystemName="mx3650a.in.ibm.com"' -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (Name)" -# - keys = { - 'CreationClassName' : classname, \ - 'Name' : field, \ - 'SystemCreationClassName' : sccname, \ - 'SystemName' : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_name'], bug_no="") +def get_rpcs_inst(virt, ip, cn): + try: + enum_list = EnumInstances(ip, cn) + if len(enum_list) != 1: + logger.error("No %s instances returned", cn) + return None, FAIL -def err_invalid_sccname_keyname(conn, classname, hostname, sccname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName=\ -# "Xen_ResourcePoolConfigurationService",Name="RPCS",\ -# Wrong="Xen_HostSystem",SystemName="mx3650a.in.ibm.com"' -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (SystemCreationClassName)" -# - keys = { - 'CreationClassName' : classname, \ - 'Name' : 'RPCS', \ - field : sccname, \ - 'SystemName' : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_sccname'], - bug_no="") + return enum_list[0], PASS -def err_invalid_sccname_keyvalue(conn, classname, hostname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName=\ -# "Xen_ResourcePoolConfigurationService",Name="RPCS",\ -# SystemCreationClassName="Wrong",SystemName="mx3650a.in.ibm.com"' -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (SystemCreationClassName)" -# - keys = { - 'CreationClassName' : classname, \ - 'Name' : 'RPCS', \ - 'SystemCreationClassName' : field, \ - 'SystemName' : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_sccname'], - bug_no="") + except Exception, details: + logger.error(details) -def err_invalid_sysname_keyname(conn, classname, hostname, sccname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName=\ -# "Xen_ResourcePoolConfigurationService",Name="RPCS",\ -# SystemCreationClassName="Xen_HostSystem",Wrong="mx3650a.in.ibm.com"' -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (SystemName)" -# - keys = { - 'CreationClassName' : classname, \ - 'Name' : 'RPCS', \ - 'SystemCreationClassName' : sccname, \ - field : hostname - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_sysname'], - bug_no="") - -def err_invalid_sysname_keyvalue(conn, classname, sccname, field): -# Input: -# ------ -# wbemcli gi 'http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationService.CreationClassName=\ -# "Xen_ResourcePoolConfigurationService",Name="RPCS",\ -# SystemCreationClassName="Xen_HostSystem",SystemName="Wrong"' -# -# Output: -# ------- -# error code : CIM_ERR_NOT_FOUND -# error desc : "No such instance (SystemName)" -# - keys = { - 'CreationClassName' : classname, \ - 'Name' : 'RPCS', \ - 'SystemCreationClassName' : sccname, \ - 'SystemName' : field - } - return try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_sysname'], - bug_no="") - + return None, FAIL @do_main(platform_sup) def main(): options = main.options - status = PASS server = options.ip - conn = assoc.myWBEMConnection('http://%s' % options.ip, - (CIM_USER, CIM_PASS), CIM_NS) virt = options.virt - status, host_inst = get_host_info(server, virt) + + cn = get_typed_class(virt, 'ResourcePoolConfigurationService') + + rpcs, status = get_rpcs_inst(options.virt, options.ip, cn) if status != PASS: - logger.error("Problem getting host information") return status - sccname = host_inst.CreationClassName - hostname = host_inst.Name + key_vals = { 'SystemName' : rpcs.SystemName, + 'CreationClassName' : rpcs.CreationClassName, + 'SystemCreationClassName' : rpcs.SystemCreationClassName, + 'Name' : rpcs.Name + } - classname = get_typed_class(virt, 'ResourcePoolConfigurationService') - ret_value = err_invalid_ccname_keyname(conn, classname, hostname, sccname, \ - field='INVALID_CCName_KeyName') - if ret_value != PASS: - logger.error("------ FAILED: Invalid CCName Key Name.------") - status = ret_value - ret_value = err_invalid_ccname_keyvalue(conn, classname, hostname, sccname, \ - field='INVALID_CCName_KeyValue') - if ret_value != PASS: - logger.error("------ FAILED: Invalid CCName Key Value.------") - status = ret_value - ret_value = err_invalid_name_keyname(conn, classname, hostname, sccname, \ - field='INVALID_Name_KeyName') - if ret_value != PASS: - logger.error("------ FAILED: Invalid Name Key Name.------") - status = ret_value - ret_value = err_invalid_name_keyvalue(conn, classname, hostname, sccname, \ - field='INVALID_CCName_KeyValue') - if ret_value != PASS: - logger.error("------ FAILED: Invalid Name Key Value.------") - status = ret_value - ret_value = err_invalid_sccname_keyname(conn, classname, hostname, sccname, - field='INVALID_Sys_CCName_KeyName') - if ret_value != PASS: - logger.error("------ FAILED: Invalid System CreationClassName Key Name.------") - status = ret_value - ret_value = err_invalid_sccname_keyvalue(conn, classname, hostname, \ - field='INVALID_Sys_CCName_KeyValue') - if ret_value != PASS: - logger.error("------ FAILED: Invalid System CreationClassName Key Value.------") - status = ret_value - ret_value = err_invalid_sysname_keyname(conn, classname, hostname, sccname, - field='INVALID_SysName_KeyName') - if ret_value != PASS: - logger.error("------ FAILED: Invalid SystemName Key Name.------") - status = ret_value - ret_value = err_invalid_sysname_keyvalue(conn, classname, sccname, \ - field='INVALID_SysName_KeyValue') - if ret_value != PASS: - logger.error("------ FAILED: Invalid SystemName Key Value.------") - status = ret_value + tc_scen = { + 'invalid_ccname' : 'CreationClassName', + 'invalid_sccname' : 'SystemCreationClassName', + 'invalid_name' : 'Name', + 'invalid_sysval' : 'SystemName', + } + + for tc, field in tc_scen.iteritems(): + status = FAIL + + keys = key_vals.copy() + keys[field] = tc + expr_values = expected_values[tc] + + ref = CIMInstanceName(cn, keybindings=keys) + + try: + inst = CIM_CimtestClass(server, 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, desc %s", err_no, err_desc) + logger.error("Expected %s %s", exp_desc, exp_rc) + + if status != PASS: + logger.error("------ FAILED: %s ------", tc) + break + return status if __name__ == "__main__": sys.exit(main())

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1229363128 28800 # Node ID d7e3d5782e205b31d831f2a2d3e0cd2a62f99326 # Parent 556c38de77803f533d093012a86ec93efc2162c9 [TEST] Remove try_getinstance() from RPCC - 02_rpcc_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 556c38de7780 -r d7e3d5782e20 suites/libvirt-cim/cimtest/ResourcePoolConfigurationCapabilities/02_rpcc_gi_errs.py --- a/suites/libvirt-cim/cimtest/ResourcePoolConfigurationCapabilities/02_rpcc_gi_errs.py Mon Dec 15 09:26:32 2008 -0800 +++ b/suites/libvirt-cim/cimtest/ResourcePoolConfigurationCapabilities/02_rpcc_gi_errs.py Mon Dec 15 09:45:28 2008 -0800 @@ -24,19 +24,12 @@ # -------------- # This tc is used to verify if appropriate exceptions are # returned by Xen_RPCC on giving invalid inputs. -# 1) Test by giving invalid Invalid InstanceID Key Name -# Input: -# ------ -# wbemcli gi http://localhost:5988/root/virt:\ -# Xen_ResourcePoolConfigurationCapabilities.Wrong="RPCC" -nl # -# 2) Test by passing Invalid InstanceID Key Value +# 1) Test by passing Invalid InstanceID Key Value # Input: # ------ # wbemcli gi http://localhost:5988/root/virt:\ # Xen_ResourcePoolConfigurationCapabilities.InstanceID="Wrong" -nl -# -# Inboth the cases the following exception is verified. # # Output: # ------- @@ -46,43 +39,49 @@ # -Date 20.02.2008 import sys -import pywbem -from XenKvmLib import assoc +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.classes import get_typed_class -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS from XenKvmLib.const import do_main -from CimTest.ReturnCodes import PASS, FAIL -from XenKvmLib.common_util import try_getinstance +from XenKvmLib.enumclass import GetInstance, CIM_CimtestClass sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] - -expr_values = { - "invalid_instid" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ - 'desc' : 'No such instance (InstanceID)' } - } @do_main(sup_types) def main(): options = main.options - status = PASS - conn = assoc.myWBEMConnection('http://%s' % options.ip, (CIM_USER, CIM_PASS), CIM_NS) - classname = get_typed_class(options.virt, 'ResourcePoolConfigurationCapabilities') - field = 'INVALID_Instid_KeyName' - keys = { field : "RPCC" } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid'], bug_no="") - if ret_value != PASS: - logger.error("------ FAILED: Invalid InstanceID Key Name.------") - status = ret_value + cn = get_typed_class(options.virt, 'ResourcePoolConfigurationCapabilities') - field = 'INVALID_Instid_KeyValue' - keys = { 'InstanceID' : field } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid'], bug_no="") - if ret_value != PASS: + expr_values = { + 'rc' : CIM_ERR_NOT_FOUND, + 'desc' : "No such instance (InstanceID)" + } + + 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("Expected %s %s", exp_desc, exp_rc) + status = FAIL + + if status != PASS: logger.error("------ FAILED: Invalid InstanceID Key Value.------") - status = ret_value return status if __name__ == "__main__":

+1 for this patch set =) Best, Regards Daisy (运国莲) VSM Team, China Systems & Technology Labs (CSTL) E-mail: yunguol@cn.ibm.com TEL: (86)-21-60922403 Building 10, 399 Ke Yuan Rd, Pudong Shanghai, 201203 libvirt-cim-bounces@redhat.com wrote on 2008-12-16 01:45:34:
try_getinstance() really isn't needed anymore as the same functionality can be achieved using the functions in enumclass.py.
Removing try_getinstance() requires essentially a re-write of these tests - they're old, so updates are needed anyway.
More test re-writes will follow in the next set.
Updates; -Only patch 5 of 8 changes - see individual patch for more info
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (2)
-
Guo Lian Yun
-
Kaitlin Rupert