[PATCH] [TEST] Fixing VSMS/09_procrasd_persist.py tc

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1233740067 28800 # Node ID 5e1c6b862cd74b56451397df81818d7afea68ff2 # Parent 912b7615d48c8303fd3daa6e55669c6d66af23e4 [TEST] Fixing VSMS/09_procrasd_persist.py tc. 1) Added description to the tc. 2) Removed unnecessary import stmts 3) Changed the tc to use cim_define() 4) Added the check to verify the VirtualQuantity 5) Aligned the tc to fit in 80 columns Tested for KVM/Xen/LXC with current sources, KVM with F9 rpm. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 912b7615d48c -r 5e1c6b862cd7 suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py --- a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py Mon Feb 02 04:45:23 2009 -0800 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/09_procrasd_persist.py Wed Feb 04 01:34:27 2009 -0800 @@ -19,50 +19,68 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# Purpose: +# Verify DefineSystem() properly uses the ProcRASD setting passed in +# as part of the ResourceSeting property. +# +# Steps: +# 1) Get the default rasds +# 2) Set the ProcRASD VirtualQuantity, Weight, Limit, InstanceID values +# 3) Define the guest using the configuration +# 4) Verify the proc settings of the guest +# import sys -import pywbem -from XenKvmLib.common_util import call_request_state_change, \ - poll_for_state_change -from XenKvmLib import vsms +from pywbem.cim_types import Uint64, Uint32 +from XenKvmLib.vxml import get_class from XenKvmLib.enumclass import GetInstance -from XenKvmLib.common_util import get_typed_class -from VirtLib import utils +from XenKvmLib.classes import get_typed_class, inst_to_mof from CimTest.Globals import logger from XenKvmLib.const import do_main from CimTest.ReturnCodes import FAIL, PASS -from XenKvmLib.test_doms import destroy_and_undefine_domain +from XenKvmLib.rasd import get_default_rasds sup_types = ['Xen', 'XenFV', 'KVM'] -default_dom = 'rstest_domain' +test_dom = 'procrasd_persist' -nvcpu = 2 +nvcpu = 3 weight = 124 -limit = 256 +limit = 512 -REQUESTED_STATE = 2 -TIME = "00000000000000.000000:000" +def setup_guest(ip, virt, cxml, prasd_cn): + rasds = get_default_rasds(ip, virt) + rasd_list= { prasd_cn : None } + + for rasd in rasds: + if rasd.classname == prasd_cn: + rasd['InstanceID'] = '%s/proc' %test_dom + rasd['VirtualQuantity'] = Uint64(nvcpu) + rasd['Weight'] = Uint32(weight) + rasd['Limit'] = Uint64(limit) + rasd_list[prasd_cn] = inst_to_mof(rasd) -def setup_rasd_mof(ip, vtype): - vssd, rasd = vsms.default_vssd_rasd_str(default_dom, virt=vtype) + if rasd_list[prasd_cn] is None: + logger.error("Unable to set template ProcRASD") + return FAIL - class_pasd = vsms.get_pasd_class(vtype) - proc_inst = class_pasd(default_dom, nvcpu, weight, limit) - proc_mof = proc_inst.mof() + cxml.set_res_settings(rasd_list) + ret = cxml.cim_define(ip) + if not ret: + logger.error("Unable to define %s ", test_dom) + return FAIL - for i in range(len(rasd)): - if "ProcResourceAllocationSettingData" in rasd[i]: - rasd[i] = proc_mof - return PASS, vssd, rasd + return PASS - return FAIL, vssd, rasd - -def check_proc_sched(server, virt): +def check_proc_sched(server, virt, cn_name): try: - key_list = {"InstanceID" : '%s/proc' %default_dom} - cn_name = get_typed_class(virt, 'ProcResourceAllocationSettingData') + key_list = {"InstanceID" : '%s/proc' %test_dom} proc = GetInstance(server, cn_name, key_list) + if proc.VirtualQuantity != nvcpu: + logger.error("VirtualQuantity is %i, expected %i", + proc.VirtualQuantity, nvcpu) + return FAIL + if proc.Limit != limit: logger.error("Limit is %i, expected %i", proc.Limit, limit) return FAIL @@ -79,32 +97,20 @@ def check_proc_sched(server, virt): @do_main(sup_types) def main(): - options = main.options + options = main.options + virt = options.virt + server = options.ip + + cxml = get_class(virt)(test_dom) + prasd_cn = get_typed_class(virt, "ProcResourceAllocationSettingData") + try: + status = setup_guest(server, virt, cxml, prasd_cn) + if status != PASS: + return status - status, vssd, rasd = setup_rasd_mof(options.ip, options.virt) - if status != PASS: - return status - - try: - service = vsms.get_vsms_class(options.virt)(options.ip) - service.DefineSystem(SystemSettings=vssd, - ResourceSettings=rasd, - ReferenceConfiguration=' ') - - rc = call_request_state_change(default_dom, options.ip, - REQUESTED_STATE, TIME, options.virt) - if rc != 0: - raise Exception("Unable to start %s using RequestedStateChange()" % - default_dom) - - status, dom_cs = poll_for_state_change(options.ip, options.virt, - default_dom, REQUESTED_STATE) + status = check_proc_sched(server, virt, prasd_cn) if status != PASS: - raise Exception("%s didn't change state as expected" % default_dom) - - status = check_proc_sched(options.ip, options.virt) - if status != PASS: - raise Exception("%s CPU scheduling not set properly", default_dom) + raise Exception("'%s' CPU scheduling not set properly" % test_dom) status = PASS @@ -112,8 +118,7 @@ def main(): logger.error("Exception: details %s", details) status = FAIL - destroy_and_undefine_domain(default_dom, options.ip, options.virt) - +# cxml.undefine(server) return status if __name__ == "__main__":

+# Purpose: +# Verify DefineSystem() properly uses the ProcRASD setting passed in +# as part of the ResourceSeting property.
The purpose is to verify that the values for limit and weight are persisted properly. When the guest is defined, the weight and limit values are written to a file. When we do a GetInstance() on the ProcRASD, the file is read to get the weight/limit values for each guest.
@@ -112,8 +118,7 @@ def main(): logger.error("Exception: details %s", details) status = FAIL
- destroy_and_undefine_domain(default_dom, options.ip, options.virt) - +# cxml.undefine(server)
Uncomment this. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Deepti B. Kalakeri
-
Kaitlin Rupert