[PATCH 0 of 3] [TEST] Profile test cases KVM support

Necessary library update also included. Signed-off-by: Zhengang Li <lizg@cn.ibm.com>

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208329494 -28800 # Node ID 7c20d87e25c0cd53deba4dc8c48529d84bb740d9 # Parent 68de226362a6f903a2e66537278733ac17c3551f [TEST] KVM support and refactor to Profile.01 Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 68de226362a6 -r 7c20d87e25c0 suites/libvirt-cim/cimtest/Profile/01_enum.py --- a/suites/libvirt-cim/cimtest/Profile/01_enum.py Wed Apr 16 10:49:55 2008 +0800 +++ b/suites/libvirt-cim/cimtest/Profile/01_enum.py Wed Apr 16 15:04:54 2008 +0800 @@ -28,77 +28,52 @@ import sys import sys import pywbem from XenKvmLib import enumclass +from XenKvmLib.classes import get_typed_class from CimTest import Globals -from CimTest.Globals import do_main +from CimTest.Globals import do_main, logger +from CimTest.ReturnCodes import PASS, FAIL -sup_types = ['Xen'] +sup_types = ['Xen', 'KVM'] @do_main(sup_types) def main(): options = main.options - registeredOrganization = 2 - registeredname = ['System Virtualization', \ - 'Virtual System Profile' ] - inst_id = ['CIM:DSP1042-SystemVirtualization-1.0.0', \ - 'CIM:DSP1057-VirtualSystem-1.0.0a'] - registeredversion = [ '1.0.0', '1.0.0a'] - cn = 'Xen_RegisteredProfile' - index = 0 + explist = [['CIM:DSP1042-SystemVirtualization-1.0.0', 2, + 'System Virtualization', '1.0.0'], + ['CIM:DSP1057-VirtualSystem-1.0.0a', 2, + 'Virtual System Profile', '1.0.0a']] + cn = 'RegisteredProfile' - status = 0 + status = PASS prev_namespace = Globals.CIM_NS Globals.CIM_NS = 'root/interop' Globals.log_param() try: key_list = ["InstanceID"] - proflist = enumclass.enumerate(options.ip, \ - enumclass.Xen_RegisteredProfile, \ - key_list) + proflist = enumclass.enumerate(options.ip, cn, key_list, options.virt) + except Exception, detail: + logger.error(Globals.CIM_ERROR_ENUMERATE, get_typed_class(options.virt, + cn)) + logger.error("Exception: %s", detail) + status = FAIL + Globals.CIM_NS = prev_namespace + return status + + Globals.CIM_NS = prev_namespace - # For each of the instances verify : - # -RegisteredOrganization = 2 - # -InstanceID="CIM:DSP1042-SystemVirtualization-1.0.0" - # -RegisteredName="System Virtualization" - # -RegisteredVersion="1.0.0" + checklist = [[x.InstanceID, x.RegisteredOrganization, + x.RegisteredName, x.RegisteredVersion] for x in proflist] + for exp_prof in explist: + if exp_prof in checklist: + continue + else: + logger.error("Profile %s is not found" % exp_prof[0]) + status = FAIL - for profile in proflist: - Globals.logger.log(int(Globals.logging.PRINT),"Verifying the \ -fields for :%s", profile.RegisteredName) - if profile.InstanceID == "" : - Globals.logger.error("InstanceID is %s instead of %s", \ - 'NULL', inst_id[index]) - status = 1 - if inst_id[index] != profile.InstanceID : - Globals.logger.error("InstanceID is %s instead of %s", \ - profile.InstanceID, inst_id[index]) - status = 1 - if registeredOrganization != profile.RegisteredOrganization: - Globals.logger.error("RegisteredOrganization is %s instead of %s"\ - , profile.RegisteredOrganization, registeredOrganization) - status = 1 - if registeredname[index] != profile.RegisteredName: - Globals.logger.error("RegisteredName is %s instead of %s", \ - profile.RegisteredName, registeredname[index]) - status = 1 - if registeredversion[index] != profile.RegisteredVersion: - Globals.logger.error("RegisteredVersion is %s instead of \ -%s", profile.RegisteredVersion, registeredversion[index]) - status = 1 - if status != 0: - Globals.CIM_NS = prev_namespace - return status - index = index + 1 - except Exception, detail: - Globals.logger.error(Globals.CIM_ERROR_ENUMERATE, 'Xen_RegisteredProfile') - Globals.logger.error("Exception: %s", detail) - status = 1 - return status - -# The execution will reach here only if all the checks are successful - Globals.logger.log(int(Globals.logging.PRINT), "Verification of the properties \ -for the class '%s' was successful", cn) + if status == PASS: + logger.info("Properties check for %s passed" % cn) return status if __name__ == "__main__":

