[Libvirt-cim] [PATCH] [TEST]#2 Fixed the RASD/07_parent_disk_pool.py

Deepti B. Kalakeri deeptik at linux.vnet.ibm.com
Mon Jul 20 15:25:48 UTC 2009


# HG changeset patch
# User Deepti B.Kalakeri <deeptik at linux.vnet.ibm.com>
# Date 1248103418 25200
# Node ID fc0ce87139b4f1e8a1967e927bf28e442ca3175d
# Parent  14b666e2a803048c1ce4e71b550a49c62915b3a3
[TEST]#2 Fixed the RASD/07_parent_disk_pool.py

Patch 2:
-------
1) Improved the code

Verified with KVM  and current sources on F10 and SLES11.
Signed-off-by: Deepti B. Kalakeri <deeptik at linux.vnet.ibm.com>

diff -r 14b666e2a803 -r fc0ce87139b4 suites/libvirt-cim/cimtest/RASD/07_parent_disk_pool.py
--- a/suites/libvirt-cim/cimtest/RASD/07_parent_disk_pool.py	Thu Jul 16 07:28:51 2009 -0700
+++ b/suites/libvirt-cim/cimtest/RASD/07_parent_disk_pool.py	Mon Jul 20 08:23:38 2009 -0700
@@ -37,7 +37,7 @@
 # -PoolID="DiskPool/0"
 # -Type=3               [ For Type 1 and 2 as well ]
 # -Path="/dev/null"
-# -DevicePath=
+# -DevicePaths=
 # -Host="host_sys.domain.com"
 # -SourceDirectory="/var/lib/images"
 # 
@@ -45,13 +45,51 @@
 
 import sys
 from sets import Set
+from copy import copy
 from CimTest.Globals import logger
 from XenKvmLib.const import do_main
 from CimTest.ReturnCodes import PASS, FAIL
 from XenKvmLib.pool import get_pool_rasds
 
 sup_types = ['KVM', 'Xen', 'XenFV']
-DISKPOOL_REC_LEN = 3
+DISKPOOL_REC_LEN = 7
+
+def init_list():
+    pval = "/dev/null"
+    ptype1 = { 'ResourceType' : 17,
+               'PoolID'       : "DiskPool/0",
+               'Type' : 1L, 'DevicePaths': None, 
+               'Host' : None, 'SourceDirectory': None, 
+               'Path' : pval }
+
+    ptype2 = ptype1.copy()
+    ptype2['Type'] = 2L
+    ptype2['DevicePaths'] = [u'/dev/sda100']
+
+    ptype3 = ptype1.copy()
+    ptype3['Type'] = 3L
+    ptype3['Host']  = u'host_sys.domain.com'
+    ptype3['SourceDirectory'] = u'/var/lib/images'
+    
+    ptype4 = ptype1.copy()
+    ptype4['Type'] = 4L
+    ptype4['DevicePaths'] = [u'/dev/VolGroup00/LogVol100']
+    
+    ptype5 = ptype1.copy()
+    ptype5['Type'] = 5L
+    ptype5['DevicePaths'] = [u'iscsi-target']
+    ptype3['Host']  = u'host_sys.domain.com'
+
+    ptype6 = ptype1.copy()
+    ptype6['Type'] = 6L
+
+    ptype7 = ptype1.copy()
+    ptype7['Type'] = 7L
+    ptype7['Path'] = '/dev/disk/by-id'
+
+    exp_t_dp_h_sdir_path = [ ptype1, ptype2, ptype3, ptype4, 
+                             ptype5, ptype6, ptype7 ]
+    return exp_t_dp_h_sdir_path
 
 def get_rec(diskpool_rasd, inst_id='Default'):
     recs = []
@@ -70,16 +108,9 @@
     if status != PASS:
         return status
     inst_list = [ 'Default', 'Minimum', 'Maximum', 'Increment' ]
-    n_rec_val = { 'ResourceType' : 17,
-                  'PoolID'       : "DiskPool/0",
-                  'Path'         : "/dev/null",
-                }
-    exp_type_path_host_dir = [('1', 'None', 'None', 'None'),
-                              ('2', '/dev/sda100', 'None', 'None'), 
-                              ('3', 'None', 'host_sys.domain.com', 
-                               '/var/lib/images')]
-                    
-                  
+
+    exp_t_dp_h_sdir_path = init_list()
+
     for inst_type in inst_list:
         logger.info("Verifying '%s' records", inst_type)
 
@@ -89,23 +120,30 @@
                 raise Exception("Got %s recs instead of %s" %(len(n_rec), 
                                  DISKPOOL_REC_LEN))
 
-            res_type_path_host_dir = []
             for rec in n_rec:
-                l = (str(rec['Type']), str(rec['DevicePath']), 
-                         str(rec['Host']), str(rec['SourceDirectory']))
-                res_type_path_host_dir.append(l)
+                found = False
+                for item in exp_t_dp_h_sdir_path:
+                    if rec['Type'] == item['Type']:
+                        found = True
+                        for key, val in item.iteritems():
+                             exp_val = val
+                             res_val = rec[key]
+                             if type(val).__name__ == 'list':
+                                 cmp_exp = (len(Set(res_val) - \
+                                            Set(exp_val)) != 0)
+                             elif type(val).__name__ != 'NoneType':
+                                 cmp_exp = (exp_val != res_val)
+                             elif type(val).__name__ == 'NoneType':
+                                 continue
 
-            if len(Set(exp_type_path_host_dir) & Set(res_type_path_host_dir)) \
-               != DISKPOOL_REC_LEN :
-                raise Exception("Mismatching values, \nGot %s,\nExpected %s"\
-                                 %(exp_type_path_host_dir, 
-                                   res_type_path_host_dir))
+                             if cmp_exp:
+                                 raise Exception("Mismatching values, "\
+                                                 "\nGot %s, \nExpected %s"\
+                                                  % (res_val, exp_val))
 
-            for key in n_rec_val.keys():
-                for rec in n_rec:
-                    if n_rec_val[key] != rec[key]:
-                        raise Exception("'%s' Mismatch, Got %s, Expected %s" \
-                                        % (key, rec[key],  n_rec_val[key]))
+                if found == False:
+                    raise Exception("Failed to get records for pooltype" \
+                                    " %s" % rec['Type'])  
 
         except Exception, details:
             logger.error("Exception details: %s", details)




More information about the Libvirt-cim mailing list