Skip to content

Commit

Permalink
Add integration test to test the new analysis handling during the sto…
Browse files Browse the repository at this point in the history
…rage migration
  • Loading branch information
davidfarkas committed Mar 2, 2018
1 parent a56f116 commit f1e1e0f
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions tests/integration_tests/python/test_migrate_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,85 @@ def mocked(*args, **kwargs):
assert config.fs.exists(util.path_from_uuid(file_2_id))

assert any(log.message == 'Probably the following file has been updated during the migration and its hash is changed, cleaning up from the new filesystem' for log in caplog.records)


def test_migrate_analysis(files_to_migrate, as_admin, migrate_storage, default_payload, data_builder, file_form):
"""Testing analysis migration"""

# get file storing by hash in legacy storage
(project_id, file_name_1, url_1, file_path_1) = files_to_migrate[0]
# get ile storing by uuid in legacy storage
(_, _,url_2, file_path_2) = files_to_migrate[1]

gear_doc = default_payload['gear']['gear']
gear_doc['inputs'] = {
'csv': {
'base': 'file'
}
}
gear = data_builder.create_gear(gear=gear_doc)

# create project analysis (job) using project's file as input
r = as_admin.post('/projects/' + project_id + '/analyses', params={'job': 'true'}, json={
'analysis': {'label': 'test analysis job'},
'job': {
'gear_id': gear,
'inputs': {
'csv': {
'type': 'projects',
'id': project_id,
'name': file_name_1
}
},
'tags': ['example']
}
})
assert r.ok
analysis_id1 = r.json()['_id']

r = as_admin.get('/projects/' + project_id + '/analyses/' + analysis_id1)
assert r.ok
analysis_files1 = '/projects/' + project_id + '/analyses/' + analysis_id1 + '/files'

# run the migration
migrate_storage.migrate_containers()

# delete files from the legacy storage
config.legacy_fs.remove(file_path_1)
config.legacy_fs.remove(file_path_2)

# get the files from the new filesystem
# get the ticket
r = as_admin.get(url_1, params={'ticket': ''})
assert r.ok
ticket = r.json()['ticket']

# download the file
assert as_admin.get(url_1, params={'ticket': ticket}).ok

# get the ticket
r = as_admin.get(url_2, params={'ticket': ''})
assert r.ok
ticket = r.json()['ticket']

# download the file
assert as_admin.get(url_2, params={'ticket': ticket}).ok

# get analysis download ticket for single file
r = as_admin.get(analysis_files1 + '/' + file_name_1, params={'ticket': ''})
assert r.ok
ticket = r.json()['ticket']

# download single analysis file w/ ticket
r = as_admin.get(analysis_files1 + '/' + file_name_1, params={'ticket': ticket})
assert r.ok

r = as_admin.get('/projects/' + project_id + '/analyses/' + analysis_id1)
assert r.ok
input_file_id = r.json()['files'][0]['_id']

r = as_admin.get('/projects/' + project_id)
assert r.ok
project_file_id = r.json()['files'][0]['_id']

assert input_file_id == project_file_id

0 comments on commit f1e1e0f

Please sign in to comment.