+ checklist = [[x.InstanceID, x.RegisteredOrganization, + x.RegisteredName, x.RegisteredVersion] for x in proflist] + for exp_prof in explist: + if exp_prof in checklist: + continue + else: + logger.error("Profile %s is not found" % exp_prof[0]) + status = FAIL
You could reorganize this so that if the exp_prof isn't in the checklist, you log an error and return a failure. Otherwise, you log the info message and return.
- -# The execution will reach here only if all the checks are successful - Globals.logger.log(int(Globals.logging.PRINT), "Verification of the properties \ -for the class '%s' was successful", cn) + if status == PASS: + logger.info("Properties check for %s passed" % cn) return status
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
+ checklist = [[x.InstanceID, x.RegisteredOrganization, + x.RegisteredName, x.RegisteredVersion] for x in proflist] + for exp_prof in explist: + if exp_prof in checklist: + continue + else: + logger.error("Profile %s is not found" % exp_prof[0]) + status = FAIL
You could reorganize this so that if the exp_prof isn't in the checklist, you log an error and return a failure. Otherwise, you log the info message and return. Patch resent. Sorry for the delay.
- -# The execution will reach here only if all the checks are successful - Globals.logger.log(int(Globals.logging.PRINT), "Verification of the properties \ -for the class '%s' was successful", cn) + if status == PASS: + logger.info("Properties check for %s passed" % cn) return status
-- - Zhengang

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208332735 -28800 # Node ID 32614eca2a5579389cc5b262eff8243b0ca2da82 # Parent 7c20d87e25c0cd53deba4dc8c48529d84bb740d9 [TEST] KVMXML cim_define() support and KVM support for Profile.02 Signed-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 7c20d87e25c0 -r 32614eca2a55 suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py --- a/suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py Wed Apr 16 15:04:54 2008 +0800 +++ b/suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py Wed Apr 16 15:58:55 2008 +0800 @@ -47,16 +47,17 @@ from CimTest.Globals import do_main from CimTest.Globals import do_main from CimTest.ReturnCodes import PASS, FAIL -sup_types = ['Xen'] +sup_types = ['Xen', 'KVM'] test_dom = "domguest" + +rp_cn = 'RegisteredProfile' def setup_env(server): rc = -1 status = PASS csxml_info = None try: - destroy_and_undefine_all(server) virt_xml = get_class(virt) csxml_info = virt_xml(test_dom) rc = csxml_info.cim_define(server) @@ -76,100 +77,54 @@ def print_err(err, detail, cn): logger.error(err % cn) logger.error("Exception: %s", detail) -def get_inst_from_list(server, cn, qcn, list, filter, exp_val): - status = PASS - ret = -1 - inst = None - - if len(list) < 1: - logger.error("%s returned %i %s objects" % (qcn, len(list), cn)) - return FAIL, None - - for inst in list: - if inst[filter['key']] == exp_val: - ret = PASS - break - - if ret != PASS: - status = FAIL - logger.error("%s with %s was not returned" % (cn, exp_val)) - - return PASS, inst +def get_expected_inst(list, property, exp): + try: + for x in list: + if x[property] == exp: + return PASS, x + except Exception: + pass + return FAIL, None def get_profile(server): registeredname = 'Virtual System Profile' - cn = 'Xen_RegisteredProfile' status = PASS profile = None try: - proflist = enumclass.enumerate_inst(server, - enumclass.Xen_RegisteredProfile) - - filter = {"key" : "RegisteredName"} - status, profile = get_inst_from_list(server, - cn, - cn, - proflist, - filter, - registeredname) - + proflist = enumclass.enumerate_inst(server, rp_cn, virt) + status, profile = get_expected_inst(proflist, 'RegisteredName', + registeredname) except Exception, detail: - print_err(CIM_ERROR_ENUMERATE, detail, cn) + print_err(CIM_ERROR_ENUMERATE, detail, rp_cn) status = FAIL - return status, profile def get_cs(server, profile): - cn = 'Xen_RegisteredProfile' - an = 'Xen_ElementConformsToProfile' + an = 'ElementConformsToProfile' status = PASS cs = None try: - assoc_info = Associators(server, - an, - cn, + assoc_info = Associators(server, an, rp_cn, virt, InstanceID = profile['InstanceID']) - - cn = 'Xen_ComputerSystem' - filter = {"key" : "Name"} - status, cs = get_inst_from_list(server, - cn, - an, - assoc_info, - filter, - test_dom) - + status, cs = get_expected_inst(assoc_info, 'Name', test_dom) except Exception, detail: print_err(CIM_ERROR_ASSOCIATORNAMES, detail, cn) status = FAIL - return status, cs def get_elec(server, cs): - cn = 'Xen_ComputerSystem' - an = 'Xen_ElementCapabilities' + cn = 'ComputerSystem' + an = 'ElementCapabilities' status = FAIL elec = None ccn = cs['CreationClassName'] try: - assoc_info = Associators(server, - an, - cn, - Name = cs['Name'], - CreationClassName = ccn) - - cn = 'Xen_EnabledLogicalElementCapabilities' - filter = {"key" : "InstanceID"} - status, elec = get_inst_from_list(server, - cn, - an, - assoc_info, - filter, - test_dom) - + assoc_info = Associators(server, an, cn, virt, Name=cs['Name'], + CreationClassName=ccn) + status, elec = get_expected_inst(assoc_info, 'InstanceID', test_dom) except Exception, detail: print_err(CIM_ERROR_ASSOCIATORNAMES, detail, cn) status = FAIL diff -r 7c20d87e25c0 -r 32614eca2a55 suites/libvirt-cim/lib/XenKvmLib/vxml.py --- a/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 16 15:04:54 2008 +0800 +++ b/suites/libvirt-cim/lib/XenKvmLib/vxml.py Wed Apr 16 15:58:55 2008 +0800 @@ -443,11 +443,10 @@ class XenXML(VirtXML, VirtCIM): 'Either the kernel image or the init_path does not exist') sys.exit(1) VirtXML.__init__(self, 'xen', test_dom, set_uuid(), mem, vcpus) + VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path, + const.Xen_default_net_type, mac, vcpus, mem) self._os(const.Xen_kernel_path, const.Xen_init_path) self._devices(disk_file_path, disk, const.Xen_default_net_type, mac) - - VirtCIM.__init__(self, 'Xen', test_dom, disk, disk_file_path, - const.Xen_default_net_type, mac, vcpus, mem) def _os(self, os_kernel, os_initrd): os = self.get_node('/domain/os') @@ -482,7 +481,7 @@ class XenXML(VirtXML, VirtCIM): return self._set_vbridge(ip, 'Xen') -class KVMXML(VirtXML): +class KVMXML(VirtXML, VirtCIM): secondary_disk_path = const.KVM_secondary_disk_path @@ -496,6 +495,8 @@ class KVMXML(VirtXML): logger.error('Error: Disk image does not exist') sys.exit(1) VirtXML.__init__(self, 'kvm', test_dom, set_uuid(), mem, vcpus) + VirtCIM.__init__(self, 'KVM', test_dom, disk, disk_file_path, + const.KVM_default_net_type, mac, vcpus, mem) self._os() self._devices(const.KVM_default_emulator, const.KVM_default_net_type, disk_file_path, disk, mac) @@ -519,9 +520,11 @@ class KVMXML(VirtXML): return self._set_emulator(emu) def set_bridge(self, ip): + self.nasd.NetworkType = 'bridge' return self._set_bridge(ip) def set_vbridge(self, ip): + self.nasd.NetworkType = 'bridge' return self._set_vbridge(ip, 'KVM')

