[PATCH] [TEST] Fix potiential false positive in CS 02

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1215718772 25200 # Node ID 0a4bc49a1fbde309070f8cc4c8631cf4a5ad9c68 # Parent c09b0a978a6621139eb355079994ba3eb2847779 [TEST] Fix potiential false positive in CS 02. Also make it so that the test skips if domain_list() returns anything > 0. This test used to be a Xen only test, so the test was only being run if there were no other guests besides Dom0. However, CS EnumInstances treats Dom0 as any other guest, so it only makes sense to run this test on KVM and LXC. If computersystem.enumerate() encounters an exception, raise an exception so that the calling test case fail appropriately. We could return FAIL in this case, but raising an exception is more descriptive. Also, other tests that call computersystem.enumerate() don't need to be modified because the number of arguments returned doesn't change. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r c09b0a978a66 -r 0a4bc49a1fbd suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Jul 10 11:48:13 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Jul 10 12:39:32 2008 -0700 @@ -27,7 +27,7 @@ from XenKvmLib import computersystem from VirtLib import live from VirtLib import utils -from CimTest.Globals import logger +from CimTest.Globals import logger, CIM_ERROR_ENUMERATE from CimTest.Globals import do_main from CimTest.ReturnCodes import PASS, FAIL, SKIP @@ -35,7 +35,7 @@ def clean_system(host, virt): l = live.domain_list(host, virt) - if len(l) > 1: + if len(l) > 0: return False else: return True @@ -43,19 +43,31 @@ @do_main(sup_types) def main(): options = main.options - if not clean_system(options.ip, options.virt): + + rc = clean_system(options.ip, options.virt) + + if options.virt == "Xen" or options.virt == "XenFV" and rc is True: + logger.error("System has no Dom0 defined; check system health") + return FAIL + elif rc is False: logger.error("System has defined domains; unable to run") return SKIP - status = PASS + cn = "%s_ComputerSystem" % options.virt - cs = computersystem.enumerate(options.ip, options.virt) + try: + cs = computersystem.enumerate(options.ip, options.virt) - if cs.__class__ == str: - logger.error("Got error instead of empty list: %s" % cs) + except Exception, details: + logger.error(CIM_ERROR_ENUMERATE, cn) + logger.error(details) + return FAIL + + if len(cs) != 0: + logger.error("%s returned %d instead of empty list" % (cn, len(cs))) status = FAIL - return status + return PASS if __name__ == "__main__": sys.exit(main()) diff -r c09b0a978a66 -r 0a4bc49a1fbd suites/libvirt-cim/lib/XenKvmLib/computersystem.py --- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Thu Jul 10 11:48:13 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Thu Jul 10 12:39:32 2008 -0700 @@ -85,7 +85,7 @@ try: instances = conn.EnumerateInstances(classname) except pywbem.CIMError, arg: - print arg[1] + raise Exception(arg[1]) return [] list = []

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1215718772 25200 # Node ID 0a4bc49a1fbde309070f8cc4c8631cf4a5ad9c68 # Parent c09b0a978a6621139eb355079994ba3eb2847779 [TEST] Fix potiential false positive in CS 02.
Also make it so that the test skips if domain_list() returns anything > 0.
This test used to be a Xen only test, so the test was only being run if there were no other guests besides Dom0. However, CS EnumInstances treats Dom0 as any other guest, so it only makes sense to run this test on KVM and LXC.
Why don't we just remove Dom-0 from the list and then carry on with the test case for Xen and XenFV ?
If computersystem.enumerate() encounters an exception, raise an exception so that the calling test case fail appropriately. We could return FAIL in this case, but raising an exception is more descriptive. Also, other tests that call computersystem.enumerate() don't need to be modified because the number of arguments returned doesn't change.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r c09b0a978a66 -r 0a4bc49a1fbd suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Jul 10 11:48:13 2008 -0700 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py Thu Jul 10 12:39:32 2008 -0700 @@ -27,7 +27,7 @@ from XenKvmLib import computersystem from VirtLib import live from VirtLib import utils -from CimTest.Globals import logger +from CimTest.Globals import logger, CIM_ERROR_ENUMERATE from CimTest.Globals import do_main from CimTest.ReturnCodes import PASS, FAIL, SKIP
@@ -35,7 +35,7 @@
def clean_system(host, virt): l = live.domain_list(host, virt) - if len(l) > 1: + if len(l) > 0: return False else: return True @@ -43,19 +43,31 @@ @do_main(sup_types) def main(): options = main.options - if not clean_system(options.ip, options.virt): + + rc = clean_system(options.ip, options.virt) + + if options.virt == "Xen" or options.virt == "XenFV" and rc is True: + logger.error("System has no Dom0 defined; check system health") + return FAIL + elif rc is False: logger.error("System has defined domains; unable to run") return SKIP
- status = PASS + cn = "%s_ComputerSystem" % options.virt
Instead of cn = "%s_ComputerSystem" % options.virt We can use the standard get_typed_class(virt, "ComputerSystem"). Either ways is fine. Otherwise +1 for me.
- cs = computersystem.enumerate(options.ip, options.virt) + try: + cs = computersystem.enumerate(options.ip, options.virt)
- if cs.__class__ == str: - logger.error("Got error instead of empty list: %s" % cs) + except Exception, details: + logger.error(CIM_ERROR_ENUMERATE, cn) + logger.error(details) + return FAIL + + if len(cs) != 0: + logger.error("%s returned %d instead of empty list" % (cn, len(cs))) status = FAIL
- return status + return PASS
if __name__ == "__main__": sys.exit(main()) diff -r c09b0a978a66 -r 0a4bc49a1fbd suites/libvirt-cim/lib/XenKvmLib/computersystem.py --- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Thu Jul 10 11:48:13 2008 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py Thu Jul 10 12:39:32 2008 -0700 @@ -85,7 +85,7 @@ try: instances = conn.EnumerateInstances(classname) except pywbem.CIMError, arg: - print arg[1] + raise Exception(arg[1]) return []
list = []
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

