20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/inferno/apps/web/controllers/test_runs/create.rb', line 20
def handle(req, res)
test_session = test_sessions_repo.find(req.params[:test_session_id])
if test_runs_repo.active_test_run_for_session?(test_session.id)
halt 409, { error: 'Cannot run new test while another test run is in progress' }.to_json
end
verify_runnable(
repo.build_entity(create_params(req.params)).runnable,
req.params[:inputs],
test_session.suite_options
)
test_run = repo.create(create_params(req.params).merge(status: 'queued'))
res.body = serialize(test_run, suite_options: test_session.suite_options)
persist_inputs(session_data_repo, req.params, test_run)
Jobs.perform(Jobs::ExecuteTestRun, test_run.id)
rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation,
Inferno::Exceptions::RequiredInputsNotFound,
Inferno::Exceptions::NotUserRunnableException => e
halt 422, { errors: e.message }.to_json
rescue StandardError => e
Application['logger'].error(e.full_message)
halt 500, { errors: e.message }.to_json
end
|