# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1230073744 28800
# Node ID f95c0c4d4ef6d807262ba06f5087caa80156d917
# Parent a9826c20a65bc16c2c205b183e4fa8eafde08d30
[TEST] 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.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r a9826c20a65b -r f95c0c4d4ef6
suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Tue Dec 23
15:03:40 2008 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/06_paused_active_suspend.py Tue Dec 23
15:09:04 2008 -0800
@@ -26,7 +26,7 @@
# 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)
# ---------------------------------
@@ -35,27 +35,22 @@
# 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 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 +60,57 @@
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)
+
+ cs_class = get_typed_class(virt, 'ComputerSystem')
+ keys = { 'Name' : test_dom, 'CreationClassName' : cs_class }
+
+ dom_cs = GetInstance(server, cs_class, keys)
+ if dom_cs.Name != test_dom:
+ raise Exception("Instance matching %s was not returned" %
test_dom)
+
+ if int(dom_cs.EnabledState) != int(START_STATE):
+ raise Exception("%s start state is %s, exp %s" % (test_dom,
+ dom_cs.EnabledState, START_STATE))
+
+ #Pause the VS
+ status = cxml.cim_pause(server)
+ if status != PASS:
+ pause_failed = True
+ raise Exception("Unable pause dom '%s'" % test_dom)
+
+ cs = GetInstance(server, cs_class, keys)
+ if cs.Name != test_dom:
+ raise Exception("Instance matching %s was not returned" %
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 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__":