zli@linux.vnet.ibm.com wrote:
# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208332735 -28800 # Node ID 32614eca2a5579389cc5b262eff8243b0ca2da82 # Parent 7c20d87e25c0cd53deba4dc8c48529d84bb740d9 [TEST] KVMXML cim_define() support and KVM support for Profile.02
Signed-off-by: Zhengang Li <lizg@cn.ibm.com>
diff -r 7c20d87e25c0 -r 32614eca2a55 suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py
This is a nice clean up and looks good to me. However, the test fails due to the "Address field missing from vsms.py" issue Deepti noted in her e-mail about Dan's emulator fix. For the Address fix, we'll need conditional behavior based on the changeset. So I'll hold off on applying this set. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
zli@linux.vnet.ibm.com wrote:
# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208332735 -28800 # Node ID 32614eca2a5579389cc5b262eff8243b0ca2da82 # Parent 7c20d87e25c0cd53deba4dc8c48529d84bb740d9 [TEST] KVMXML cim_define() support and KVM support for Profile.02
Signed-off-by: Zhengang Li <lizg@cn.ibm.com>
diff -r 7c20d87e25c0 -r 32614eca2a55 suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py
This is a nice clean up and looks good to me. However, the test fails due to the "Address field missing from vsms.py" issue Deepti noted in her e-mail about Dan's emulator fix.
For the Address fix, we'll need conditional behavior based on the changeset. So I'll hold off on applying this set.
I saw this patch when I was trying to update the cim_define() support for KVM and others. Is this still true that we'll need to do conditional behavior on changeset?
-- - Zhengang

