[Libvirt-cim] [PATCH] [TEST] Update CS 05_activate_defined_start.py

Deepti B Kalakeri deeptik at linux.vnet.ibm.com
Tue Dec 30 10:33:43 UTC 2008



Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert <karupert at us.ibm.com>
> # Date 1230073420 28800
> # Node ID a9826c20a65bc16c2c205b183e4fa8eafde08d30
> # Parent  660adffeba4f0bc2b9d54f8b5c750fbc623ca791
> [TEST] Update CS 05_activate_defined_start.py
>
> Re-wrote this test to fix readibilty and layout.
>
> Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>
>
> diff -r 660adffeba4f -r a9826c20a65b suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py
> --- a/suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py	Tue Dec 23 13:51:22 2008 -0800
> +++ b/suites/libvirt-cim/cimtest/ComputerSystem/05_activate_defined_start.py	Tue Dec 23 15:03:40 2008 -0800
> @@ -42,19 +42,17 @@
>  #						Date  : 17-10-2007
>
>  import sys
> -from XenKvmLib import enumclass
> -from XenKvmLib import vxml
> -from VirtLib import utils
> +from XenKvmLib.enumclass import GetInstance 
> +from XenKvmLib.vxml import get_class 
>  from CimTest.Globals import logger
>  from XenKvmLib.const import do_main
>  from XenKvmLib.classes import get_typed_class
> -from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
> +from CimTest.ReturnCodes import PASS, FAIL
>
>  sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
>  test_dom = "DomST1"
> -mem = 128 # MB
> -bug_no  = "00002"
> -START_STATE = 3 
> +
> +START_STATE = 3
>  FINAL_STATE = 2
>   
We can use const.CIM_DISABLE and const.CIM_ENABLE for START_STATE and 
FINAL_STATE respectively.
>  @do_main(sup_types)
> @@ -62,7 +60,7 @@
>      options = main.options
>      status = FAIL
>
> -    cxml = vxml.get_class(options.virt)(test_dom, mem) 
> +    cxml = get_class(options.virt)(test_dom) 
>      ret = cxml.cim_define(options.ip)
>      #Define a VS
>      if not ret :
> @@ -73,52 +71,35 @@
>      keys = { 'Name' : test_dom, 'CreationClassName' : cs_class }
>
>      try:
> -        cs = enumclass.GetInstance(options.ip, cs_class, keys)
> -        if cs.Name == test_dom:
> -            from_State =  cs.EnabledState
> -        else:
> -            logger.error("VS '%s' is not available", test_dom)
> -            return status
> +        cs = GetInstance(options.ip, cs_class, keys)
> +        if cs.Name != test_dom:
> +            raise Exception("VS '%s' is not available" % test_dom)
> +
> +        if int(cs.EnabledState) != int(START_STATE):
> +            raise Exception("%s start state is %s, exp %s" % (test_dom, 
> +                            cs.EnabledState, START_STATE))
> +
> +        #Change the state of the  VS to Start
> +        status = cxml.cim_start(options.ip)
> +        if status != PASS:      
> +            raise Exception("Unable start dom '%s'" % test_dom)
> +
> +        #Get the value of the EnabledState property and RequestedState property.
> +        cs = GetInstance(options.ip, cs_class, keys)
> +        if cs.Name != test_dom:
> +            raise Exception("VS '%s' is not found" % test_dom)
> +
> +        if int(cs.EnabledState) != int(FINAL_STATE):
> +            raise Exception("%s final state is %s, exp %s" % (test_dom, 
> +                            cs.RequestedState, FINAL_STATE))
> +
> +        if int(cs.EnabledState) != int(cs.RequestedState):
> +            raise Exception("%s enabled state %s != requested state %s" % \
> +                            (test_dom, cs.EnabledState, cs.RequestedState))
>
>   
The below piece of code is repeated :

cs = GetInstance(options.ip, cs_class, keys)
if cs.Name != test_dom:
raise Exception("VS '%s' is not available" % test_dom)

if int(cs.EnabledState) != int(START_STATE):
raise Exception("%s start state is %s, exp %s" % (test_dom,
cs.EnabledState, START_STATE))

We can put this in a fn like check_state() , any thoughts ??

Thanks and Regards,
Deepti.




More information about the Libvirt-cim mailing list