[Libvirt-cim] [PATCH] [TEST] #2 Add try / except to VSMS 15

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Thu Sep 10 09:14:51 UTC 2009



Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1252002019 25200
> # Node ID 54bf724a87d4dcf370ca68714809cfaaf55457ca
> # Parent  30196cc506c07d81642c94a01fc65b34421c0714
> [TEST] #2 Add try / except to VSMS 15
>
> This will catch any unexpected exceptions.  Otherwise, the exception isn't
> caught and the guest may not be properly undefined
>
> Updates:
>   -Fix Exception() calls to use % instead of a , when specifying arguments
>   -Remove import of default_network_name
>   -Replace destroy() with cim_destroy()
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 30196cc506c0 -r 54bf724a87d4 suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
> --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py	Wed Sep 02 05:11:16 2009 -0700
> +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py	Thu Sep 03 11:20:19 2009 -0700
> @@ -26,7 +26,7 @@
>  from XenKvmLib import vxml
>  from CimTest.Globals import logger
>  from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
> -from XenKvmLib.const import do_main, default_network_name
> +from XenKvmLib.const import do_main
>  from XenKvmLib.classes import get_typed_class, inst_to_mof
>  from XenKvmLib.enumclass import GetInstance 
>  from XenKvmLib.common_util import poll_for_state_change 
> @@ -74,72 +74,70 @@
>      cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
>      service = vsms.get_vsms_class(options.virt)(options.ip)
>
> -    for case in test_cases:
> -        #Each time through, define guest using a default XML
> -        cxml.undefine(options.ip)
> -        cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
> -        ret = cxml.cim_define(options.ip)
> -        if not ret:
> -            logger.error("Failed to define the dom: %s", default_dom)
> -            cleanup_env(options.ip, cxml)
> -            return FAIL
> +    try:
>
> -        if case == "start":
> -            ret = cxml.start(options.ip)
> +        for case in test_cases:
> +            #Each time through, define guest using a default XML
> +            cxml.undefine(options.ip)
> +            cxml = vxml.get_class(options.virt)(default_dom, vcpus=cpu)
> +            ret = cxml.cim_define(options.ip)
>              if not ret:
> -                logger.error("Failed to start %s", default_dom)
> -                cleanup_env(options.ip, cxml)
> -                return FAIL
> +                raise Exception("Failed to define the dom: %s" % default_dom)
>
> -        status, inst = get_vssd(options.ip, options.virt, True)
> -        if status != PASS:
> -            logger.error("Failed to get the VSSD instance for %s", default_dom)
> -            cleanup_env(options.ip, cxml)
> -            return FAIL
> +            if case == "start":
> +                ret = cxml.start(options.ip)
>   
Sorry I missed this one last time, we can use cim_start() instead of 
cxml.start()
> +                if not ret:
> +                    raise Exception("Failed to start %s" % default_dom)
>
> -        inst['AutomaticRecoveryAction'] = pywbem.cim_types.Uint16(RECOVERY_VAL)
> -        vssd = inst_to_mof(inst)
> +            status, inst = get_vssd(options.ip, options.virt, True)
> +            if status != PASS:
> +                raise Expcetion("Failed to get the VSSD instance for %s", 
> +                                default_dom)
>
>   
Need to remove the comma and also ues %
The tc fails with the following error:
VirtualSystemManagementService - 15_mod_system_settings.py: FAIL
--------------------------------------------------------------------
ERROR - CS instance not returned for rstest_domain.
ERROR - Failed to destroy rstest_domain
ERROR - Got CIM error Referenced domain `rstest_domain' does not exist: 
Domain not found with return code 6
InvokeMethod(DestroySystem): Referenced domain `rstest_domain' does not 
exist: Domain not found
--------------------------------------------------------------------

This is because the cim_destroy() is destroying and undefining the VM.
The call to DestroySystem() should only destroy the VM and not undefine 
the VM.
We have not seen this problem in the tests till now because we have 
never verified if DestroySystem() only destroys the domain or undefines 
it as well.
This test case needed the VM to be in the defined state after 
DestroySystem() and hence we caught hold of this error.

