# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231183018 28800
# Node ID 0e6f4b82fce48e3ed1eeb46f3b8f318ebc9f5ffb
# Parent 1745043d345ceb2ee24462bee31c8c5e640e6bad
[TEST] #2 Update CS 06_paused_active_suspend.py to use cim_() functions.
This test has been re-written so it is now easier to read and flows better.
Updates:
-Use check_guest_state()
-Use CIM state values defined in const.py
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 1745043d345c -r 0e6f4b82fce4
suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Mon Jan 05
11:16:46 2009 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Mon Jan 05
11:16:58 2009 -0800
@@ -26,36 +26,20 @@
# information related to this is captured in the RequestedState Property
# of the VS.
# The test is considered to be successful if RequestedState Property
-# has a value of "9" when the VS is moved from active to suspend state.
+# has a value of "9" when the VS is moved from active to paused state.
#
-# List of Valid state values (Refer to VSP spec doc Table 2 for more)
-# ---------------------------------
-# State | Values
-# ---------------------------------
-# Defined | 3
-# Active | 2
-# Paused | 9
-# Suspended | 6
-#
-#
# Date :18-10-2007
import sys
-from XenKvmLib import vxml
-from VirtLib import utils
-from XenKvmLib.test_doms import destroy_and_undefine_all
+from XenKvmLib.vxml import get_class
from CimTest.Globals import logger
-from XenKvmLib.const import do_main
-from XenKvmLib.common_util import call_request_state_change, \
-poll_for_state_change
+from XenKvmLib.const import do_main, CIM_ENABLE, CIM_PAUSE
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
+from XenKvmLib.classes import get_typed_class
+from XenKvmLib.enumclass import GetInstance
sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
test_dom = "DomST1"
-mem = 128 # MB
-START_STATE = 2
-FINAL_STATE = 9
-TIME = "00000000000000.000000:000"
bug_libvirt = "00011"
@do_main(sup_types)
@@ -65,69 +49,42 @@
server = options.ip
virt = options.virt
- destroy_and_undefine_all(server)
-
- cxml = vxml.get_class(virt)(test_dom, mem)
+ cxml = get_class(virt)(test_dom)
#Create VS
+ pause_failed = False
try:
- ret = cxml.create(server)
+ ret = cxml.cim_define(server)
if not ret:
- logger.error("VS '%s' was not created" % test_dom)
- return status
+ raise Exception("VS '%s' was not defined" % test_dom)
+
+ status = cxml.cim_start(server)
+ if status != PASS:
+ raise Exception("Unable start dom '%s'" % test_dom)
+
+ status = cxml.check_guest_state(options.ip, CIM_ENABLE)
+ if status != PASS:
+ raise Exception("%s not in expected state" % test_dom)
+
+ #Pause the VS
+ status = cxml.cim_pause(server)
+ if status != PASS:
+ pause_failed = True
+ raise Exception("Unable pause dom '%s'" % test_dom)
+
+ status = cxml.check_guest_state(options.ip, CIM_PAUSE)
+ if status != PASS:
+ raise Exception("%s not in expected state" % test_dom)
+
except Exception, detail:
logger.error("Exception variable: %s" % detail)
- return status
-
- status, dom_cs = poll_for_state_change(server, virt, test_dom,
- START_STATE)
-
- if status != PASS:
- cxml.destroy(server)
- return status
-
- from_State = dom_cs.EnabledState
-
- #Suspend the VS
- status = call_request_state_change(test_dom, server, FINAL_STATE,
- TIME, virt)
- if status != PASS:
- logger.error("Unable to suspend dom '%s' using
RequestedStateChange()",
- test_dom)
- cxml.destroy(server)
- if virt == 'LXC':
- return XFAIL_RC(bug_libvirt)
- 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.
- status, dom_cs = poll_for_state_change(server, virt, test_dom,
- FINAL_STATE, timeout=40)
-
- if status != PASS:
- cxml.destroy(server)
- return status
-
- enabledState = dom_cs.EnabledState
- to_RequestedState = dom_cs.RequestedState
-
- # Success:
- # if
- # From state == 2
- # To state == 9
- # Enabled_state == RequestedState
-
- if from_State == START_STATE and \
- to_RequestedState == FINAL_STATE and \
- to_RequestedState == enabledState:
- status = PASS
- else:
- logger.error("VS '%s' transition from Activate State to Suspend
State"
- " was not Successful" % test_dom)
status = FAIL
cxml.destroy(server)
+ cxml.undefine(options.ip)
+
+ if pause_failed and virt == 'LXC':
+ return XFAIL_RC(bug_libvirt)
return status
if __name__ == "__main__":