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