Skip to content

Commit

Permalink
Merge pull request #786 from dynamic-entropy/update_tape_rest_helper_…
Browse files Browse the repository at this point in the history
…script

Make minor corrections to helper script
  • Loading branch information
dynamic-entropy authored Apr 26, 2024
2 parents 1e83e37 + 6e40559 commit 820e1ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion helpers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
46 changes: 26 additions & 20 deletions helpers/test_http_tape_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,34 @@ 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)


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):
Expand All @@ -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()

Expand All @@ -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):
Expand Down

0 comments on commit 820e1ab

Please sign in to comment.