[PATCH] [TEST] #4 Fix HostedService-04_reverse_errs.py to work with sblim base provider installed

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1223273159 25200 # Node ID 3e0a467ec1227d04e2478ff7c10447a00459d246 # Parent b710ecb26adf500caa6b801fdf10e4efbed3877e [TEST] #4 Fix HostedService-04_reverse_errs.py to work with sblim base provider installed Updates form 3 to 4: verifying the complete exception instead of just verifying part of it Follow up patch will to verify other exceptions except invalid Name Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r b710ecb26adf -r 3e0a467ec122 suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py --- a/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py Fri Oct 03 06:34:29 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py Sun Oct 05 23:05:59 2008 -0700 @@ -25,6 +25,7 @@ from pywbem.cim_obj import CIMInstanceNa from pywbem.cim_obj import CIMInstanceName from XenKvmLib import assoc from XenKvmLib import enumclass +from XenKvmLib.common_util import get_host_info from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, CIM_USER, \ CIM_PASS, CIM_NS @@ -33,20 +34,17 @@ from CimTest.ReturnCodes import PASS, FA sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] exp_rc = 6 #CIM_ERR_NOT_FOUND -exp_desc = "No such instance" +exp_desc = "No such instance (Name)" @do_main(sup_types) def main(): options = main.options rc = -1 status = FAIL - keys = ['Name', 'CreationClassName'] - try: - host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] - except Exception: - logger.error(CIM_ERROR_ENUMERATE % host_sys.name) + status, host_name, host_ccn = get_host_info(options.ip, options.virt) + if status != PASS: + logger.error("Error in calling get_host_info function") return FAIL - servicelist = {get_typed_class(options.virt, "ResourcePoolConfigurationService") : "RPCS", get_typed_class(options.virt, "VirtualSystemManagementService") : "Management Service", @@ -59,13 +57,14 @@ def main(): for k, v in servicelist.items(): instanceref = CIMInstanceName(k, keybindings = {"Wrong" : v, - "CreationClassName" : "wrong", - "SystemCreationClassName" : host_sys.CreationClassName, - "SystemName" : host_sys.Name}) + "CreationClassName" : k, + "SystemCreationClassName" : host_ccn, + "SystemName" : host_name}) names = [] - + + assoc_class = get_typed_class(options.virt, "HostedService") try: - names = conn.AssociatorNames(instanceref, AssocClass = get_typed_class(options.virt, "HostedService")) + names = conn.AssociatorNames(instanceref, AssocClass = assoc_class) rc = 0 except pywbem.CIMError, (rc, desc): if rc == exp_rc and desc.find(exp_desc) >= 0: @@ -78,7 +77,8 @@ def main(): logger.error(details) if rc == 0: - logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of %s input" % k) + logger.error("HostedService associator should NOT return excepted result\ + with a wrong key name and value of %s input" % k) status = FAIL return status

libvirt-cim-bounces@redhat.com wrote on 2008-10-06 20:55:58:
yunguol@cn.ibm.com wrote: # HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1223273159 25200 # Node ID 3e0a467ec1227d04e2478ff7c10447a00459d246 # Parent b710ecb26adf500caa6b801fdf10e4efbed3877e [TEST] #4 Fix HostedService-04_reverse_errs.py to work with sblim base provider installed
Updates form 3 to 4:
verifying the complete exception instead of just verifying part of it
Follow up patch will to verify other exceptions except invalid Name
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r b710ecb26adf -r 3e0a467ec122 suites/libvirt- cim/cimtest/HostedService/04_reverse_errs.py --- a/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py Fri Oct 03 06:34:29 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedService/04_reverse_errs.py Sun Oct 05 23:05:59 2008 -0700 @@ -25,6 +25,7 @@ from pywbem.cim_obj import CIMInstanceNa from pywbem.cim_obj import CIMInstanceName from XenKvmLib import assoc from XenKvmLib import enumclass +from XenKvmLib.common_util import get_host_info from XenKvmLib.classes import get_typed_class from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, CIM_USER, \ CIM_PASS, CIM_NS @@ -33,20 +34,17 @@ from CimTest.ReturnCodes import PASS, FA
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC'] exp_rc = 6 #CIM_ERR_NOT_FOUND -exp_desc = "No such instance" +exp_desc = "No such instance (Name)"
@do_main(sup_types) def main(): options = main.options rc = -1 status = FAIL - keys = ['Name', 'CreationClassName'] - try: - host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] - except Exception: - logger.error(CIM_ERROR_ENUMERATE % host_sys.name) + status, host_name, host_ccn = get_host_info(options.ip,
options.virt)
+ if status != PASS: + logger.error("Error in calling get_host_info function") return FAIL -
servicelist = {get_typed_class(options.virt, "ResourcePoolConfigurationService") : "RPCS", get_typed_class(options.virt, "VirtualSystemManagementService") : "Management Service",
We should indent the lines to 80 columns. @@ -59,13 +57,14 @@ def main(): for k, v in servicelist.items(): instanceref = CIMInstanceName(k, keybindings = {"Wrong" : v, - "CreationClassName" : "wrong", - "SystemCreationClassName" : host_sys.CreationClassName, - "SystemName" : host_sys.Name}) + "CreationClassName" : k, + "SystemCreationClassName" : host_ccn,
Wrap this line to 80 columns. + "SystemName" : host_name}) names = [] - + + assoc_class = get_typed_class(options.virt, "HostedService") try: - names = conn.AssociatorNames(instanceref, AssocClass = get_typed_class(options.virt, "HostedService")) + names = conn.AssociatorNames(instanceref, AssocClass = assoc_class) rc = 0 except pywbem.CIMError, (rc, desc): if rc == exp_rc and desc.find(exp_desc) >= 0: @@ -78,7 +77,8 @@ def main(): logger.error(details)
if rc == 0: - logger.error("HostedService associator should NOT return excepted result with a wrong key name and value of %s input" % k) + logger.error("HostedService associator should NOT return excepted result\ + with a wrong key name and value of %s input" % k)
Need to align this log msg as this will give lot of space between result and with as below: HostedService associator should NOT return excepted result with a wrong key name and value of Xen_ResourcePoolConfigurationService input Also, you can use the association name variable assoc_class instead of hardcoding it as below: logger.error("'%s' associator should NOT return records " "with a wrong key name and CreationClassName value of % s input", assoc_class, k)
status = FAIL
return status Misplaced return statement , this will exit after checking for RPCS and the loop will not execute the VirtualSystemMigrationService and VirtualSystemManagementService checks. Also, you can replace calling Associators() and verifications, with the library function try_assoc() of common_util.py to verify the exceptions for the associtations.
I replace it using try_assoc() function to verify the exceptions. Thanks!
This is not related to your changes, but can you change the following
log msg
logger.error("Unknown exception happened") to logger.error("Unknown exception")
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim _______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
participants (3)
-
Deepti B Kalakeri
-
Guo Lian Yun
-
yunguol@cn.ibm.com