# HG changeset patch
# User Kaitlin Rupert <karupert(a)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(a)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