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

yunguol at cn.ibm.com yunguol at cn.ibm.com
Tue Mar 24 09:09:53 UTC 2009


# HG changeset patch
# User Guolian Yun <yunguol at 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 at 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 at 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'
+
+ at 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())




More information about the Libvirt-cim mailing list