Skip to content

Commit

Permalink
Client: Fix faulty list account usage test and untracked error #4870
Browse files Browse the repository at this point in the history
When an RSE was specified for the list-account-usage an KeyError:
'resolved_rses' was generated. The key does not exist in the underlying data
model.

The `test_list_account_usage` did not report the problem since the regex, which
compared the actual output with the expected result, contained an unescaped `|`
character. Hence the test produced a passing test, while a failing was expected.
  • Loading branch information
Joel Dierkes authored and bari12 committed Oct 12, 2021
1 parent 054e7a1 commit b364c05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/rucio
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ def list_account_usage(args):
table = []
usage = client.get_global_account_usage(account=args.usage_account)
for item in usage:
if (args.rse and args.rse in item['resolved_rses']) or not args.rse:
if (args.rse and args.rse in item['rse_expression']) or not args.rse:
remaining = 0 if float(item['bytes_remaining']) < 0 else float(item['bytes_remaining'])
table.append([item['rse_expression'], sizefmt(item['bytes'], args.human), sizefmt(item['bytes_limit'], args.human), sizefmt(remaining, args.human)])
table.sort()
Expand Down
6 changes: 4 additions & 2 deletions lib/rucio/tests/test_bin_rucio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1563,11 +1563,13 @@ def test_list_account_usage(self):
cmd = 'rucio list-account-usage {0}'.format(account)
exitcode, out, err = execute(cmd)
assert re.search('.*{0}.*{1}.*{2}.*{3}'.format(rse, usage, local_limit, local_left), out) is not None
assert re.search('.*{0}.*{1}.*{2}.*{3}'.format(rse_exp, usage, global_limit, global_left), out) is not None
assert re.search('.*{0}.*{1}.*{2}.*{3}'.format(r'MOCK\|MOCK4', usage, global_limit, global_left), out) is not None

cmd = 'rucio list-account-usage --rse {0} {1}'.format(rse, account)
exitcode, out, err = execute(cmd)
assert exitcode == 0
assert re.search('.*{0}.*{1}.*{2}.*{3}'.format(rse, usage, local_limit, local_left), out) is not None
assert re.search('.*{0}.*{1}.*{2}.*{3}'.format(rse_exp, usage, global_limit, global_left), out) is not None
assert re.search('.*{0}.*{1}.*{2}.*{3}'.format(r'MOCK\|MOCK4', usage, global_limit, global_left), out) is not None
self.account_client.set_local_account_limit(account, rse, -1)
self.account_client.set_global_account_limit(account, rse_exp, -1)

Expand Down

0 comments on commit b364c05

Please sign in to comment.