in perfmetrics/scripts/ls_metrics/listing_benchmark.py [0:0]
def _compare_directory_structure(url, directory_structure) -> bool:
"""Compares the directory structure present in the GCS bucket with the structure present in the JSON config file.
Args:
url: Path of the directory to compare in the GCS bucket.
directory_structure: Protobuf of the current directory.
Returns:
True if GCS bucket contents matches the directory structure.
"""
contents_url = _list_directory(url)
# gsutil in some cases return the contents_url list with the current
# directory in the first index. We dont want the current directory so
# we remove it manually.
if contents_url and contents_url[0] == url:
contents_url = contents_url[1:]
files = []
folders = []
for content in contents_url:
if content[-1] == '/':
folders.append(content)
else:
files.append(content)
if len(folders) != directory_structure.num_folders:
return False
if len(files) != directory_structure.num_files:
return False
result = True
for folder in directory_structure.folders:
if not RUN_1M_TEST and folder.name == "1KB_1000000files_0subdir":
# Excluding test case with 1m files from HNS in daily periodic tests.
continue
new_url = url + folder.name + '/'
if new_url not in folders:
return False
result = result and _compare_directory_structure(new_url, folder)
return result