[Libvirt-cim] [PATCH] [TEST] #3 Fix VirtualSystemManagementService/05_destroysystem_neg.py with provider's updates of error message

yunguol at cn.ibm.com yunguol at cn.ibm.com
Tue Mar 17 05:38:30 UTC 2009


# HG changeset patch
# User Guolian Yun <yunguol at cn.ibm.com>
# Date 1237268304 25200
# Node ID 8ab3cd32eec75ce195e51b6c62a4e0b2c7acc56d
# Parent  b1e05c9de638909c5c6a7ba86aa2b3551802d013
[TEST] #3 Fix VirtualSystemManagementService/05_destroysystem_neg.py with provider's updates of error message


Updates from 2 to 3:
1) Move following log message before the if conditional statement
   logger.info("For Invalid Scenario '%s'", tc)
2) Return PASS instead of assign status separately

Updates from 1 to 2:
1) Remove unused import statement
2) Redefine exp_value for different provider version
3) Add log error desc for report mismatching exception

Tested for KVM with current sources and rpm

Signed-off-by: Guolian Yun<yunguol at cn.ibm.com>

diff -r b1e05c9de638 -r 8ab3cd32eec7 suites/libvirt-cim/cimtest/VirtualSystemManagementService/05_destroysystem_neg.py
--- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/05_destroysystem_neg.py	Fri Mar 13 10:31:05 2009 -0700
+++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/05_destroysystem_neg.py	Mon Mar 16 22:38:24 2009 -0700
@@ -20,80 +20,87 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 #
+# This test case is used to verify the VSMS.DestroySystem with invalid vs.
+
 
 import sys
 import pywbem
 from pywbem.cim_obj import CIMInstanceName
-from VirtLib import utils
 from XenKvmLib import vsms
 from XenKvmLib.classes import get_typed_class
-from XenKvmLib.test_doms import undefine_test_domain
 from CimTest.Globals import logger
-from XenKvmLib.const import do_main
+from XenKvmLib.const import do_main, get_provider_version
 from CimTest.ReturnCodes import FAIL, PASS, SKIP
 
 sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
-vsms_status_version = 534
+vsms_err_message = 814
 
 def destroysystem_fail(tc, options):
     service = vsms.get_vsms_class(options.virt)(options.ip)
     
     classname = get_typed_class(options.virt, 'ComputerSystem')
+    curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
 
     if tc == 'noname':
         cs_ref = CIMInstanceName(classname, 
                               keybindings = {'CreationClassName':classname})
 
-        exp_value = { 'rc'    : pywbem.CIM_ERR_FAILED,
-                      'desc'  : 'Unable to retrieve domain name.'
-                    }
+        if curr_cim_rev >= vsms_err_message:
+            exp_value = { 'rc'    : pywbem.CIM_ERR_NOT_FOUND,
+                          'desc'  : 'Unable to retrieve domain name: Error 0'
+                        }
+        else:
+            exp_value = { 'rc'    : pywbem.CIM_ERR_FAILED,
+                          'desc'  : 'Unable to retrieve domain name.'
+                        }
 
     elif tc == 'nonexistent':
         cs_ref = CIMInstanceName(classname,keybindings = {
                                 'Name':'##@@!!cimtest_domain',
                                 'CreationClassName':classname})
 
-        exp_value = { 'rc'   : pywbem.CIM_ERR_FAILED,
-                      'desc' : 'Failed to find domain' 
-                    }
+        if curr_cim_rev >= vsms_err_message:
+            exp_value = { 'rc'   : pywbem.CIM_ERR_NOT_FOUND,
+                          'desc' : "Referenced domain `##@@!!cimtest_domain'" \
+                                   " does not exist: Domain not found"
+                        }
+        else:
+            exp_value = { 'rc'   : pywbem.CIM_ERR_FAILED,
+                          'desc' : 'Failed to find domain'
+                        }
 
-    else:
-        return SKIP
-
-    status = FAIL
     try:
         ret = service.DestroySystem(AffectedSystem=cs_ref)
 
     except Exception, details:
         err_no   = details[0]
         err_desc = details[1]
+        logger.info("For Invalid Scenario '%s'", tc)
         if err_no == exp_value['rc'] and err_desc.find(exp_value['desc']) >= 0:
-            logger.error("For Invalid Scenario '%s'", tc)
             logger.info('Got expected error no: %s', err_no)
             logger.info('Got expected error desc: %s',err_desc)
             return PASS
-
-        logger.error('destroy_fail>> %s: Error executing DestroySystem', tc)
-        logger.error(details)
-        return FAIL
+        else:
+            logger.error('Got error no %s, but expected no %s', 
+                          err_no, exp_value['rc'])
+            logger.error('Got error desc: %s, but expected desc: %s',
+                          err_desc, exp_value['desc'])
+            return FAIL
+    logger.error('destroy_fail>> %s: Error executing DestroySystem', tc)
+    logger.error(details)
+    return FAIL
 
 @do_main(sup_types)
 def main():
     options = main.options
     rc1 = destroysystem_fail('noname', options)
     rc2 = destroysystem_fail('nonexistent', options)
-
+    
     status = FAIL
     if rc1 == PASS and rc2 == PASS:
-        status = PASS
-    else:
-        rclist = [rc1, rc2]
-        rclist.sort()
-        if rclist[0] == PASS and rclist[1] == SKIP:
-            status = PASS
-    
+        return PASS
+
     return status
 
 if __name__ == "__main__":
     sys.exit(main())
-    




More information about the Libvirt-cim mailing list