[Libvirt-cim] [PATCH] [TEST] #2 Fix VirtualSystemSettingDataComponent - 01_forward.py failure

Guo Lian Yun yunguol at cn.ibm.com
Wed Jul 2 02:10:01 UTC 2008


+1 from me =)

libvirt-cim-bounces at redhat.com wrote on 2008-07-02 04:59:38:

> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1214945951 25200
> # Node ID 5872801b69296bac39b1b5060e6de2643471f290
> # Parent  ea52dde5ac3e1b10d5aa59b101d91b8ffc5b127e
> [TEST] #2 Fix VirtualSystemSettingDataComponent - 01_forward.py failure.
> 
> Test was expecting one ProcRASD for each domain processor. It should
> expect only one RASD.
> 
> Also updated this test to use PASS/FAIL, removed global variables, 
> and cleaned up indention.
> 
> This test will need to be updated to support other XenFV, etc.
> 
> Updates from 1 to 2:
>   -Fix build_vssd_info() to return FAIL in case of error, not call 
sys.exit().
> 
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
> 
> diff -r ea52dde5ac3e -r 5872801b6929 suites/libvirt-
> cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py
> --- a/suites/libvirt-
> cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py   Tue 
> Jul 01 13:45:25 2008 -0700
> +++ b/suites/libvirt-
> cim/cimtest/VirtualSystemSettingDataComponent/01_forward.py   Tue 
> Jul 01 13:59:11 2008 -0700
> @@ -58,6 +58,7 @@
>  from CimTest import Globals 
>  from XenKvmLib import assoc
>  from CimTest.Globals import logger, do_main
> +from CimTest.ReturnCodes import FAIL, PASS
> 
>  sup_types = ['Xen']
> 
> @@ -67,64 +68,49 @@
>  test_disk   = 'xvda'
>  status      = 0
>  VSType      = "Xen"
> -vssd_names  = []
> -vssd_values = []
> 
> -RASD_cllist = [
> -          'Xen_DiskResourceAllocationSettingData', \
> -          'Xen_MemResourceAllocationSettingData',  \
> -          'Xen_NetResourceAllocationSettingData',  \
> -          'Xen_ProcResourceAllocationSettingData'
> -         ]
> - 
>  def init_list():
>      """
>          Creating the lists that will be used for comparisons.
>      """
> -    prop_list = [] 
> -    prop_list = ["%s/%s"  % (test_dom, test_disk), \
> -                 "%s/%s" % (test_dom, "mem"), \
> -                 "%s/%s" % (test_dom, test_mac)
> -                ]
> -    proc_list = []
> -    for i in range(test_vcpus):
> -        proc_list.append("%s/%s" % (test_dom, i))
> -    return prop_list, proc_list
> +
> +    rlist = ['Xen_DiskResourceAllocationSettingData',
> +             'Xen_MemResourceAllocationSettingData',
> +             'Xen_NetResourceAllocationSettingData',
> +             'Xen_ProcResourceAllocationSettingData'
> +            ]
> +
> +    prop_list = {rlist[0] : "%s/%s"  % (test_dom, test_disk),
> +                 rlist[1] : "%s/%s" % (test_dom, "mem"),
> +                 rlist[2] : "%s/%s" % (test_dom, test_mac),
> +                 rlist[3] : "%s/%s" % (test_dom, "proc")
> +                }
> +
> +    return prop_list
> 
>  def build_vssd_info(ip, vssd):
>      """
>          Creating the vssd fileds lists that will be used for 
comparisons.
>      """
> -    global vssd_names, vssd_values
> 
>      if vssd.Bootloader == "" or vssd.Caption == "" or \
>        vssd.InstanceID == "" or vssd.ElementName == "" or \
>        vssd.VirtualSystemIdentifier == "" or vssd.VirtualSystemType == 
"":
>          logger.error("One of the required VSSD details seems to be 
empty")
> -        status = 1
>          test_domain_function(test_dom, ip, "undefine")
> -        sys.exit(status)
> +        return FAIL
> 
> -    vssd_names = [
> -                  'Bootloader',    \
> -                  'Caption',       \
> -                  'InstanceID',    \
> -                  'ElementName',   \
> -        'VirtualSystemIdentifier', \
> -              'VirtualSystemType', \
> -    ]
> - 
> -    vssd_values = [
> -                    vssd.Bootloader,  \
> -                       vssd.Caption,  \
> -                     vssd.InstanceID, \
> -                    vssd.ElementName, \
> -        vssd.VirtualSystemIdentifier, \
> -              vssd.VirtualSystemType, \
> -       ]
> +    vssd_vals = {'Bootloader'         : vssd.Bootloader,
> +                 'Caption'         : vssd.Caption,
> +                 'InstanceID'         : vssd.InstanceID,
> +                 'ElementName'         : vssd.ElementName,
> +                 'VirtualSystemIdentifier'   : 
vssd.VirtualSystemIdentifier,
> +                 'VirtualSystemType'      : vssd.VirtualSystemType
> +                }
> 
> +    return vssd_vals
> 
> -def assoc_values(ip, assoc_info, cn):
> +def assoc_values(ip, assoc_info, cn, an, vals):
>      """
>          The association info of 
>          Xen_VirtualSystemSettingDataComponent with every RASDclass is
> @@ -132,36 +118,29 @@
>          Caption, InstanceID, ElementName, VirtualSystemIdentifier,
>          VirtualSystemType, Bootloader
>      """
> -    global status
> -    global vssd_names, vssd_values
> 
>      try: 
>          if len(assoc_info) != 1:
> -            Globals.logger.error("Xen_VirtualSystemSettingDataComponent 
\
> -returned %i Resource objects for class '%s'", len(assoc_info),cn)
> -            status = 1
> -            return status
> +            Globals.logger.error("%s returned %i resource objects 
> for '%s'" % \
> +                                 (an, len(assoc_info), cn))
> +            return FAIL 
> 
> -        for idx in range(len(vssd_names)):
> -            if assoc_info[0][vssd_names[idx]] != vssd_values[idx]:
> -                Globals.logger.error("%s Mismatch", vssd_names[idx])
> -                Globals.logger.error("Returned %s instead of %s", \
> -                               assoc_info[0][vssd_names[idx]], \
> -                                                vssd_fields[idx])
> -                status = 1
> -            if status != 0:
> -                break
> +        for prop, val in vals.iteritems():
> +            if assoc_info[0][prop] != val:
> +                Globals.logger.error("%s mismatch: returned %s 
> instead of %s" %\
> +                                     (prop, assoc_info[0][prop], val))
> +                return FAIL
> +
> +        return PASS
> +
>      except  Exception, detail :
>          logger.error("Exception in assoc_values function: %s" % detail)
> -        status = 1
> -        test_domain_function(test_dom, ip, "undefine")
> -        return status
> -
> +        return FAIL 
> 
>  @do_main(sup_types)
>  def main():
>      options = main.options
> -    global  status 
> +    status = FAIL
> 
>      destroy_and_undefine_all(options.ip)
>      test_xml = testxml_bl(test_dom, vcpus = test_vcpus, \
> @@ -171,9 +150,7 @@
>      ret = test_domain_function(test_xml, options.ip, cmd = "define")
>      if not ret:
>          logger.error("Failed to define the dom: %s", test_dom)
> -        status = 1
> -        return status
> -
> +        return FAIL 
> 
>      instIdval = "%s:%s" % (VSType, test_dom)
>      keyname = "InstanceID"
> @@ -183,48 +160,39 @@
>          vssd = enumclass.getInstance(options.ip, \
> enumclass.Xen_VirtualSystemSettingData, \
>                                      key_list)
> -        build_vssd_info(options.ip, vssd)
> +        if vssd is None:
> +            logger.error("VSSD instance for %s not found" % test_dom)
> +            test_domain_function(test_dom, options.ip, "undefine")
> +            return FAIL
> +
> +        vssd_vals = build_vssd_info(options.ip, vssd)
> 
>      except  Exception, detail :
>          logger.error(Globals.CIM_ERROR_GETINSTANCE, \
> - 'Xen_VirtualSystemSettingData')
> +                     'Xen_VirtualSystemSettingData')
>          logger.error("Exception : %s" % detail)
>          test_domain_function(test_dom, options.ip, "undefine")
> -        status = 1
> -        return status
> +        return FAIL 
> 
> -    prop_list, proc_list = init_list() 
> +    prop_list = init_list()
> 
>      try:
> -        idx = 0
> -    # Looping through the RASD_cllist, call association 
> -    # Xen_VirtualSystemSettingDataComponent with each class in 
RASD_cllist
> -        for rasd_cname in RASD_cllist:
> -            if rasd_cname != 'Xen_ProcResourceAllocationSettingData':
> -                assoc_info = assoc.Associators(options.ip, \
> - 
> 'Xen_VirtualSystemSettingDataComponent', \
> - 
> rasd_cname, \
> -                                                   InstanceID = 
> prop_list[idx])
> -             # Verify the association fields returned for 
> particular rasd_cname.
> -                assoc_values(options.ip, assoc_info, rasd_cname)
> -                idx = idx + 1
> -            else:
> -            # Xen_ProcResourceAllocationSettingData, we need to find 
> -            # association information for all the proc InstanceID and 
hence 
> -            # we loop from 0 to (test_vcpus - 1 )
> -                for index in range(len(proc_list)): 
> -                    assoc_info = assoc.Associators(options.ip, \
> - 
> 'Xen_VirtualSystemSettingDataComponent', \
> - 
> rasd_cname, \
> -                                                  InstanceID = 
> prop_list[index])
> +        # Looping through the RASD_cllist, call association 
> +        # Xen_VirtualSystemSettingDataComponent with each class in 
> RASD_cllist
> +        an = 'Xen_VirtualSystemSettingDataComponent'
> +        for rasd_cname, prop in prop_list.iteritems():
> +            assoc_info = assoc.Associators(options.ip, an, rasd_cname,
> +                                           InstanceID = prop)
>              # Verify the association fields returned for particular
> rasd_cname.
> -                    assoc_values(options.ip, assoc_info, rasd_cname)
> +            status = assoc_values(options.ip, assoc_info, rasd_cname, 
an, 
> +                                  vssd_vals)
> +            if status != PASS:
> +                break
> 
>      except  Exception, detail :
> -        logger.error(Globals.CIM_ERROR_ASSOCIATORS, \
> - 
> 'Xen_VirtualSystemSettingDataComponent')
> +        logger.error(Globals.CIM_ERROR_ASSOCIATORS, an)
>          logger.error("Exception : %s" % detail)
> -        status = 1 
> +        status = FAIL
> 
>      test_domain_function(test_dom, options.ip, "undefine")
>      return status
> 
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20080702/16b2fa31/attachment.htm>


More information about the Libvirt-cim mailing list