Kaitlin Rupert wrote:
# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1231194787 28800
# Node ID f317d11f46a29a8141563498076d716153dfc5f2
# Parent ae40dfa1b8f6e134d200233d2e5b3395855cafa2
[TEST] Update 32_start_reboot.py to use cim_() functions
Also change cim_state_change() to support enable and requested state parameters.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ae40dfa1b8f6 -r f317d11f46a2
suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py
--- a/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Mon Jan 05 14:08:38
2009 -0800
+++ b/suites/libvirt-cim/cimtest/ComputerSystem/32_start_reboot.py Mon Jan 05 14:33:07
2009 -0800
@@ -28,26 +28,13 @@
# The test is considered to be successful if RequestedState Property
# has a value of 10 when the VS is moved from active to reboot state.
#
-# List of Valid state values (Refer to VSP spec doc Table 2 for more)
-# ---------------------------------
-# State | Values
-# ---------------------------------
-# Defined | 3
-# Active | 2
-# Rebooted | 10
-#
# Date: 03-03-2008
import sys
-from VirtLib import utils
-from time import sleep
from CimTest.Globals import logger
from XenKvmLib.const import do_main
from CimTest.ReturnCodes import PASS, FAIL, XFAIL_RC
-from XenKvmLib.test_doms import destroy_and_undefine_domain
-from XenKvmLib.common_util import create_using_definesystem, \
- call_request_state_change, \
- poll_for_state_change
+from XenKvmLib.vxml import get_class
sup_types = ['Xen', 'XenFV', 'KVM', 'LXC']
The following can be removed from the test case since they are not used
in the updated test case.
ACTIVE_STATE = 2
REBOOT_STATE = 10
TIME = "00000000000000.000000:000"
@@ -64,45 +51,35 @@
server = options.ip
virt = options.virt
- tc_scen = [('Start', [ACTIVE_STATE, ACTIVE_STATE]), \
- ('Reboot', [ACTIVE_STATE, REBOOT_STATE])]
-
+ action_failed = False
try:
# define the vs
- status = create_using_definesystem(default_dom, server,
- virt=virt)
+ cxml = get_class(virt)(default_dom)
+ ret = cxml.cim_define(server)
+ if not ret:
+ raise Exception("Failed to define the guest: %s" % default_dom)
+
+ status = cxml.cim_start(server)
if status != PASS:
- logger.error("Unable to define domain '%s' using
DefineSystem()",
- default_dom)
- return status
+ action_failed = True
If we set action_failed here we return XFAIL even for start operation
which is not valid.
Since cim_start() is supported and should not XFAIL. No need to set
action_failed here.
+ raise Exception("Unable start dom
'%s'" % default_dom)
- # start, then reboot
- for action, state in tc_scen:
- en_state = state[0]
- rq_state = state[1]
- status = call_request_state_change(default_dom, server,
- rq_state, TIME,
- virt=virt)
- if status != PASS:
- logger.error("Unable to '%s' dom '%s' using
RequestedStateChange()",
- action, default_dom)
- status = XFAIL_RC(bug_libvirt)
- break
-
- status, dom_cs = poll_for_state_change(server, virt, default_dom, en_state,
- timeout=10)
-
- if status != PASS or dom_cs.RequestedState != rq_state:
- status = FAIL
- logger.error("Attributes for dom '%s' is not set as
expected.",
- default_dom)
- break
+ status = cxml.cim_reboot(server)
+ if status != PASS:
+ action_failed = True
+ raise Exception("Unable reboot dom '%s'" % default_dom)
except Exception, detail:
logger.error("Exception: %s", detail)
status = FAIL
- destroy_and_undefine_domain(default_dom, server, virt)
+ cxml.cim_destroy(server)
+ cxml.undefine(server)
+
+ if action_failed:
+ if virt == "KVM" or virt == "LXC":
+ return XFAIL_RC(bug_libvirt)
+
return status
if __name__ == "__main__":
diff -r ae40dfa1b8f6 -r f317d11f46a2 suites/libvirt-cim/lib/XenKvmLib/vxml.py
--- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jan 05 14:08:38 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Mon Jan 05 14:33:07 2009 -0800
@@ -535,7 +535,7 @@
try:
cs = GetInstance(server, cs_class, keys)
- if cs.Name != self.domain_name:
+ if cs is None or cs.Name != self.domain_name:
raise Exception("Wrong guest instance")
if cs.EnabledState != en_state:
@@ -553,7 +553,11 @@
return PASS
- def cim_state_change(self, server, req_state, req_timeout, poll_time):
+ def cim_state_change(self, server, req_state, req_timeout, poll_time,
+ en_state=None):
+ if en_state is None:
+ en_state = req_state
+
cs = None
cs_class = get_typed_class(self.virt, 'ComputerSystem')
keys = { 'Name' : self.domain_name, 'CreationClassName' :
cs_class }
@@ -562,7 +566,7 @@
return status
try:
- req_state_change = pywbem.cim_types.Uint16(req_state)
+ req_state_change = pywbem.cim_types.Uint16(req_state)
time_period = pywbem.cim_types.CIMDateTime(req_timeout)
cs.RequestStateChange(RequestedState=req_state_change,
TimeoutPeriod=time_period)
@@ -574,7 +578,7 @@
return FAIL
for i in range(1, (poll_time + 1)):
- status = self.check_guest_state(server, req_state)
+ status = self.check_guest_state(server, en_state, req_state)
if status == PASS:
break
@@ -606,7 +610,7 @@
def cim_reboot(self, server, req_time=const.TIME, poll_time=30):
return self.cim_state_change(server, const.CIM_REBOOT,
- req_time, poll_time)
+ req_time, poll_time, const.CIM_ENABLE)
The test case gives a false positive. The following are the log messages
which means the tc is suppose to fail.
Tue, 06 Jan 2009 01:10:14:TEST LOG:INFO - ====32_start_reboot.py Log====
Tue, 06 Jan 2009 01:10:17:TEST LOG:ERROR - Unable to check guest state
Tue, 06 Jan 2009 01:10:17:TEST LOG:ERROR - Exception: Wrong guest instance
Tue, 06 Jan 2009 01:10:18:TEST LOG:ERROR - Unable to check guest state
Tue, 06 Jan 2009 01:10:18:TEST LOG:ERROR - Exception: EnabledState is 9,
expected 2.
But, the test case gives a PASS message on the console.
def cim_reset(self, server, req_time=const.TIME, poll_time=30):
return self.cim_state_change(server, const.CIM_RESET,
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim