[PATCH] [TEST] Add new tc to verify VSMS.RemoveResourceSettings() with invalid instance

# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1237885787 25200 # Node ID 125291db2a71a803ce3ee991dd730aaddb1d3157 # Parent 57f08f1c7a1a8b7c9068e1bf0e76368bb92ead26 [TEST] Add new tc to verify VSMS.RemoveResourceSettings() with invalid instance Tested for KVM, Xen with current sources and rpm Signed-off-by: Guolian Yun<yunguol@cn.ibm.com> diff -r 57f08f1c7a1a -r 125291db2a71 suites/libvirt-cim/cimtest/VirtualSystemManagementService/17_removeresource_neg.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/17_removeresource_neg.py Tue Mar 24 02:09:47 2009 -0700 @@ -0,0 +1,71 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Guolian Yun <yunguol@cn.ibm.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import pywbem +from XenKvmLib.vsms import get_vsms_class +from XenKvmLib.vxml import get_class +from CimTest.Globals import logger +from XenKvmLib.const import do_main +from CimTest.ReturnCodes import FAIL, PASS + +exp_rc = 13 +exp_desc = 'CIM_ERR_TYPE_MISMATCH' + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'domain' + +@do_main(sup_types) +def main(): + options = main.options + + cxml = get_class(options.virt)(default_dom) + ret = cxml.cim_define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + return FAIL + + rc = -1 + try: + bad_inst = 'instance of what ever dfs&' + service = get_vsms_class(options.virt)(options.ip) + ret = service.RemoveResourceSettings(ResourceSettings=[bad_inst]) + if ret[0] == 0: + logger.error('RemoveRS should NOT return OK with wrong RS input') + rc = 0 + except pywbem.CIMError, (rc, desc): + if rc == exp_rc and desc.find(exp_desc) >= 0: + logger.info('Got expected rc code and error string') + status = PASS + else: + logger.error('Unexpected rc code %s and description"\n %s', + rc, desc) + status = FAIL + except Exception, details: + logger.error(details) + status = FAIL + + cxml.undefine(options.ip) + return status + +if __name__ == "__main__": + sys.exit(main())

This tc fails for KVM with current src because of the exp_desc. The error desc expects to "The value supplied is incompatible with the type" instead of "CIM_ERR_TYPE_MISMATCH" for KVM with current src. But this tc with exp_desc of "CIM_ERR_TYPE_MISMATCH" pass for Xen with current src. I'm not sure why it is? Why the error desc is different from Xen to KVM with the same libvit-cim version? libvirt-cim-bounces@redhat.com wrote on 2009-03-24 17:09:53:
# HG changeset patch # User Guolian Yun <yunguol@cn.ibm.com> # Date 1237885787 25200 # Node ID 125291db2a71a803ce3ee991dd730aaddb1d3157 # Parent 57f08f1c7a1a8b7c9068e1bf0e76368bb92ead26 [TEST] Add new tc to verify VSMS.RemoveResourceSettings() with invalid instance
Tested for KVM, Xen with current sources and rpm Signed-off-by: Guolian Yun<yunguol@cn.ibm.com>
diff -r 57f08f1c7a1a -r 125291db2a71 suites/libvirt- cim/cimtest/VirtualSystemManagementService/17_removeresource_neg.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt- cim/cimtest/VirtualSystemManagementService/17_removeresource_neg.py Tue Mar 24 02:09:47 2009 -0700 @@ -0,0 +1,71 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Guolian Yun <yunguol@cn.ibm.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import sys +import pywbem +from XenKvmLib.vsms import get_vsms_class +from XenKvmLib.vxml import get_class +from CimTest.Globals import logger +from XenKvmLib.const import do_main +from CimTest.ReturnCodes import FAIL, PASS + +exp_rc = 13 +exp_desc = 'CIM_ERR_TYPE_MISMATCH' + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'domain' + +@do_main(sup_types) +def main(): + options = main.options + + cxml = get_class(options.virt)(default_dom) + ret = cxml.cim_define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + return FAIL + + rc = -1 + try: + bad_inst = 'instance of what ever dfs&' + service = get_vsms_class(options.virt)(options.ip) + ret = service.RemoveResourceSettings(ResourceSettings=[bad_inst]) + if ret[0] == 0: + logger.error('RemoveRS should NOT return OK with wrong RS input') + rc = 0 + except pywbem.CIMError, (rc, desc): + if rc == exp_rc and desc.find(exp_desc) >= 0: + logger.info('Got expected rc code and error string') + status = PASS + else: + logger.error('Unexpected rc code %s and description"\n %s', + rc, desc) + status = FAIL + except Exception, details: + logger.error(details) + status = FAIL + + cxml.undefine(options.ip) + return status + +if __name__ == "__main__": + sys.exit(main())
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

