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

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Tue Jul 22 06:31:35 UTC 2008


+1 for me.

Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1216654535 25200
> # Node ID 29ede6f3ff473886fa928a83fd62a0a192493b7e
> # Parent  de486893703609719ea79d53ee64828537826211
> [TEST] #2 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.
>
> Updates from 1 to 2:
>   -Remove Xen and XenFV from the supported platforms list.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r de4868937036 -r 29ede6f3ff47 suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py
> --- a/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py	Sat Jul 19 14:17:09 2008 -0700
> +++ b/suites/libvirt-cim/cimtest/ComputerSystem/02_nosystems.py	Mon Jul 21 08:35:35 2008 -0700
> @@ -27,15 +27,15 @@
>  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
>
> -sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
> +sup_types = ['KVM', 'LXC']
>
>  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,28 @@
>  @do_main(sup_types)
>  def main():
>      options = main.options
> +
>      if not clean_system(options.ip, options.virt):
>          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
> +    else:
> +        status = PASS
>
> -    return status
> +    return status 
>
>  if __name__ == "__main__":
>      sys.exit(main())
> diff -r de4868937036 -r 29ede6f3ff47 suites/libvirt-cim/lib/XenKvmLib/computersystem.py
> --- a/suites/libvirt-cim/lib/XenKvmLib/computersystem.py	Sat Jul 19 14:17:09 2008 -0700
> +++ b/suites/libvirt-cim/lib/XenKvmLib/computersystem.py	Mon Jul 21 08:35:35 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