From 6e405594df4b8c53a516d029859f82321d48e543 Mon Sep 17 00:00:00 2001 From: Rahul Chauhan Date: Thu, 25 Apr 2024 14:47:57 +0200 Subject: [PATCH] Update default dataset correct typo for rule_id correct read rule url --- helpers/README.md | 2 +- helpers/test_http_tape_rest_api.py | 46 +++++++++++++++++------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/helpers/README.md b/helpers/README.md index 047a05eb..3cf0a118 100644 --- a/helpers/README.md +++ b/helpers/README.md @@ -28,7 +28,7 @@ This is to test HTTP REST API readiness for all our Tapes. --name NAME can be specified if the default scope and name are not desired. ``` -6. For a Read Test `python3 test_http_tape_rest_api.py --rse RSENAME --mode read --ruleid RULEID` +6. For a Read Test `python3 test_http_tape_rest_api.py --readtorse RSENAME --mode read --ruleid RULEID` ``` where RULEID is the rule id of the file that was written in the write test. optionally: diff --git a/helpers/test_http_tape_rest_api.py b/helpers/test_http_tape_rest_api.py index d92d861f..cb1273c7 100644 --- a/helpers/test_http_tape_rest_api.py +++ b/helpers/test_http_tape_rest_api.py @@ -10,7 +10,8 @@ def set_davs_endpoint(client, rse): # but we do it to emulate the final goal of having only davs protocol for proto in protocols: if proto['scheme'] != 'davs': - client.delete_protocols(rse=rse, scheme=proto['scheme'], hostname=proto['hostname'], port=proto['port']) + client.delete_protocols( + rse=rse, scheme=proto['scheme'], hostname=proto['hostname'], port=proto['port']) # Then set update_from_json=False client.add_rse_attribute(rse=rse, key='update_from_json', value=False) @@ -18,25 +19,25 @@ def set_davs_endpoint(client, rse): def create_write_rule(client, rse, scope, name): # create rule to the rse - rse_id = client.add_replication_rule(dids=[{'scope': scope, 'name': name}], - copies=1, rse_expression=rse, grouping='DATASET', lifetime=86400, - activity='Debug', - comment="Testing tape http rest write operation")[0] + rule_id = client.add_replication_rule(dids=[{'scope': scope, 'name': name}], + copies=1, rse_expression=rse, grouping='DATASET', lifetime=86400, + activity='Debug', + comment="Testing tape http rest write operation")[0] - print("Rule created: %s" % rse_id) - print(f"https://cms-rucio-webui.cern.ch/rule?rule_id={rse_id}") + print("Rule created: %s" % rule_id) + print(f"https://cms-rucio-webui.cern.ch/rule?rule_id={rule_id}") def create_read_rule(client, rse, scope, name, read_to_rse): # create rule to the rse - rse_id = client.add_replication_rule(dids=[{'scope': scope, 'name': name}], - copies=1, rse_expression=read_to_rse, grouping='DATASET', lifetime=86400, - activity='Debug', - comment="Testing tape http rest read operation", - source_replica_expression=rse) + rule_id = client.add_replication_rule(dids=[{'scope': scope, 'name': name}], + copies=1, rse_expression=read_to_rse, grouping='DATASET', lifetime=86400, + activity='Debug', + comment="Testing tape http rest read operation", + source_replica_expression=rse)[0] - print("Rule created: %s" % rse_id) - print(f"https://cms-rucio-webui.cern.ch/rule?rule_id={rse_id}") + print("Rule created: %s" % rule_id) + print(f"https://cms-rucio-webui.cern.ch/rule?rule_id={rule_id}") def check_davs_scheme_exists(client, rse): @@ -51,17 +52,21 @@ def check_davs_scheme_exists(client, rse): ap = ArgumentParser() ap.add_argument('--rse', help='rse to test', required=True) - ap.add_argument('--mode', help='mode to test', required=True, choices=['write', 'read']) + ap.add_argument('--mode', help='mode to test', + required=True, choices=['write', 'read']) # arguments for write mode - ap.add_argument('--scope', help='scope of did to use for write operation', default='cms') + ap.add_argument( + '--scope', help='scope of did to use for write operation', default='cms') ap.add_argument( '--dataset', help='dataset name to use for write operation', - default='/StreamALCAPPSExpress/Run2023C-PPSCalMaxTracks-Express-v4/ALCARECO#fefaecd0-d3a3-4dec-85b0-7a031b2fecc6') + default='/HIPhysicsRawPrime19/HIRun2023A-PromptReco-v2/MINIAOD#0fcda50b-cea5-476c-964c-b6cb4ebcb970') # arguments for read mode - ap.add_argument('--ruleid', help='exsiting rule id to use as a read source', default=None) - ap.add_argument('--readtorse', help='destination rse to use for read operation', default='T2_CH_CERN') + ap.add_argument( + '--ruleid', help='exsiting rule id to use as a read source', default=None) + ap.add_argument( + '--readtorse', help='destination rse to use for read operation', default='T2_CH_CERN') args = ap.parse_args() @@ -78,7 +83,8 @@ def check_davs_scheme_exists(client, rse): if rule['state'] != 'OK' or rule["rse_expression"] != rse: raise Exception except Exception as e: - print("Rule not found or not valid, please provide a valid rule id or try again in 1 hr", e) + print( + "Rule not found or not valid, please provide a valid rule id or try again in 1 hr", e) exit(1) if not check_davs_scheme_exists(client, rse):