[Libvirt-cim] [PATCH] [TEST] Fix potiential false positive in CS 02

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Thu Jul 17 10:08:29 UTC 2008



Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at 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 at 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 at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
>   




More information about the Libvirt-cim mailing list