Here is the debug message:
misc_util.c(75): Connecting to libvirt with uri `qemu:///system'
misc_util.c(75): Connecting to libvirt with uri `qemu:///system'
misc_util.c(202): URI of connection is: qemu:///system
misc_util.c(202): URI of connection is: qemu:///system
device_parsing.c(273): Disk node: disk
infostore.c(88): Path is /etc/libvirt/cim/QEMU_rstest_domain
Virt_ComputerSystemIndication.c(722): triggered
std_invokemethod.c(305): Method `ModifySystemSettings' returned 0
misc_util.c(75): Connecting to libvirt with uri `qemu:///system'
misc_util.c(202): URI of connection is: qemu:///system
Virt_HostSystem.c(203): SBLIM: Returned instance
std_invokemethod.c(279): Method `DestroySystem' execution attempted
std_invokemethod.c(230): Method parameter `AffectedSystem' validated 
type 0x1100
std_invokemethod.c(303): Executing handler for method `DestroySystem'
misc_util.c(75): Connecting to libvirt with uri `qemu:///system'
Virt_VirtualSystemManagementService.c(1602): Domain successfully 
destroyed and undefined
Virt_ComputerSystemIndication.c(722): triggered
std_invokemethod.c(305): Method `DestroySystem' returned 0

> -        ret = service.ModifySystemSettings(SystemSettings=vssd) 
> -        curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
> -        if curr_cim_rev >= libvirt_modify_setting_changes:
> -            if ret[0] != 0:
> -                logger.error("Failed to modify dom: %s", default_dom)
> -                cleanup_env(options.ip, cxml)
> -                return FAIL
> +            val = pywbem.cim_types.Uint16(RECOVERY_VAL)
> +            inst['AutomaticRecoveryAction'] = val
> +            vssd = inst_to_mof(inst)
>
> -        if case == "start":
> -            #This should be replaced with a RSC to shutdownt he guest
> -            cxml.destroy(options.ip)
> -            status, cs = poll_for_state_change(options.ip, options.virt, 
> -                                               default_dom, DEFINED_STATE)
> +            ret = service.ModifySystemSettings(SystemSettings=vssd) 
> +            curr_cim_rev, changeset = get_provider_version(options.virt, 
> +                                                           options.ip)
> +            if curr_cim_rev >= libvirt_modify_setting_changes:
> +                if ret[0] != 0:
> +                    raise Exception("Failed to modify dom: %s" % default_dom)
> +
> +            if case == "start":
> +                cxml.cim_destroy(options.ip)
> +                status, cs = poll_for_state_change(options.ip, options.virt, 
> +                                                   default_dom, DEFINED_STATE)
> +                if status != PASS:
> +                    raise Exception("Failed to destroy %s" % default_dom)
> +
> +            status, inst = get_vssd(options.ip, options.virt, False)
>              if status != PASS:
> -                logger.error("Failed to destroy %s", default_dom)
> -                cleanup_env(options.ip, cxml)
> -                return FAIL
> +                raise Exception("Failed to get the VSSD instance for %s" % \
> +                                default_dom)
>
> -        status, inst = get_vssd(options.ip, options.virt, False)
> -        if status != PASS:
> -            logger.error("Failed to get the VSSD instance for %s", default_dom)
> -            cleanup_env(options.ip, cxml)
> -            return FAIL
> +            if inst.AutomaticRecoveryAction != RECOVERY_VAL:
> +                logger.error("Exp AutomaticRecoveryAction=%d, got %d", 
> +                             RECOVERY_VAL, inst.AutomaticRecoveryAction)
> +                raise Exception("%s not updated properly" % default_dom)
>
> -        if inst.AutomaticRecoveryAction != RECOVERY_VAL:
> -            logger.error("%s not updated properly.", default_dom)
> -            logger.error("Exp AutomaticRecoveryAction=%d, got %d", RECOVERY_VAL,
> -                         inst.AutomaticRecoveryAction)
> -            cleanup_env(options.ip, cxml)
> -            curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
> -            if curr_cim_rev <= libvirt_f9_revision and options.virt == "KVM":
> -                return XFAIL_RC(f9_bug)
> +            status = PASS
>
> -            if options.virt == "LXC":
> -                return XFAIL_RC(bug)
> -            return FAIL 
> +    except Exception, details:
> +        logger.error(details)
> +        status = FAIL
>
>      cleanup_env(options.ip, cxml)
>
> -    return PASS 
> +    curr_cim_rev, changeset = get_provider_version(options.virt, options.ip)
> +    if curr_cim_rev <= libvirt_f9_revision and options.virt == "KVM":
> +        return XFAIL_RC(f9_bug)
> +
> +    if options.virt == "LXC":
> +        return XFAIL_RC(bug)
> +
> +    return status 
>
>  if __name__ == "__main__":
>      sys.exit(main())
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>   

-- 
Thanks and Regards,
Deepti B. Kalakeri
IBM Linux Technology Center
deeptik at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list