Commit d27720f9 authored by Andrea Manzi's avatar Andrea Manzi
Browse files

Merge branch 'FTS-1324' into 'develop'

Resolve FTS-1324

Closes FTS-1324

See merge request !18
parents 7e3301f9 f3aa3ef6
Pipeline #615788 passed with stage
in 1 minute and 33 seconds
......@@ -282,9 +282,8 @@ class BanningController(BaseController):
if not storage:
raise HTTPBadRequest('Missing storage parameter')
vo_name = input_dict.get('vo_name', '*')
if vo_name is None or vo_name == '':
raise HTTPBadRequest('vo_name can not be null')
user = request.environ['fts3.User.Credentials']
vo_name = user.vos[0]
allow_submit = bool(input_dict.get('allow_submit', False))
status = input_dict.get('status', 'cancel').upper()
......@@ -355,8 +354,10 @@ class BanningController(BaseController):
raise HTTPBadRequest('Missing storage parameter')
job_ids = []
try:
Session.query(BannedSE).filter(BannedSE.se==storage).delete()
job_ids= _reenter_queue(storage, '*')
user = request.environ['fts3.User.Credentials']
vo_name = user.vos[0]
Session.query(BannedSE).filter(BannedSE.se==storage,BannedSE.vo==vo_name).delete()
job_ids= _reenter_queue(storage, vo_name)
Session.commit()
except Exception:
Session.rollback()
......
......@@ -100,13 +100,13 @@ class TestBanning(TestController):
"""
jobs = list()
jobs.append(
insert_job('dteam', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED', user_dn='/DC=cern/CN=someone')
insert_job('testvo', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED', user_dn='/DC=cern/CN=someone')
)
jobs.append(
insert_job('dteam', 'gsiftp://source', 'gsiftp://destination2', 'ACTIVE', user_dn='/DC=cern/CN=someone')
insert_job('testvo', 'gsiftp://source', 'gsiftp://destination2', 'ACTIVE', user_dn='/DC=cern/CN=someone')
)
jobs.append(
insert_job('dteam', 'gsiftp://source', 'gsiftp://destination2', 'FAILED', duration=10, queued=20,
insert_job('testvo', 'gsiftp://source', 'gsiftp://destination2', 'FAILED', duration=10, queued=20,
user_dn='/DC=cern/CN=someone')
)
......@@ -148,16 +148,13 @@ class TestBanning(TestController):
status=200
).json
self.assertEqual(0, len(canceled))
banned = Session.query(BannedSE).get(('gsiftp://nowhere', '*'))
banned = Session.query(BannedSE).filter(BannedSE.se=='gsiftp://nowhere').first()
self.assertNotEqual(None, banned)
self.assertEqual(self.get_user_credentials().user_dn, banned.admin_dn)
self.assertEqual('CANCEL', banned.status)
self.assertEqual('*', banned.vo)
self.assertEqual('TEST BAN 42', banned.message)
self.app.delete(url="/ban/se?storage=%s" % urllib.quote('gsiftp://nowhere'), status=204)
banned = Session.query(BannedSE).get(('gsiftp://nowhere', '*'))
banned = Session.query(BannedSE).filter(BannedSE.se=='gsiftp://nowhere').first()
self.assertEqual(None, banned)
def test_list_banned_ses(self):
......@@ -185,19 +182,19 @@ class TestBanning(TestController):
"""
canceled = self.app.post(
url="/ban/se",
params={'storage': 'gsiftp://nowhere', 'vo_name': 'dteam'},
params={'storage': 'gsiftp://nowhere', 'vo_name': 'testvo'},
status=200
).json
self.assertEqual(0, len(canceled))
banned = Session.query(BannedSE).get(('gsiftp://nowhere', 'dteam'))
banned = Session.query(BannedSE).get(('gsiftp://nowhere', 'testvo'))
self.assertNotEqual(None, banned)
self.assertEqual(self.get_user_credentials().user_dn, banned.admin_dn)
self.assertEqual('CANCEL', banned.status)
self.assertEqual('dteam', banned.vo)
self.assertEqual('testvo', banned.vo)
self.app.delete(url="/ban/se?storage=%s&vo_name=dteam" % urllib.quote('gsiftp://nowhere'), status=204)
banned = Session.query(BannedSE).get(('gsiftp://nowhere', 'dteam'))
self.app.delete(url="/ban/se?storage=%s&vo_name=testvo" % urllib.quote('gsiftp://nowhere'), status=204)
banned = Session.query(BannedSE).get(('gsiftp://nowhere', 'someone'))
self.assertEqual(None, banned)
def test_ban_se_cancel(self):
......@@ -205,9 +202,9 @@ class TestBanning(TestController):
Ban a SE that has files queued, make sure they are canceled
"""
jobs = list()
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination2', 'ACTIVE'))
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination2', 'FAILED', duration=10, queued=20))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination2', 'ACTIVE'))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination2', 'FAILED', duration=10, queued=20))
canceled_ids = self.app.post(
url="/ban/se",
......@@ -241,7 +238,7 @@ class TestBanning(TestController):
Ban a SE that has files queued. If a job has other pairs, the job must remain!
"""
job_id = insert_job(
'dteam',
'testvo',
multiple=[('gsiftp://source', 'gsiftp://destination'), ('gsiftp://other', 'gsiftp://destination')]
)
canceled_ids = self.app.post(
......@@ -270,13 +267,13 @@ class TestBanning(TestController):
Cancel a SE that has files queued, make sure they are canceled (with VO)
"""
jobs = list()
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('atlas', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('atlas', 'gsiftp://source', 'gsiftp://destination2', 'SUBMITTED'))
canceled_ids = self.app.post(
url="/ban/se",
params={'storage': 'gsiftp://source', 'status': 'cancel', 'vo_name': 'dteam'},
params={'storage': 'gsiftp://source', 'status': 'cancel', 'vo_name': 'testvo'},
status=200
).json
......@@ -302,9 +299,9 @@ class TestBanning(TestController):
Ban a SE, but instead of canceling, give jobs some time to finish
"""
jobs = list()
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination2', 'ACTIVE'))
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination2', 'FAILED', duration=10, queued=20))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination2', 'ACTIVE'))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination2', 'FAILED', duration=10, queued=20))
waiting_ids = self.app.post(
url="/ban/se",
......@@ -332,7 +329,7 @@ class TestBanning(TestController):
for f in files:
self.assertEqual('FAILED', f.file_state)
banned = Session.query(BannedSE).get(('gsiftp://source', '*'))
banned = Session.query(BannedSE).get(('gsiftp://source', 'testvo'))
self.assertEqual('WAIT', banned.status)
def test_ban_se_wait_vo(self):
......@@ -340,13 +337,13 @@ class TestBanning(TestController):
Ban a SE, but instead of canceling, give jobs some time to finish (with VO)
"""
jobs = list()
jobs.append(insert_job('dteam', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('testvo', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('atlas', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED'))
jobs.append(insert_job('atlas', 'gsiftp://source', 'gsiftp://destination2', 'SUBMITTED'))
waiting_ids = self.app.post(
url="/ban/se",
params={'storage': 'gsiftp://source', 'status': 'wait', 'vo_name': 'dteam', 'timeout': 33},
params={'storage': 'gsiftp://source', 'status': 'wait', 'vo_name': 'testvo', 'timeout': 33},
status=200
).json
......@@ -440,7 +437,7 @@ class TestBanning(TestController):
Regression for FTS-297
When unbanning a storage, if any file was left on wait, they must re-enter the queue
"""
job_id = insert_job('dteam', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED', user_dn='/DC=cern/CN=someone')
job_id = insert_job('testvo', 'gsiftp://source', 'gsiftp://destination', 'SUBMITTED', user_dn='/DC=cern/CN=someone')
self.app.post(
url="/ban/se", params={'storage': 'gsiftp://source', 'status': 'wait', 'allow_submit': True},
status=200
......@@ -506,7 +503,7 @@ class TestBanning(TestController):
"""
self.push_delegation()
pre_job_id = insert_job('dteam', 'srm://source', 'srm://destination', 'STAGING', user_dn='/DC=cern/CN=someone')
pre_job_id = insert_job('testvo', 'srm://source', 'srm://destination', 'STAGING', user_dn='/DC=cern/CN=someone')
self.app.post(
url="/ban/se", params={'storage': 'srm://source', 'status': 'wait', 'allow_submit': True},
status=200
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment