Skip to content

Commit

Permalink
Misleading warnings when submitting a Lifetime Model exception with a…
Browse files Browse the repository at this point in the history
…n input file containing duplicate entries : Closes rucio#6146
  • Loading branch information
cserf committed Apr 19, 2023
1 parent b5874bf commit b72d5fa
Show file tree
Hide file tree
Showing 2 changed files with 24 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
23 changes: 23 additions & 0 deletions lib/rucio/tests/test_bin_rucio.py
Expand Up @@ -13,9 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import codecs
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 +28,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 +70,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 +2331,22 @@ 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(seconds=86400)).strftime('%Y-%m-%d'))
tomorrow = datetime.utcnow() + timedelta(days=1)
tomorrow = tomorrow.strftime('%Y-%m-%d')
self.config_client.set_config_option(section='lifetime_model', option='cutoff_date', value=tomorrow)
string = codecs.encode("%s\n" % tmp_dsn_did, 'utf-8')
with tempfile.NamedTemporaryFile() as fp:
fp.write(string)
fp.write(string)
fp.seek(0)
exitcode, out, err = execute("rucio add-lifetime-exception --inputfile %s --reason 'For testing purposed; please ignore.' --expiration 2124-01-01" % fp.name)
assert err.find('does not exist') == -1

0 comments on commit b72d5fa

Please sign in to comment.