yunguol(a)cn.ibm.com wrote:
# HG changeset patch
# User Guolian Yun <yunguol(a)cn.ibm.com>
# Date 1237189564 25200
# Node ID 079bbc777d5b6968c4d2cf0220a509ffc63e820d
# Parent b1e05c9de638909c5c6a7ba86aa2b3551802d013
[TEST] #2 Fix VirtualSystemManagementService/05_destroysystem_neg.py with provider's
updates of error message
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(a)cn.ibm.com>
diff -r b1e05c9de638 -r 079bbc777d5b
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 00:46:04 2009 -0700
@@ -20,47 +20,54 @@
# 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)
@@ -68,30 +75,33 @@
err_no = details[0]
err_desc = details[1]
if err_no == exp_value['rc'] and
err_desc.find(exp_value['desc']) >= 0:
- logger.error("For Invalid Scenario '%s'", tc)
+ logger.info("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("For Invalid Scenario '%s'", tc)
+ 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
You can write the following log message before the if conditional
statement above, we dont need to duplicate the statement.
logger.error("For Invalid Scenario '%s'", tc)
+ 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
No need to assign status separately, instead use return PASS.
else:
- rclist = [rc1, rc2]
- rclist.sort()
- if rclist[0] == PASS and rclist[1] == SKIP:
- status = PASS
-
+ status = FAIL
No need to assign status separately here for else, since status = FAIL
is assigned before the if rc1 == PASS and rc2 == PASS: condition.
+
return status
Or else the main() can written as below:
@do_main(sup_types)
def main():
options = main.options
rc1 = destroysystem_fail('noname', options)
rc2 = destroysystem_fail('nonexistent', options)
if rc1 == PASS and rc2 == PASS:
return PASS
return FAIL
if __name__ == "__main__":
sys.exit(main())
if __name__ == "__main__":
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik(a)linux.vnet.ibm.com