
# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1207834557 -19800 # Node ID dac8e3a5491b28fd6946e6fabf0d4b14cd9921fe # Parent 0e7eb39ed839e03d1dd2635157f19e5acdc4c9be [TEST]Fixing 06_paused_active_suspend.py tc failure. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 0e7eb39ed839 -r dac8e3a5491b suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py --- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Thu Apr 10 19:04:30 2008 +0530 +++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Thu Apr 10 19:05:57 2008 +0530 @@ -44,8 +44,6 @@ from time import sleep from time import sleep from XenKvmLib import computersystem from XenKvmLib import vxml -from VirtLib import utils -from XenKvmLib.test_doms import destroy_and_undefine_all from CimTest.Globals import log_param, logger from CimTest.Globals import do_main from XenKvmLib.common_util import call_request_state_change @@ -61,6 +59,37 @@ FINAL_STATE = 9 FINAL_STATE = 9 REQUESTED_STATE = FINAL_STATE TIME = "00000000000000.000000:000" + +def poll_for_status(server, virt, cxml, expstate): +#Polling for the value of EnabledState to be set to expstate. +#We need to wait for the EnabledState to be set appropriately since +#it does not get set immediatley to value of expstate when created/suspended. + status = FAIL + timeout = 10 + try: + + for i in range(1, (timeout + 1)): + sleep(1) + cs = computersystem.get_cs_class(virt)(server, 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 == expstate: + status = PASS + break + + except Exception, detail: + logger.error("Exception variable: %s" % detail) + + if status != PASS: + logger.error("Mismatching state values got %i instead of %i", enabledState, expstate) + cxml.destroy(server) + cxml.undefine(server) + + return status, to_RequestedState, enabledState @do_main(sup_types) def main(): @@ -87,45 +116,26 @@ def main(): cxml.destroy(options.ip) cxml.undefine(options.ip) return status - + + status, to_RequestedState, enabledState = poll_for_status(options.ip, options.virt, cxml, 2) + if status != PASS or enabledState != 2: + return status + #Suspend the VS - rc = call_request_state_change(test_dom, options.ip, REQUESTED_STATE, - TIME, options.virt) + 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, to_RequestedState, enabledState = poll_for_status(options.ip, options.virt, cxml, + FINAL_STATE) 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: - ret = cxml.destroy(options.ip) - cxml.undefine(options.ip) return status # Success: @@ -134,9 +144,8 @@ def main(): # To state == 2 # Enabled_state == RequestedState - if from_State == START_STATE and \ - to_RequestedState == FINAL_STATE and \ - enabledState == to_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 \