# HG changeset patch
# User Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
# Date 1217331858 25200
# Node ID 8c8ec47bc8492eacc1f5feff6ed6fd871451a9d0
# Parent ec303feee0e302ddf29b8dad81d0d4416e0fb48a
1) Added support for KVM
2) Removed the invalid bug nos.
3) Removed check_attributes() and used check_reqstate_value() library function instead.
4) Adding create_netpool_conf(), destroy_netpool() since the VSMS now requires
networkpool.
5) used destroy_and_undefine_domain() to undefine and destroy the VS.
6) Used try_request_state_change() library function to verify the exception.
7) Used poll_for_state_change() to verify the poll and verify the EnabledState value.
The changes are verified with KVM Xen, XenFV with current sources.
Signed-off-by: Deepti B. Kalakeri <deeptik(a)linux.vnet.ibm.com>
diff -r ec303feee0e3 -r 8c8ec47bc849
suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Tue Jul 29 04:39:45
2008 -0700
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/23_suspend_suspend.py Tue Jul 29 04:44:18
2008 -0700
@@ -4,7 +4,7 @@
#
# Authors:
# Anoop V Chakkalakkal<anoop.vijayan(a)in.ibm.com>
-#
+# Deepti B. Kalakeri<deeptik(a)linux.vnet.ibm.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
@@ -26,7 +26,7 @@
# information 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
-# and has a value of 9 when supended again
+# and returns an excpetion when supended again.
#
# List of Valid state values (Refer to VSP spec doc Table 2 for more)
# ---------------------------------
@@ -39,84 +39,89 @@
# Date: 29-02-2008
import sys
+import pywbem
from VirtLib import utils
from CimTest.Globals import do_main, logger
-from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
-from XenKvmLib.test_doms import undefine_test_domain
-from XenKvmLib.common_util import get_cs_instance
+from CimTest.ReturnCodes import PASS, FAIL
+from XenKvmLib.test_doms import destroy_and_undefine_domain
from XenKvmLib.common_util import create_using_definesystem
from XenKvmLib.common_util import call_request_state_change
+from XenKvmLib.common_util import try_request_state_change
+from XenKvmLib.common_util import poll_for_state_change
+from XenKvmLib.common_util import check_reqstate_value
+from XenKvmLib.common_util import create_netpool_conf, destroy_netpool
-sup_types = ['Xen', 'XenFV']
+sup_types = ['Xen', 'XenFV', 'KVM']
ACTIVE_STATE = 2
SUSPND_STATE = 9
-bug_req_state = "00002"
-default_dom = 'test_domain'
+default_dom = 'cs_test_domain'
TIME = "00000000000000.000000:000"
-
-def check_attributes(domain_name, ip, en_state, rq_state, virt):
- rc, cs = get_cs_instance(domain_name, ip, virt)
- if rc != 0:
- return rc
- if cs.RequestedState != rq_state:
- logger.error("RequestedState should be %d not %d",
- rq_state, cs.RequestedState)
- return XFAIL_RC(bug_req_state)
-
- if cs.EnabledState != en_state:
- logger.error("EnabledState should be %d not %d",
- en_state, cs.EnabledState)
- return FAIL
-
- return PASS
+err_no = pywbem.CIM_ERR_FAILED
+err_desc = "Domain not running"
@do_main(sup_types)
def main():
options = main.options
- status = FAIL
+ server = options.ip
+ virt = options.virt
+
+ status, test_network = create_netpool_conf(server, virt, False)
+ if status != PASS:
+ return FAIL
tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \
- ('Suspend', [SUSPND_STATE, SUSPND_STATE]), \
- ('Suspend', [SUSPND_STATE, SUSPND_STATE])]
+ ('Suspend', [SUSPND_STATE, SUSPND_STATE])]
try:
# define the vs
status = create_using_definesystem(default_dom,
- options.ip,
- virt=options.virt)
+ server,
+ virt=virt)
if status != PASS:
- logger.error("Unable to define domain %s using DefineSystem()", \
- default_dom)
+ logger.error("Unable to define domain '%s' using
DefineSystem()",
+ default_dom)
return status
- # start, suspend and suspend again
+ # start, suspend
for action, state in tc_scen:
en_state = state[0]
rq_state = state[1]
- status = call_request_state_change(default_dom, options.ip,
- rq_state, TIME, options.virt)
+ status = call_request_state_change(default_dom, server,
+ rq_state, TIME, virt)
if status != PASS:
- logger.error("Unable to %s dom %s using \
-RequestedStateChange()", action, default_dom)
+ logger.error("Unable to '%s' dom '%s' using
RequestedStateChange()",
+ action, default_dom)
break
- # FIX ME
- # sleep()
+ status = poll_for_state_change(server, virt, default_dom, en_state,
+ timeout=10)
+ if status != PASS:
+ break
- status = check_attributes(default_dom, options.ip,
- en_state, rq_state, options.virt)
+ status = check_reqstate_value(default_dom, server, rq_state, virt)
if status != PASS:
- logger.error("Attributes for dom %s not set as expected.",
+ logger.error("RequestedState for dom '%s' is not set as
expected.",
default_dom)
break
except Exception, detail:
- logger.error("Exception: %s", detail)
+ logger.error("Exception: '%s'", detail)
status = FAIL
- # undefine the vs
- undefine_test_domain(default_dom, options.ip, options.virt)
+ if status != PASS:
+ destroy_netpool(server, virt, test_network)
+ destroy_and_undefine_domain(default_dom, server, virt)
+ return status
+
+ # try to suspend already suspended VS
+ rq_state = SUSPND_STATE
+ status = try_request_state_change(default_dom, server,
+ rq_state, TIME, err_no,
+ err_desc, virt)
+
+ destroy_netpool(server, virt, test_network)
+ destroy_and_undefine_domain(default_dom, server, virt)
return status