Commit 67a6119c authored by Alejandro Alvarez Ayllon's avatar Alejandro Alvarez Ayllon
Browse files

FTS-875: Fix session reuse misfires

It might actually concern FTS-873 too, since hashed ids
were not shared when session reuse was automatically enabled.
parent 03369fc8
Pipeline #79809 passed with stage
in 19 seconds
......@@ -455,7 +455,6 @@ class JobBuilder(object):
for file_dict in files_list:
self._populate_files(file_dict, f_index, shared_hashed_id)
f_index += 1
if len(self.files) == 0:
raise HTTPBadRequest('No valid pairs available')
......@@ -503,9 +502,13 @@ class JobBuilder(object):
log.debug(str(file['user_filesize']))
if file['user_filesize'] < 104857600:
small_files +=1
if small_files >= min_small_files:
if small_files > min_small_files:
self.job['job_type'] = 'Y'
log.debug("Reuse jobs with "+str(small_files)+" small files up to "+str(len(self.files))+" total files")
# Need to reset their hashed_id so they land on the same machine
shared_hashed_id = _generate_hashed_id()
for file in self.files:
file['hashed_id'] = shared_hashed_id
if self.job['job_type'] is None:
self.job['job_type'] = 'N'
......
......@@ -385,6 +385,83 @@ class TestMultiple(TestController):
for f in files:
self.assertEqual(hashed, f.hashed_id)
def test_submit_reuse_auto_small(self):
"""
Submit small files with reuse not set (auto). It should be enabled.
"""
self.setup_gridsite_environment()
self.push_delegation()
job = {
'files': [
{
'sources': ['http://source.es:8446/file'],
'destinations': ['http://dest.ch:8447/file'],
'filesize': 1024,
},
{
'sources': ['http://source.es:8446/otherfile'],
'destinations': ['http://dest.ch:8447/otherfile'],
'filesize': 1024,
}
],
'params': {'overwrite': True, 'reuse': None}
}
job_id = self.app.post(
url="/jobs",
content_type='application/json',
params=json.dumps(job),
status=200
).json['job_id']
job = Session.query(Job).get(job_id)
self.assertEqual(job.job_type, 'Y')
files = Session.query(File).filter(File.job_id == job_id)
hashed = files[0].hashed_id
for f in files:
self.assertEqual(1024, f.user_filesize)
self.assertEqual(hashed, f.hashed_id)
def test_submit_reuse_auto_big(self):
"""
Submit big files with reuse not set (auto). It should be disabled.
"""
self.setup_gridsite_environment()
self.push_delegation()
job = {
'files': [
{
'sources': ['http://source.es:8446/file'],
'destinations': ['http://dest.ch:8447/file'],
'filesize': 2**30,
},
{
'sources': ['http://source.es:8446/otherfile'],
'destinations': ['http://dest.ch:8447/otherfile'],
'filesize': 2**30,
}
],
'params': {'overwrite': True, 'reuse': None}
}
job_id = self.app.post(
url="/jobs",
content_type='application/json',
params=json.dumps(job),
status=200
).json['job_id']
job = Session.query(Job).get(job_id)
self.assertEqual(job.job_type, 'N')
files = Session.query(File).filter(File.job_id == job_id)
hashed = files[0].hashed_id
for f in files:
self.assertEqual(2**30, f.user_filesize)
def test_multihop(self):
"""
Submit a multihop transfer
......
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