[PATCH] [TEST] Fix HostedResourcePool/01_forward.py to work with sblim base provider installed

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1223359324 25200 # Node ID d81c2122fff796c7a08eb45cfe679f2e690e27bf # Parent 311bf6eda3786eb8e47ede06c4da6dc1570aff61 [TEST] Fix HostedResourcePool/01_forward.py to work with sblim base provider installed Signed-off-by: Guolian Yun <yunguol@cn.ibm.com> diff -r 311bf6eda378 -r d81c2122fff7 suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py --- a/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Sun Oct 05 23:56:40 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Mon Oct 06 23:02:04 2008 -0700 @@ -26,13 +26,15 @@ import sys import sys from XenKvmLib import assoc from XenKvmLib import enumclass +from XenKvmLib.common_util import get_host_info from XenKvmLib.const import default_network_name from CimTest import Globals from CimTest.Globals import logger -from CimTest.ReturnCodes import PASS, FAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC from XenKvmLib.const import do_main, default_pool_name from XenKvmLib.classes import get_typed_class +bug = '00007' sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @do_main(sup_types) def main(): @@ -40,19 +42,17 @@ def main(): status = FAIL keys = ['Name', 'CreationClassName'] - try: - host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] - except Exception: - host_cn = get_typed_class(options.virt, "HostSystem") - logger.error(Globals.CIM_ERROR_ENUMERATE % host_cn) + status, host_sys, host_cn = get_host_info(options.ip, options.virt) + if status != PASS: + logger.error("Error in calling get_host_info function") return FAIL try: assoc_cn = get_typed_class(options.virt, "HostedResourcePool") pool = assoc.AssociatorNames(options.ip, assoc_cn, - host_sys.CreationClassName, - Name = host_sys.Name, - CreationClassName = host_sys.CreationClassName) + host_cn, + Name = host_sys, + CreationClassName = host_cn) except Exception, details: logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % assoc_cn) logger.error("Exception:", details) @@ -62,8 +62,11 @@ def main(): logger.error("System association failed") return FAIL elif len(pool) == 0: - logger.error("No pool returned") - return FAIL + if host_cn == 'Linux_ComputerSystem': + return XFAIL_RC(bug) + else: + logger.error("No pool returned") + return FAIL for items in pool: cname = items.classname

+1 for the changes in this patch. Daisy, I have some more comments on the tc which is not part of the changes you have made. At the end of the tc we have a for loop to verify the resourcepool details. With the existing changes we might get a false positive because before entering the loop the status is already assigned to PASS by get_host_info() call if it succeeds. After entering the for loop even when none of the if conditions match we will still have the status set to PASS and there are possibilities of the tc returning false positives because of the status already being set to PASS. Can you change the below in the tc : for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] == "MemoryPool/0": status = PASS if cname.find("ProcessorPool") >=0 and items['InstanceID'] == "ProcessorPool/0": status = PASS if cname.find("NetworkPool") >=0 and \ items['InstanceID'] == "NetworkPool/%s" %default_network_name: status = PASS if cname.find("DiskPool") >=0 and \ items['InstanceID'] == "DiskPool/%s" % default_pool_name: status = PASS To status = FAIL for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] == "MemoryPool/0": status = PASS if cname.find("ProcessorPool") >=0 and items['InstanceID'] == "ProcessorPool/0": status = PASS if cname.find("NetworkPool") >=0 and \ items['InstanceID'] == "NetworkPool/%s" %default_network_name: status = PASS if cname.find("DiskPool") >=0 and \ items['InstanceID'] == "DiskPool/%s" % default_pool_name: status = PASS if status != PASS: logger.error("HostedResourcePool information error") return status If you have anyother better ideas, you are welcome to do the changes accordingly. Thanks and Regards, Deepti. yunguol@cn.ibm.com wrote:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1223359324 25200 # Node ID d81c2122fff796c7a08eb45cfe679f2e690e27bf # Parent 311bf6eda3786eb8e47ede06c4da6dc1570aff61 [TEST] Fix HostedResourcePool/01_forward.py to work with sblim base provider installed
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r 311bf6eda378 -r d81c2122fff7 suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py --- a/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Sun Oct 05 23:56:40 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Mon Oct 06 23:02:04 2008 -0700 @@ -26,13 +26,15 @@ import sys import sys from XenKvmLib import assoc from XenKvmLib import enumclass +from XenKvmLib.common_util import get_host_info from XenKvmLib.const import default_network_name from CimTest import Globals from CimTest.Globals import logger -from CimTest.ReturnCodes import PASS, FAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC from XenKvmLib.const import do_main, default_pool_name from XenKvmLib.classes import get_typed_class
+bug = '00007' sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @do_main(sup_types) def main(): @@ -40,19 +42,17 @@ def main(): status = FAIL
keys = ['Name', 'CreationClassName'] - try: - host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] - except Exception: - host_cn = get_typed_class(options.virt, "HostSystem") - logger.error(Globals.CIM_ERROR_ENUMERATE % host_cn) + status, host_sys, host_cn = get_host_info(options.ip, options.virt) + if status != PASS: + logger.error("Error in calling get_host_info function") return FAIL try: assoc_cn = get_typed_class(options.virt, "HostedResourcePool") pool = assoc.AssociatorNames(options.ip, assoc_cn, - host_sys.CreationClassName, - Name = host_sys.Name, - CreationClassName = host_sys.CreationClassName) + host_cn, + Name = host_sys, + CreationClassName = host_cn) except Exception, details: logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % assoc_cn) logger.error("Exception:", details) @@ -62,8 +62,11 @@ def main(): logger.error("System association failed") return FAIL elif len(pool) == 0: - logger.error("No pool returned") - return FAIL + if host_cn == 'Linux_ComputerSystem': + return XFAIL_RC(bug) + else: + logger.error("No pool returned") + return FAIL
for items in pool: cname = items.classname
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

