[Libvirt-cim] [PATCH] [TEST] Fix potiential false positive in AC 01

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Jul 10 18:53:17 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1215715693 25200
# Node ID c09b0a978a6621139eb355079994ba3eb2847779
# Parent  502dddef8c34eeb85b571df0ee97f0ee0676861b
[TEST] Fix potiential false positive in AC 01.

This test needs to verify enum of AC returns the same number of instances as the number of instances returned by enum of MemoryPool + ProcessorPool + DiskPool + NetworkPool.

Also, cleaned up the logic to verify that the ResourceType and the InstanceIDs of the AC instances match the Pool instances they're describing.


Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 502dddef8c34 -r c09b0a978a66 suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py
--- a/suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py	Tue Jul 01 14:12:48 2008 -0700
+++ b/suites/libvirt-cim/cimtest/AllocationCapabilities/01_enum.py	Thu Jul 10 11:48:13 2008 -0700
@@ -22,6 +22,7 @@
 #
 
 import sys
+from VirtLib.live import virsh_version
 from XenKvmLib import enumclass
 from CimTest.Globals import do_main
 from CimTest.Globals import logger, CIM_ERROR_ENUMERATE, platform_sup
@@ -32,48 +33,52 @@
 def main():
     options = main.options
 
+    cn = 'AllocationCapabilities'
+
     pools = {}
     pt = ['MemoryPool', 'ProcessorPool', 'DiskPool', 'NetworkPool']
     try:
-        key_list = ["InstanceID"]
-        ac = enumclass.enumerate(options.ip,
-                                 "AllocationCapabilities",
-                                 key_list,
-                                 options.virt)
-        pools['MemoryPool'] = enumclass.enumerate(options.ip,
-                                                  "MemoryPool",
-                                                  key_list,
-                                                  options.virt)
-        pools['ProcessorPool'] = enumclass.enumerate(options.ip,
-                                                     "ProcessorPool",
-                                                     key_list,
-                                                     options.virt)
-        pools['DiskPool'] = enumclass.enumerate(options.ip,
-                                                "DiskPool",
-                                                key_list,
-                                                options.virt)
-        pools['NetworkPool'] = enumclass.enumerate(options.ip,
-                                                   "NetworkPool",
-                                                   key_list,
-                                                   options.virt)
-    except Exception:
-        logger.error(CIM_ERROR_ENUMERATE, '%s_AllocationCapabilities' % options.virt)
+        key = ["InstanceID"]
+        ac = enumclass.enumerate(options.ip, cn, key, options.virt)
+
+        for p in pt:
+            enum_list = enumclass.enumerate(options.ip, p, key, options.virt)
+
+            if len(enum_list) < 1:
+                # If libvirt version >= 0.4.1, libvirt-cim uses libvirt's
+                # disk pool support instead of creating its own diskpool.
+                # In this case, it's possible for a disk pool to not exist. 
+                libvirt_version = virsh_version(options.ip, options.virt)
+                if p == "DiskPool" and libvirt_version >= '0.4.1':
+                    continue
+
+                logger.error("%s did not return any instances" % p)
+                return FAIL
+
+            for pool in enum_list:
+                pools[pool.InstanceID] = pool 
+
+    except Exception, details:
+        logger.error(CIM_ERROR_ENUMERATE, cn)
+        logger.error(details)
         return FAIL
      
-    acset = set([(x.InstanceID, x.ResourceType) for x in ac])
-    poolset = set()
-    for pl in pools.values():
-        for x in pl:
-            poolset.add((x.InstanceID, x.ResourceType))
+    if len(ac) != len(pools):
+        logger.error("%s returned %s instances, expected %s" % (cn, len(ac), 
+                     len(pools)))
+        return FAIL
 
-    if len(acset) != len(poolset):
-        logger.error(
-                'AllocationCapabilities return %i instances, excepted %i'
-                % (ac_size, pool_size))
-        return FAIL
-    zeroset = acset - poolset
-    if len(zeroset) != 0:
-        logger.error('AC is inconsistent with pools')
+    try:
+        for inst in ac: 
+            id = inst.InstanceID
+            if pools[id].ResourceType != inst.ResourceType: 
+                logger.error("%s ResourceType %s, Pool ResourceType %s" % (cn, 
+                             inst.ResourceType, pools[id].ResourceType))
+                return FAIL
+            
+    except Exception, details:
+        logger.error("%s returned instance with unexpected InstanceID %s" % (cn,
+                     details))
         return FAIL
 
     return PASS




More information about the Libvirt-cim mailing list