[Libvirt-cim] [PATCH 6 of 8] [TEST] Remove try_getinstance() from VSMigC - 02_vsmc_gi_errs.py

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Dec 15 17:45:40 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at 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 at 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__":




More information about the Libvirt-cim mailing list