@@ -127,6 +127,7 @@ def get_cmd_output(cmd_out):
127127 out = out .strip ('\n ' )
128128 return out
129129
130+
130131def main ():
131132 """
132133 execute the datacache test
@@ -172,24 +173,45 @@ def main():
172173 json_op = json .loads (out )
173174 cached_object_name = json_op ['manifest' ]['prefix' ]
174175 log .debug ("Cached object name is: %s" , cached_object_name )
175-
176- # check that the cache is enabled (does the cache directory empty)
176+ stripe_size = json_op ['manifest' ]['begin_iter' ]['stripe_size' ]
177+ log .debug ("*** stripe_size = %s" , stripe_size )
178+ stripe_max_size = json_op ['manifest' ]['rules' ][0 ]['val' ]['stripe_max_size' ]
179+ log .debug ("*** stripe_max_size = %s" , stripe_max_size )
180+ compression_type = 'none'
181+ if 'compression' in json_op and 'compression_type' in json_op ['compression' ]:
182+ compression_type = json_op ['compression' ]['compression_type' ]
183+ log .debug ("*** compression_type = %s" , compression_type )
184+
185+ # check if the cache directory is empty or not
177186 out = exec_cmd ('find %s -type f | wc -l' % (cache_dir ))
178- chk_cache_dir = int (get_cmd_output (out ))
179- log .debug ("Check cache dir content: %s" , chk_cache_dir )
180- if chk_cache_dir == 0 :
181- log .info ("NOTICE: datacache test object not found, inspect if datacache was bypassed or disabled during this check." )
187+ cache_dir_file_count = int (get_cmd_output (out ))
188+ log .debug ("*** cache_dir_file_count = %s" , cache_dir_file_count )
189+
190+ if stripe_max_size > 4194304 :
191+ # ref: qa/suites/rgw/verify/striping$/stripe-greater-than-chunk.yaml : "rgw obj stripe size: 6291456"
192+ log .debug ("*** NOTICE: Running under 'stripe-greater-than-chunk' permutation - skipping the RGW Datacache test" )
193+ return
194+ elif compression_type != 'none' :
195+ log .debug ("*** NOTICE: Running under 'compression' enabled permutation - skipping the RGW Datacache test" )
182196 return
197+ else :
198+ log .debug ("*** NOTICE: RGW Datacache test will be performed" )
199+
200+ if cache_dir_file_count == 0 :
201+ log .debug ("*** ERROR: Cache directory is empty, RGW Datacache test FAILED" )
202+ assert (cache_dir_file_count > 0 )
183203
184204 # list the files in the cache dir for troubleshooting
185- out = exec_cmd ('ls -l %s' % (cache_dir ))
205+ out = exec_cmd ('ls -ltr %s' % (cache_dir ))
186206 # get name of cached object and check if it exists in the cache
187- out = exec_cmd ('find %s -type f -name "*" | tail -1' % (cache_dir ))
188- cached_object_path = get_cmd_output (out )
207+ out = exec_cmd ('ls -1tr %s | tail -1' % (cache_dir ))
208+ cached_object_path = cache_dir + "/" + get_cmd_output (out )
209+
210+ out = exec_cmd ('ls -ltr %s' % (cache_dir ))
189211 log .debug ("Path of file in datacache is: %s" , cached_object_path )
190212 out = exec_cmd ("sha1sum %s | awk '{ print $1 }'" % (cached_object_path ))
191213 cached_object_sha1 = get_cmd_output (out )
192- log .debug ("SHA1 of file in datacache is: %s" , cached_object_sha1 )
214+ log .debug ("*** SHA1 of file in datacache is: %s" , cached_object_sha1 )
193215
194216 # check to see if the cached object is in Ceph
195217 out = exec_cmd ('rados ls -p default.rgw.buckets.data' )
@@ -198,14 +220,16 @@ def main():
198220
199221 out = exec_cmd ("dd status=none if=%s of=/dev/stdout bs=1M skip=4 | sha1sum | awk '{ print $1 }'" % (outfile ))
200222 org_object_sha1 = get_cmd_output (out )
201- log .debug ("SHA1 of cached part in original file is: %s" , org_object_sha1 )
223+ log .debug ("*** SHA1 of cached part in original file is: %s" , org_object_sha1 )
202224 out = exec_cmd ("dd status=none if=%s of=/dev/stdout bs=1M skip=4 | sha1sum | awk '{ print $1 }'" % (get_file_path ))
203225 download_object_sha1 = get_cmd_output (out )
204- log .debug ("SHA1 of cached part in downloaded file is: %s" , download_object_sha1 )
226+ log .debug ("*** SHA1 of cached part in downloaded file is: %s" , download_object_sha1 )
227+
228+ log .debug ("*** CHECK: cache_dir_file_count: %s > 0 and (cached_object_sha1: %s == org_object_sha1: %s or (stripe_size: %s < 4194304 and org_object_sha1: %s == download_object_sha1: %s)" , cache_dir_file_count , cached_object_sha1 , org_object_sha1 , stripe_size , org_object_sha1 , download_object_sha1 )
229+ assert (cache_dir_file_count > 0 and (cached_object_sha1 == org_object_sha1 or (stripe_size < 4194304 and org_object_sha1 == download_object_sha1 )))
230+ # (cached_object_sha1 == org_object_sha1) test fails if "stripe_size" < 4MiB(4194304),
231+ # in that case fall back to checking the sha1 of the downloaded file (https://tracker.ceph.com/issues/71387)
205232
206- assert ((cached_object_sha1 == org_object_sha1 ) or (org_object_sha1 == download_object_sha1 and chk_cache_dir > 0 ))
207- # (cached_object_sha1 == org_object_sha1) test fails if "stripe_size" is not exactly 4MiB(4194304),
208- # in that case fall back to checking the sha1 of the downloaded file
209233 log .debug ("RGW Datacache test SUCCESS" )
210234
211235 # remove datacache dir
0 commit comments