Zhengang Li wrote:
Kaitlin Rupert wrote:
zli@linux.vnet.ibm.com wrote:
# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208332735 -28800 # Node ID 32614eca2a5579389cc5b262eff8243b0ca2da82 # Parent 7c20d87e25c0cd53deba4dc8c48529d84bb740d9 [TEST] KVMXML cim_define() support and KVM support for Profile.02
Signed-off-by: Zhengang Li <lizg@cn.ibm.com>
diff -r 7c20d87e25c0 -r 32614eca2a55 suites/libvirt-cim/cimtest/Profile/02_profile_to_elec.py
This is a nice clean up and looks good to me. However, the test fails due to the "Address field missing from vsms.py" issue Deepti noted in her e-mail about Dan's emulator fix.
For the Address fix, we'll need conditional behavior based on the changeset. So I'll hold off on applying this set.
I saw this patch when I was trying to update the cim_define() support for KVM and others. Is this still true that we'll need to do conditional behavior on changeset?
I've tagged a release of the cimtest tree. So now, we'll be able to check out a release that is tied to the latest release of libvirt-cim. You won't need to use the conditional branch on this patch. Sorry for the slow reply! -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Zhengang Li <lizg@cn.ibm.com> # Date 1208333452 -28800 # Node ID e54b31ce89af19ca0d4c40ce4b097685e34aa2c7 # Parent 32614eca2a5579389cc5b262eff8243b0ca2da82 [TEST] Add KVM support for Profile.03 Signe-off-by: Zhengang Li <lizg@cn.ibm.com> diff -r 32614eca2a55 -r e54b31ce89af suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py --- a/suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py Wed Apr 16 15:58:55 2008 +0800 +++ b/suites/libvirt-cim/cimtest/Profile/03_rprofile_gi_errs.py Wed Apr 16 16:10:52 2008 +0800 @@ -52,12 +52,13 @@ import pywbem import pywbem from VirtLib import utils from XenKvmLib import assoc +from XenKvmLib.classes import get_typed_class from XenKvmLib.common_util import try_getinstance from CimTest.ReturnCodes import PASS, FAIL from CimTest import Globals from CimTest.Globals import do_main -sup_types = ['Xen'] +sup_types = ['Xen', 'KVM'] expr_values = { "invalid_instid_keyvalue" : { 'rc' : pywbem.CIM_ERR_NOT_FOUND, \ @@ -74,31 +75,35 @@ def main(): prev_namespace = Globals.CIM_NS Globals.CIM_NS = 'root/interop' - classname = 'Xen_RegisteredProfile' + classname = get_typed_class(options.virt, 'RegisteredProfile') status = PASS - conn = assoc.myWBEMConnection('http://%s' % options.ip, ( \ - Globals.CIM_USER, Globals.CIM_PASS), Globals.CIM_NS) + conn = assoc.myWBEMConnection('http://%s' % options.ip, + (Globals.CIM_USER, Globals.CIM_PASS), + Globals.CIM_NS) - inst_id = ["CIM:DSP1042-SystemVirtualization-1.0.0", "CIM:DSP1057-VirtualSystem-1.0.0a"] + inst_id = ["CIM:DSP1042-SystemVirtualization-1.0.0", + "CIM:DSP1057-VirtualSystem-1.0.0a"] # 1) Test by passing Invalid InstanceID Key Value field = 'INVALID_Instid_KeyValue' keys = { 'InstanceID' : field } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid_keyvalue'], bug_no="") + ret_value = try_getinstance(conn, classname, keys, field_name=field, + expr_values=expr_values['invalid_instid_keyvalue'], + bug_no="") if ret_value != PASS: - Globals.logger.error("------ FAILED: Invalid InstanceID Key Value.------") + Globals.logger.error("--- FAILED: Invalid InstanceID Key Value.---") status = ret_value # 2) Test by giving Invalid InstanceID Key Name for i in range(len(inst_id)): field = 'INVALID_Instid_KeyName' keys = { field : inst_id[i] } - ret_value = try_getinstance(conn, classname, keys, field_name=field, \ - expr_values=expr_values['invalid_instid_keyname'], bug_no="") + ret_value = try_getinstance(conn, classname, keys, field_name=field, + expr_values=expr_values['invalid_instid_keyname'], + bug_no="") if ret_value != PASS: - Globals.logger.error("------ FAILED: Invalid InstanceID Key Name.------") + Globals.logger.error("--- FAILED: Invalid InstanceID Key Name.---") status = ret_value Globals.CIM_NS = prev_namespace
participants (3)
-
Kaitlin Rupert
-
Zhengang Li
-
zli@linux.vnet.ibm.com