Skip to content

Commit

Permalink
using single config file flag along with bucket type
Browse files Browse the repository at this point in the history
  • Loading branch information
anushka567 committed Aug 22, 2024
1 parent 0da8dfd commit b6d7aff
Showing 1 changed file with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

# limitations under the License.
# To run the script,run in terminal:
# python3 renaming_benchmark.py [--flat_dir_config_file flat_dir-config.json] \
# [--hns_dir_config_file hns_dir-config.json] [--upload_gs] [--num_samples NUM_SAMPLES]
# python3 renaming_benchmark.py config.json bucket_type [--upload_gs] \
# [--num_samples NUM_SAMPLES]
# where dir-config.json file contains the directory structure details for the test.

import os
Expand Down Expand Up @@ -284,8 +284,8 @@ def _perform_testing(dir, test_type, num_samples, results):
hns_bucket_name=mount_gcs_bucket(dir["name"], hns_mount_flags, log)

# Record time of operation and populate the results dict.
flat_results = _record_time_of_operation(hns_bucket_name, dir, num_samples)
results["hns"] = flat_results
hns_results = _record_time_of_operation(hns_bucket_name, dir, num_samples)
results["hns"] = hns_results

unmount_gcs_bucket(dir["name"], log)
# Deleting config file for hns enabled mounting.
Expand All @@ -309,16 +309,15 @@ def _parse_arguments(argv):
parser = argparse.ArgumentParser()

parser.add_argument(
'--flat_dir_config_file',
help='Provide path of the config file for flat bucket.',
'config_file',
help='Provide path of the config file for GCS bucket.',
action='store',
required=False,
)
parser.add_argument(
'--hns_dir_config_file',
help='Provide path of the config file for hns bucket.',
'bucket_type',
help='Provide bucket type - hns or flat ',
action='store',
required=False,
choices=['hns','flat']
)
parser.add_argument(
'--upload_gs',
Expand Down Expand Up @@ -380,20 +379,11 @@ def _run_rename_benchmark(test_type,dir_config,num_samples,results,upload_gs):
if len(argv) < 2:
raise TypeError('Incorrect number of arguments.\n'
'Usage: '
'python3 renaming_benchmark.py [--upload_gs] [--num_samples NUM_SAMPLES] config_file ')
'python3 renaming_benchmark.py [--upload_gs] [--num_samples NUM_SAMPLES] config_file bucket_type')

args = _parse_arguments(argv)
check_dependencies(['gcloud', 'gcsfuse'], log)
#check_dependencies(['gcloud', 'gcsfuse'], log)
results = dict() # Dict object to store the results corresonding to the test types.

# If the config file for flat bucket is provided, we will perform rename benchmark
# for flat bucket.
if args.flat_dir_config_file:
_run_rename_benchmark("flat", args.flat_dir_config_file, args.num_samples,
results, args.upload_gs)

# If the config file for hns bucket is provided, we will perform rename benchmark
# for hns bucket.
if args.hns_dir_config_file:
_run_rename_benchmark("hns", args.hns_dir_config_file, args.num_samples,
_run_rename_benchmark(args.bucket_type, args.config_file, args.num_samples,
results, args.upload_gs)

0 comments on commit b6d7aff

Please sign in to comment.