Guo Lian Yun wrote:
This tc fails for KVM with current src because of the exp_desc. The error desc expects to "The value supplied is incompatible with the type" instead of "CIM_ERR_TYPE_MISMATCH" for KVM with current src.
But this tc with exp_desc of "CIM_ERR_TYPE_MISMATCH" pass for Xen with current src. I'm not sure why it is? Why the error desc is different from Xen to KVM with the same libvit-cim version?
When I run on KVM, I see the following: Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 17_removeresource_neg.py: FAIL InvokeMethod(RemoveResourceSettings): CIM_ERR_TYPE_MISMATCH 13 CIM_ERR_TYPE_MISMATCH -------------------------------------------------------------------- What error are you seeing? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

libvirt-cim-bounces@redhat.com wrote on 2009-03-25 01:03:33:
Guo Lian Yun wrote:
This tc fails for KVM with current src because of the exp_desc. The error desc expects to "The value supplied is incompatible with the
type" instead of "CIM_ERR_TYPE_MISMATCH" for KVM with current src.
But this tc with exp_desc of "CIM_ERR_TYPE_MISMATCH" pass for Xen with
current src. I'm not sure why it is? Why the error desc is different from Xen to KVM with the same libvit-cim version?
When I run on KVM, I see the following:
Testing KVM hypervisor -------------------------------------------------------------------- VirtualSystemManagementService - 17_removeresource_neg.py: FAIL InvokeMethod(RemoveResourceSettings): CIM_ERR_TYPE_MISMATCH 13 CIM_ERR_TYPE_MISMATCH --------------------------------------------------------------------
What error are you seeing? It outputs as follows: "The value supplied is incompatible with the type"
Just as you said, this bad inst will verify the COMOM instead of VSMS.RemoveRS() function. I create a DiskRASD with invalid InstanceID and pass to VSMS.RemoveRS() in #2 tc, and the tc works for me now. Thank for your help =)
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim

+exp_rc = 13 +exp_desc = 'CIM_ERR_TYPE_MISMATCH' + +sup_types = ['Xen', 'KVM', 'XenFV'] +default_dom = 'domain' + +@do_main(sup_types) +def main(): + options = main.options + + cxml = get_class(options.virt)(default_dom) + ret = cxml.cim_define(options.ip) + if not ret: + logger.error("Failed to define the dom: %s", default_dom) + return FAIL + + rc = -1 + try: + bad_inst = 'instance of what ever dfs&'
This will just verify the CIMOM, since the CIMOM will check the type of the parameter. Instead, you need to create a RASD instance, but have something in the instance be invalid. One example would be to create a RASD of a class type we don't support, or set all of the attributes to NULL / 0.
+ service = get_vsms_class(options.virt)(options.ip) + ret = service.RemoveResourceSettings(ResourceSettings=[bad_inst]) + if ret[0] == 0: + logger.error('RemoveRS should NOT return OK with wrong RS input') + rc = 0
Why do you set the rc value here? You don't check it afterwards.
+ except pywbem.CIMError, (rc, desc): + if rc == exp_rc and desc.find(exp_desc) >= 0: + logger.info('Got expected rc code and error string') + status = PASS + else: + logger.error('Unexpected rc code %s and description"\n %s', + rc, desc) + status = FAIL + except Exception, details: + logger.error(details) + status = FAIL + + cxml.undefine(options.ip) + return status +
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Guo Lian Yun
-
Kaitlin Rupert
-
yunguol@cn.ibm.com