DK> Why don't we just remove Dom-0 from the list and then carry on DK> with the test case for Xen and XenFV ? Agreed. At one point, this test did exactly that, and worked on Xen systems with no (other) guests defined. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
DK> Why don't we just remove Dom-0 from the list and then carry on DK> with the test case for Xen and XenFV ?
Agreed. At one point, this test did exactly that, and worked on Xen systems with no (other) guests defined.
My thinking was that the purpose was to verify the EnumInstance() of CS returned no instances when no guests were defined on the system. I'm not sure I understand the purpose of testing with no other guests defined on Xen, because Dom0 is treated as a guest by the providers. The original code was: cs = computersystem.enumerate(options.ip, options.virt) if cs.__class__ == str: logger.error("Got error instead of empty list: %s" % cs) status = FAIL The error message here is misleading - EnumInstances() won't return an empty list on Xen because an instance for Dom0 is returned. And we're not really checking for an empty list anyway. Is this test really checking to make sure EnumInstances() doesn't return an error? If so, the name of the test is misleading. And other tests cover this already (CS 01_enum.py). -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> Is this test really checking to make sure EnumInstances() doesn't KR> return an error? If so, the name of the test is misleading. And KR> other tests cover this already (CS 01_enum.py). Well, I looked at the current test, as well as the original version of it and I'm all confused now. I thought it was doing something different than it is (and was). So, as you say, I think it makes sense to remove Xen and XenFV from the list of runnable platforms and let this test ensure that the providers can handle the case where there are no domains on the system for LXC and KVM. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> Is this test really checking to make sure EnumInstances() doesn't KR> return an error? If so, the name of the test is misleading. And KR> other tests cover this already (CS 01_enum.py).
Well, I looked at the current test, as well as the original version of it and I'm all confused now. I thought it was doing something different than it is (and was). So, as you say, I think it makes sense to remove Xen and XenFV from the list of runnable platforms and let this test ensure that the providers can handle the case where there are no domains on the system for LXC and KVM.
Sure, that works for me. Right now, I have Xen and XenFV in the list (the test should always skip on them). I'll send an updated patch that fixes this test so that it is KVM and LXC only. Thanks! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Dan Smith
-
Deepti B Kalakeri
-
Kaitlin Rupert