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

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Dec 24 22:06:56 UTC 2008


# 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
 
 @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))
 
     except Exception, detail:
         logger.error("Exception: %s" % detail)
-        cxml.undefine(options.ip)
-        return status
-
-    try:
-        #Change the state of the  VS to Start
-        status = cxml.cim_start(options.ip)
-        if status != PASS:      
-            logger.error("Unable start dom '%s' using "
-                         "RequestedStateChange()", test_dom)
-            cxml.undefine(options.ip)
-            return status
-
-        #Get the value of the EnabledState property and RequestedState property.
-        cs= enumclass.GetInstance(options.ip, cs_class, keys)
-        if cs.Name == test_dom:
-            to_RequestedState = cs.RequestedState
-            enabledState = cs.EnabledState
-        else: 
-            logger.error("VS '%s' is not found", test_dom)
-            return status 
-
-        # Success: 
-        # if  
-        # From state == defined
-        # To state == running
-        # Enabled_state == RequestedState
-
-        if from_State == START_STATE and \
-           to_RequestedState == FINAL_STATE and \
-           enabledState == to_RequestedState:
-            status = PASS
-        else:
-            logger.error("VS '%s' transition from Defined State to "
-                         "Activate state was not Successful", test_dom)
-            status = XFAIL_RC(bug_no)
-    except Exception, detail:
-        logger.error("Exception: %s" % detail)
+        status = FAIL
 
     cxml.cim_destroy(options.ip)
     cxml.undefine(options.ip)




More information about the Libvirt-cim mailing list