[Libvirt-cim] [PATCH] [TEST] Fixing the 06_paused_active_suspend.py tc of ComputerSystem

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Tue Jul 1 15:16:24 UTC 2008


# HG changeset patch
# User Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1214925380 25200
# Node ID 16bbf4d2f48e04334471805a524cfb653a391dd8
# Parent  cc7716fa4252235924577a0e9bb16c89fc55870b
[TEST] Fixing the 06_paused_active_suspend.py tc of ComputerSystem.

1) Updated the tc to use the poll_for_state_change() function.
2) Included the get_state_values() functions that returns the enable_state, req_state values.
3) Included the extra sleep bcs sometimes the provider is not
   able to suspend the domain immediately even though the enable_state
   is set to 2 and hence the tc was failing intermittently.
4) Removed  cxml.undefine() call since it was not req.
5) Fixed Indentation.

Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

~

diff -r cc7716fa4252 -r 16bbf4d2f48e suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py	Mon Jun 30 23:07:06 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/03_defineVS.py	Tue Jul 01 08:16:20 2008 -0700
@@ -55,6 +55,7 @@ def main():
             raise Exception('No cs instance returned')
         for dom in cs:
             if dom.Name == test_dom:
+                Globals.logger.error("Deepti %s", dom.Name)
                 enabState = dom.EnabledState
                 status = PASS
                 break
diff -r cc7716fa4252 -r 16bbf4d2f48e suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py	Mon Jun 30 23:07:06 2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py	Tue Jul 01 08:16:20 2008 -0700
@@ -48,103 +48,97 @@ from XenKvmLib.test_doms import destroy_
 from XenKvmLib.test_doms import destroy_and_undefine_all
 from CimTest.Globals import logger
 from CimTest.Globals import do_main
-from XenKvmLib.common_util import call_request_state_change
+from XenKvmLib.common_util import call_request_state_change, \
+poll_for_state_change
 from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
 
 sup_types = ['Xen', 'KVM', 'XenFV']
 test_dom = "DomST1"
 mem = 128 # MB
-# Keeping the bug no for future reference
-# bug_no_req_change_method = "90559"
 bug_no_req_change_prop   = "00002"
 START_STATE = 2 
 FINAL_STATE = 9
 REQUESTED_STATE = FINAL_STATE
 TIME = "00000000000000.000000:000"
 
+def get_state_values(server, virt):
+    enable_state = req_state = None
+    try:
+        cs = computersystem.get_cs_class(virt)(server, test_dom)
+        if cs.Name == test_dom:
+            enable_state = cs.EnabledState
+            req_state    = cs.RequestedState
+        else:
+            logger.error("ERROR: VS %s not found" % test_dom)
+    except Exception, detail:
+        logger.error("Exception variable: %s" % detail)
+    return enable_state, req_state
+
 @do_main(sup_types)
 def main():
     options = main.options
     status = FAIL
+    server = options.ip
+    virt = options.virt
     
-    cxml = vxml.get_class(options.virt)(test_dom, mem)
+    cxml = vxml.get_class(virt)(test_dom, mem)
 
-#Create VS
+    #Create VS
     try:
-        ret = cxml.create(options.ip)
+        ret = cxml.create(server)
         if not ret:
             logger.error("ERROR: VS %s was not created" % test_dom)
             return status
-        cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom)
-        if cs.Name == test_dom:
-            from_State = cs.EnabledState
-        else:
-            logger.error("ERROR: VS %s not found" % test_dom)
-            return status
-    except Exception, detail:
-        logger.error("Exception variable: %s" % detail)
-        cxml.destroy(options.ip)
-        cxml.undefine(options.ip)
-        return status
- 
-#Suspend the VS
-    rc = call_request_state_change(test_dom, options.ip, REQUESTED_STATE,
-                                   TIME, options.virt)
-    if rc != 0:
-        logger.error("Unable to suspend dom %s using RequestedStateChange()", test_dom)
-        cxml.destroy(options.ip)
-        cxml.undefine(options.ip)
-        return status
-#Polling for the value of EnabledState to be set to 9.
-#We need to wait for the EnabledState to be set appropriately since
-#it does not get set immediatley to value of 9 when suspended.
-    timeout = 10
-    try:
-
-        for i in range(1, (timeout + 1)):
-            sleep(1)
-            cs = computersystem.get_cs_class(options.virt)(options.ip, test_dom)
-            if cs.Name == test_dom:
-                to_RequestedState = cs.RequestedState
-                enabledState =  cs.EnabledState
-            else:
-                logger.error("VS %s not found" % test_dom)
-                return status 
-            if enabledState == FINAL_STATE:
-                status = PASS
-                break
-
     except Exception, detail:
         logger.error("Exception variable: %s" % detail)
         return status
+ 
+    status = poll_for_state_change(server, virt, test_dom, 
+                                   START_STATE)
+    from_State, req_state = get_state_values(server, virt)
 
-    if enabledState != FINAL_STATE:
-        logger.error("EnabledState has %i instead of %i", enabledState, FINAL_STATE)
-        logger.error("Try to increase the timeout and run the test again")
-
+    if status != PASS or from_State == None or req_state == None:
+        cxml.destroy(server)
+        return status
+ 
+    sleep(10)
+    #Suspend the VS
+    status = call_request_state_change(test_dom, server, REQUESTED_STATE,
+                                       TIME, virt)
     if status != PASS:
-        ret = cxml.destroy(options.ip)
-        cxml.undefine(options.ip)
+        logger.error("Unable to suspend dom %s using RequestedStateChange()", 
+                      test_dom)
+        cxml.destroy(server)
         return status
 
-# Success: 
-# if  
-# From state == 9
-# To state == 2
-# Enabled_state == RequestedState
+    #Polling for the value of EnabledState to be set to 9.
+    #We need to wait for the EnabledState to be set appropriately since
+    #it does not get set immediatley to value of 9 when suspended.
+    status = poll_for_state_change(server, virt, test_dom, 
+                                   FINAL_STATE, timeout=40)
+    enabledState, to_RequestedState = get_state_values(server, virt)
+
+    if status != PASS or enabledState == None or to_RequestedState == None:
+        ret = cxml.destroy(server)
+        return status
+
+    # Success: 
+    # if  
+    # From state == 9
+    # To state == 2
+    # Enabled_state == RequestedState
 
     if from_State == START_STATE and \
         to_RequestedState == FINAL_STATE and \
         enabledState == to_RequestedState:
         status = PASS
     else:
-        logger.error("ERROR: VS %s transition from suspend State to Activate state \
- was not Successful" % test_dom)
+        logger.error("VS %s transition from Suspend State to Activate State" 
+                     " was not Successful" % test_dom)
 # Replace the status with FAIL once the bug is fixed.
         status = XFAIL_RC(bug_no_req_change_prop)
-    ret = cxml.destroy(options.ip)
-    cxml.undefine(options.ip)
+
+    ret = cxml.destroy(server)
     return status
-
 if __name__ == "__main__":
     sys.exit(main())




More information about the Libvirt-cim mailing list