Skip to content

Commit

Permalink
Tests: Use jdoe_account test fixture in Undertaker tests; rucio#6529
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio committed Mar 5, 2024
1 parent ca273f1 commit d8f3c68
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions tests/test_undertaker.py
Expand Up @@ -19,7 +19,7 @@
import pytest

from rucio.common.policy import get_policy
from rucio.common.types import InternalAccount, InternalScope
from rucio.common.types import InternalScope
from rucio.core.account_limit import set_local_account_limit
from rucio.core.did import add_dids, attach_dids, list_expired_dids, get_did, set_metadata
from rucio.core.replica import add_replicas, get_replica
Expand All @@ -37,15 +37,14 @@
@pytest.mark.noparallel(reason='uses pre-defined rses; runs undertaker, which impacts other tests')
class TestUndertaker:

def test_undertaker(self, vo, rse_factory, mock_scope, root_account):
def test_undertaker(self, vo, rse_factory, mock_scope, root_account, jdoe_account):
""" UNDERTAKER (CORE): Test the undertaker. """
jdoe = InternalAccount('jdoe', vo=vo)

nbdatasets = 5
nbfiles = 5
rse, rse_id = rse_factory.make_rse()

set_local_account_limit(jdoe, rse_id, -1)
set_local_account_limit(jdoe_account, rse_id, -1)

dsns1 = [{'name': did_name_generator('dataset'),
'scope': mock_scope,
Expand All @@ -56,7 +55,7 @@ def test_undertaker(self, vo, rse_factory, mock_scope, root_account):
'scope': mock_scope,
'type': 'DATASET',
'lifetime': -1,
'rules': [{'account': jdoe, 'copies': 1,
'rules': [{'account': jdoe_account, 'copies': 1,
'rse_expression': rse,
'grouping': 'DATASET'}]} for _ in range(nbdatasets)]

Expand All @@ -75,27 +74,26 @@ def test_undertaker(self, vo, rse_factory, mock_scope, root_account):
attach_dids(scope=mock_scope, name=dsn['name'], rse_id=rse_id, dids=files, account=root_account)
replicas += files

add_rules(dids=dsns1, rules=[{'account': jdoe, 'copies': 1, 'rse_expression': rse, 'grouping': 'DATASET'}])
add_rules(dids=dsns1, rules=[{'account': jdoe_account, 'copies': 1, 'rse_expression': rse, 'grouping': 'DATASET'}])

undertaker(once=True)
undertaker(once=True)

for replica in replicas:
assert get_replica(scope=replica['scope'], name=replica['name'], rse_id=rse_id)['tombstone'] is not None

def test_list_expired_dids_with_locked_rules(self, rse_factory, vo, mock_scope, root_account):
def test_list_expired_dids_with_locked_rules(self, rse_factory, vo, mock_scope, root_account, jdoe_account):
""" UNDERTAKER (CORE): Test that the undertaker does not list expired dids with locked rules"""
jdoe = InternalAccount('jdoe', vo=vo)

# Add quota
rse, rse_id = rse_factory.make_rse()
set_local_account_limit(jdoe, rse_id, -1)
set_local_account_limit(jdoe_account, rse_id, -1)

dsn = {'name': did_name_generator('dataset'),
'scope': mock_scope,
'type': 'DATASET',
'lifetime': -1,
'rules': [{'account': jdoe, 'copies': 1,
'rules': [{'account': jdoe_account, 'copies': 1,
'rse_expression': rse, 'locked': True,
'grouping': 'DATASET'}]}

Expand All @@ -104,27 +102,25 @@ def test_list_expired_dids_with_locked_rules(self, rse_factory, vo, mock_scope,
for did in list_expired_dids(limit=1000):
assert (did['scope'], did['name']) != (dsn['scope'], dsn['name'])

def test_atlas_archival_policy(self, vo, mock_scope, root_account):
def test_atlas_archival_policy(self, vo, mock_scope, root_account, jdoe_account):
""" UNDERTAKER (CORE): Test the atlas archival policy. """
if get_policy() != 'atlas':
LOG.info("Skipping atlas-specific test")
return

jdoe = InternalAccount('jdoe', vo=vo)

nbdatasets = 5
nbfiles = 5

rse = 'LOCALGROUPDISK_%s' % rse_name_generator()
rse_id = add_rse(rse, vo=vo)

set_local_account_limit(jdoe, rse_id, -1)
set_local_account_limit(jdoe_account, rse_id, -1)

dsns2 = [{'name': did_name_generator('dataset'),
'scope': mock_scope,
'type': 'DATASET',
'lifetime': -1,
'rules': [{'account': jdoe, 'copies': 1,
'rules': [{'account': jdoe_account, 'copies': 1,
'rse_expression': rse,
'grouping': 'DATASET'}]} for _ in range(nbdatasets)]

Expand Down

0 comments on commit d8f3c68

Please sign in to comment.