status = FAIL for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] == "MemoryPool/0": status = PASS if cname.find("ProcessorPool") >=0 and items['InstanceID'] == "ProcessorPool/0": status = PASS if cname.find("NetworkPool") >=0 and \ items['InstanceID'] == "NetworkPool/%s" %default_network_name: status = PASS if cname.find("DiskPool") >=0 and \ items['InstanceID'] == "DiskPool/%s" % default_pool_name: status = PASS if status != PASS: logger.error("HostedResourcePool information error") return status
If you hit an error condition, the test should return - no point in checking the other conditions when we already know we've failed. Plus, the error log message is really vague. Instead, you could do something like: try: for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] != "MemoryPool/0": raise Exception("%s does not match MemoryPool/0", items['InstanceID']) elif cname.find("ProcessorPool") >=0 and items['InstanceID'] != "ProcessorPool/0": raise Exception("%s does not match ProcessorPool/0", items['InstanceID']) elif cname.find("NetworkPool") >= 0 and \ items['InstanceID'] != "NetworkPool/%s" %default_network_name: raise Exception("%s does not match NetworkPool/%s", items['InstanceID'], default_network_name) elif cname.find("DiskPool") >= 0 and \ items['InstanceID'] != "DiskPool/%s" % default_pool_name: raise Exception("%s does not match DiskPool/%s", items['InstanceID'], default_pool_name) except Exception, details: logger.error(details) return FAIL return PASS -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2008-10-08 01:24:54:
status = FAIL for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] == "MemoryPool/0": status = PASS if cname.find("ProcessorPool") >=0 and items['InstanceID'] == "ProcessorPool/0": status = PASS if cname.find("NetworkPool") >=0 and \ items['InstanceID'] == "NetworkPool/%s" %default_network_name: status = PASS if cname.find("DiskPool") >=0 and \ items['InstanceID'] == "DiskPool/%s" % default_pool_name: status = PASS if status != PASS: logger.error("HostedResourcePool information error") return status
If you hit an error condition, the test should return - no point in checking the other conditions when we already know we've failed. Plus, the error log message is really vague.
Instead, you could do something like:
try: for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] != "MemoryPool/0": raise Exception("%s does not match MemoryPool/0", items['InstanceID'])
elif cname.find("ProcessorPool") >=0 and items['InstanceID'] != "ProcessorPool/0": raise Exception("%s does not match ProcessorPool/0", items['InstanceID'])
elif cname.find("NetworkPool") >= 0 and \ items['InstanceID'] != "NetworkPool/%s" %default_network_name: raise Exception("%s does not match NetworkPool/%s", items['InstanceID'], default_network_name)
elif cname.find("DiskPool") >= 0 and \ items['InstanceID'] != "DiskPool/%s" % default_pool_name: raise Exception("%s does not match DiskPool/%s", items['InstanceID'], default_pool_name)
except Exception, details: logger.error(details) return FAIL
return PASS
Kaitlin - That sounds good to me. Thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+1 for the changes in this patch. Daisy, I have some more comments on the tc which is not part of the changes you have made. At the end of the tc we have a for loop to verify the resourcepool
libvirt-cim-bounces@redhat.com wrote on 2008-10-07 19:49:24: details.
With the existing changes we might get a false positive because before entering the loop the status is already assigned to PASS by get_host_info() call if it succeeds. After entering the for loop even when none of the if conditions match we
will still have the status set to PASS and there are possibilities of the tc returning false positives because of the status already being set to PASS. Can you change the below in the tc :
for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] == "MemoryPool/0": status = PASS if cname.find("ProcessorPool") >=0 and items['InstanceID'] == "ProcessorPool/0": status = PASS if cname.find("NetworkPool") >=0 and \ items['InstanceID'] == "NetworkPool/%s" %default_network_name: status = PASS if cname.find("DiskPool") >=0 and \ items['InstanceID'] == "DiskPool/%s" % default_pool_name: status = PASS To
status = FAIL for items in pool: cname = items.classname if cname.find("MemoryPool") >=0 and items['InstanceID'] == "MemoryPool/0": status = PASS if cname.find("ProcessorPool") >=0 and items['InstanceID'] == "ProcessorPool/0": status = PASS if cname.find("NetworkPool") >=0 and \ items['InstanceID'] == "NetworkPool/%s" %default_network_name: status = PASS if cname.find("DiskPool") >=0 and \ items['InstanceID'] == "DiskPool/%s" % default_pool_name: status = PASS if status != PASS: logger.error("HostedResourcePool information error") return status
If you have anyother better ideas, you are welcome to do the changes accordingly.
Your idea sounds good to me. I cook up a patch for it. Thanks!
Thanks and Regards, Deepti.
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1223359324 25200 # Node ID d81c2122fff796c7a08eb45cfe679f2e690e27bf # Parent 311bf6eda3786eb8e47ede06c4da6dc1570aff61 [TEST] Fix HostedResourcePool/01_forward.py to work with sblim
yunguol@cn.ibm.com wrote: base provider installed
Signed-off-by: Guolian Yun <yunguol@cn.ibm.com>
diff -r 311bf6eda378 -r d81c2122fff7 suites/libvirt-
cim/cimtest/HostedResourcePool/01_forward.py
--- a/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Sun Oct 05 23:56:40 2008 -0700 +++ b/suites/libvirt-cim/cimtest/HostedResourcePool/01_forward.py Mon Oct 06 23:02:04 2008 -0700 @@ -26,13 +26,15 @@ import sys import sys from XenKvmLib import assoc from XenKvmLib import enumclass +from XenKvmLib.common_util import get_host_info from XenKvmLib.const import default_network_name from CimTest import Globals from CimTest.Globals import logger -from CimTest.ReturnCodes import PASS, FAIL +from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC from XenKvmLib.const import do_main, default_pool_name from XenKvmLib.classes import get_typed_class
+bug = '00007' sup_types = ['Xen', 'KVM', 'XenFV', 'LXC'] @do_main(sup_types) def main(): @@ -40,19 +42,17 @@ def main(): status = FAIL
keys = ['Name', 'CreationClassName'] - try: - host_sys = enumclass.enumerate(options.ip, 'HostSystem', keys, options.virt)[0] - except Exception: - host_cn = get_typed_class(options.virt, "HostSystem") - logger.error(Globals.CIM_ERROR_ENUMERATE % host_cn) + status, host_sys, host_cn = get_host_info(options.ip,
options.virt)
+ if status != PASS: + logger.error("Error in calling get_host_info function") return FAIL try: assoc_cn = get_typed_class(options.virt, "HostedResourcePool") pool = assoc.AssociatorNames(options.ip, assoc_cn, - host_sys.CreationClassName, - Name = host_sys.Name, - CreationClassName = host_sys.CreationClassName) + host_cn, + Name = host_sys, + CreationClassName = host_cn) except Exception, details: logger.error(Globals.CIM_ERROR_ASSOCIATORNAMES % assoc_cn) logger.error("Exception:", details) @@ -62,8 +62,11 @@ def main(): logger.error("System association failed") return FAIL elif len(pool) == 0: - logger.error("No pool returned") - return FAIL + if host_cn == 'Linux_ComputerSystem': + return XFAIL_RC(bug) + else: + logger.error("No pool returned") + return FAIL
for items in pool: cname = items.classname
_______________________________________________ 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 (4)
-
Deepti B Kalakeri
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com