Skip to content

Commit

Permalink
Lifetime Model: Deduplicate input file : Closes rucio#6146
Browse files Browse the repository at this point in the history
  • Loading branch information
cserf committed Apr 26, 2023
1 parent 3385266 commit bce59a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/rucio
Expand Up @@ -1723,7 +1723,7 @@ def add_lifetime_exception(args):
logger.error('inputfile is mandatory')
return FAILURE
with open(args.inputfile) as infile:
dids = list(filter(None, [line.strip() for line in infile]))
dids = list(set(line.strip() for line in infile))

dids_list = []
containers = []
Expand Down
20 changes: 20 additions & 0 deletions lib/rucio/tests/test_bin_rucio.py
Expand Up @@ -16,6 +16,7 @@
import os
import random
import re
import tempfile
from datetime import datetime, timedelta
from os import remove, unlink, listdir, rmdir, stat, path, environ

Expand All @@ -26,6 +27,7 @@
from rucio.client.replicaclient import ReplicaClient
from rucio.client.rseclient import RSEClient
from rucio.client.ruleclient import RuleClient
from rucio.client.configclient import ConfigClient
from rucio.common.config import config_get, config_get_bool
from rucio.common.types import InternalScope, InternalAccount
from rucio.common.utils import generate_uuid, get_tmp_dir, md5, render_json
Expand Down Expand Up @@ -67,6 +69,7 @@ def setup_obj(self, vo, function_scope_prefix):
self.did_client = DIDClient()
self.replica_client = ReplicaClient()
self.rule_client = RuleClient()
self.config_client = ConfigClient()
self.account_client = AccountLimitClient()
rse_factory = None
if environ.get('SUITE', 'remote_dbs') != 'client':
Expand Down Expand Up @@ -2327,3 +2330,20 @@ def test_admin_rse_update_unsupported_option(self):
print(out, err)
assert exitcode == 0
assert not err

@pytest.mark.noparallel(reason='Modify config')
def test_lifetime_cli(self):
""" CLIENT(USER): Check CLI to declare lifetime exceptions """
# Setup data for CLI check
tmp_dsn_name = 'container' + rse_name_generator()
tmp_dsn_did = self.user + ':' + tmp_dsn_name
self.did_client.add_did(scope=self.user, name=tmp_dsn_name, did_type='DATASET')
self.did_client.set_metadata(scope=self.user, name=tmp_dsn_name, key='eol_at', value=(datetime.utcnow() - timedelta(days=1)).strftime('%Y-%m-%d'))
self.config_client.set_config_option(section='lifetime_model', option='cutoff_date', value=(datetime.utcnow() + timedelta(days=1)).strftime('%Y-%m-%d'))
string = f"%s{tmp_dsn_did}\n"
with tempfile.NamedTemporaryFile(mode="w+") as fp:
fp.write(string)
fp.write(string)
fp.seek(0)
exitcode, out, err = execute("rucio add-lifetime-exception --inputfile %s --reason 'For testing purpose; please ignore.' --expiration 2124-01-01" % fp.name)
assert err.find('does not exist') == -1

0 comments on commit bce59a0

Please sign in to comment.