inferno_core 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/inferno +7 -0
- data/lib/inferno/apps/cli/console.rb +12 -0
- data/lib/inferno/apps/cli/main.rb +18 -0
- data/lib/inferno/apps/cli/migration.rb +14 -0
- data/lib/inferno/apps/cli.rb +8 -0
- data/lib/inferno/apps/web/controllers/test_runs/create.rb +30 -10
- data/lib/inferno/apps/web/controllers/test_runs/show.rb +10 -0
- data/lib/inferno/apps/web/controllers/test_sessions/create.rb +1 -0
- data/lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb +22 -0
- data/lib/inferno/apps/web/controllers/test_sessions/results/index.rb +6 -1
- data/lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb +21 -0
- data/lib/inferno/apps/web/router.rb +15 -0
- data/lib/inferno/apps/web/serializers/hash_value_extractor.rb +11 -0
- data/lib/inferno/apps/web/serializers/request.rb +1 -0
- data/lib/inferno/apps/web/serializers/result.rb +8 -0
- data/lib/inferno/apps/web/serializers/session_data.rb +10 -0
- data/lib/inferno/apps/web/serializers/test.rb +3 -6
- data/lib/inferno/apps/web/serializers/test_group.rb +5 -8
- data/lib/inferno/apps/web/serializers/test_run.rb +1 -0
- data/lib/inferno/apps/web/serializers/test_session.rb +1 -1
- data/lib/inferno/apps/web/serializers/test_suite.rb +1 -0
- data/lib/inferno/config/application.rb +8 -2
- data/lib/inferno/config/boot/db.rb +3 -2
- data/lib/inferno/config/boot/logging.rb +2 -0
- data/lib/inferno/config/boot/sidekiq.rb +11 -0
- data/lib/inferno/config/boot/suites.rb +4 -6
- data/lib/inferno/config/boot.rb +2 -0
- data/lib/inferno/db/migrations/001_create_initial_structure.rb +0 -21
- data/lib/inferno/db/migrations/002_add_wait_support.rb +7 -0
- data/lib/inferno/db/migrations/003_update_session_data.rb +18 -0
- data/lib/inferno/db/migrations/004_add_request_results_table.rb +9 -0
- data/lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb +5 -0
- data/lib/inferno/db/schema.rb +154 -0
- data/lib/inferno/dsl/assertions.rb +85 -0
- data/lib/inferno/dsl/configurable.rb +126 -0
- data/lib/inferno/dsl/fhir_client.rb +8 -6
- data/lib/inferno/dsl/fhir_client_builder.rb +19 -3
- data/lib/inferno/dsl/fhir_validation.rb +1 -1
- data/lib/inferno/dsl/http_client.rb +14 -12
- data/lib/inferno/dsl/http_client_builder.rb +3 -3
- data/lib/inferno/dsl/request_storage.rb +34 -13
- data/lib/inferno/dsl/results.rb +49 -0
- data/lib/inferno/dsl/resume_test_route.rb +89 -0
- data/lib/inferno/dsl/runnable.rb +183 -28
- data/lib/inferno/dsl.rb +1 -3
- data/lib/inferno/entities/header.rb +14 -7
- data/lib/inferno/entities/message.rb +16 -6
- data/lib/inferno/entities/request.rb +59 -20
- data/lib/inferno/entities/result.rb +45 -22
- data/lib/inferno/entities/session_data.rb +39 -0
- data/lib/inferno/entities/test.rb +48 -8
- data/lib/inferno/entities/test_group.rb +8 -0
- data/lib/inferno/entities/test_run.rb +36 -6
- data/lib/inferno/entities/test_session.rb +17 -11
- data/lib/inferno/entities.rb +1 -1
- data/lib/inferno/exceptions.rb +24 -0
- data/lib/inferno/jobs/execute_test_run.rb +14 -0
- data/lib/inferno/jobs/resume_test_run.rb +14 -0
- data/lib/inferno/jobs.rb +16 -0
- data/lib/inferno/public/bundle.js +1 -1
- data/lib/inferno/repositories/in_memory_repository.rb +1 -1
- data/lib/inferno/repositories/repository.rb +13 -0
- data/lib/inferno/repositories/requests.rb +5 -4
- data/lib/inferno/repositories/results.rb +151 -3
- data/lib/inferno/repositories/session_data.rb +47 -0
- data/lib/inferno/repositories/test_runs.rb +81 -0
- data/lib/inferno/spec_support.rb +1 -1
- data/lib/inferno/test_runner.rb +126 -32
- data/lib/inferno/utils/markdown_formatter.rb +15 -0
- data/lib/inferno/utils/middleware/request_logger.rb +17 -4
- data/lib/inferno/utils/migration.rb +17 -0
- data/lib/inferno/version.rb +1 -1
- data/lib/inferno.rb +4 -4
- data/spec/factories/request.rb +14 -7
- data/spec/factories/result.rb +8 -0
- data/spec/factories/test_run.rb +2 -0
- metadata +84 -7
- data/bin/inferno-console +0 -8
- data/lib/inferno/dsl/fhir_manipulation.rb +0 -25
- data/lib/inferno/entities/test_input.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c8b0374d22ea35f07944360943d2a1240f8ef7365b97d625b32facde4a2eaa
|
4
|
+
data.tar.gz: '0258752a8738b7e9c1da7d9112d0ee4f15bac0a8c7b2acac5f9973bb35d8146c'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76cd8133722b109ed66f9b79eea46279c177fdac68cfe9abea4d0e9caaa76b861e533909923a94121d17e15483be5254f8e36e67cf6abb6121bc12f1e37f5fd7
|
7
|
+
data.tar.gz: 9be9f363e78e653b33818a8e8eee7fc74474ec2ca019b715054b7926d7e5675c46b290e138c0ee020e586d91eecef2759ead3272b6087461af89afeb8fdd7e94
|
data/bin/inferno
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'console'
|
2
|
+
require_relative 'migration'
|
3
|
+
|
4
|
+
module Inferno
|
5
|
+
module CLI
|
6
|
+
class Main < Thor
|
7
|
+
desc 'console', 'Start an interactive console session with Inferno'
|
8
|
+
def console
|
9
|
+
Console.new.run
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'migrate', 'Run database migrations'
|
13
|
+
def migrate
|
14
|
+
Migration.new.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -3,28 +3,48 @@ module Inferno
|
|
3
3
|
module Controllers
|
4
4
|
module TestRuns
|
5
5
|
class Create < Controller
|
6
|
-
include Import[
|
6
|
+
include Import[
|
7
|
+
test_sessions_repo: 'repositories.test_sessions',
|
8
|
+
session_data_repo: 'repositories.session_data',
|
9
|
+
test_runs_repo: 'repositories.test_runs'
|
10
|
+
]
|
7
11
|
|
8
12
|
PARAMS = [:test_session_id, :test_suite_id, :test_group_id, :test_id].freeze
|
9
13
|
|
10
14
|
def call(params)
|
11
|
-
|
12
|
-
inputs = (params[:inputs] || {}).each_with_object({}) do |input, new_inputs|
|
13
|
-
new_inputs[input[:name].to_sym] = input[:value]
|
14
|
-
end
|
15
|
+
test_session = test_sessions_repo.find(params[:test_session_id])
|
15
16
|
|
16
|
-
test_session = test_sessions_repo.find(test_run.test_session_id)
|
17
17
|
# if testsession.nil?
|
18
|
+
if test_runs_repo.active_test_run_for_session?(test_session.id)
|
19
|
+
self.status = 409
|
20
|
+
self.body = { error: 'Cannot run new test while another test run is in progress' }.to_json
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
test_run = repo.create(create_params(params).merge(status: 'queued'))
|
25
|
+
missing_inputs = test_run.runnable.missing_inputs(params[:inputs])
|
18
26
|
|
19
|
-
|
20
|
-
|
21
|
-
.run(test_run.runnable, inputs)
|
27
|
+
raise Inferno::Exceptions::RequiredInputsNotFound, missing_inputs if missing_inputs.any?
|
28
|
+
raise Inferno::Exceptions::NotUserRunnableException unless test_run.runnable.user_runnable?
|
22
29
|
|
23
30
|
self.body = serialize(test_run)
|
24
|
-
|
31
|
+
|
32
|
+
params[:inputs]&.each do |input|
|
33
|
+
session_data_repo.save(
|
34
|
+
test_session_id: test_session.id,
|
35
|
+
name: input[:name],
|
36
|
+
value: input[:value]
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
Jobs.perform(Jobs::ExecuteTestRun, test_run.id)
|
41
|
+
rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation,
|
42
|
+
Inferno::Exceptions::RequiredInputsNotFound,
|
43
|
+
Inferno::Exceptions::NotUserRunnableException => e
|
25
44
|
self.body = { errors: e.message }.to_json
|
26
45
|
self.status = 422
|
27
46
|
rescue StandardError => e
|
47
|
+
Application['logger'].error(e.full_message)
|
28
48
|
self.body = { errors: e.message }.to_json
|
29
49
|
self.status = 500
|
30
50
|
end
|
@@ -7,6 +7,16 @@ module Inferno
|
|
7
7
|
test_run = repo.find(params[:id])
|
8
8
|
halt 404 if test_run.nil?
|
9
9
|
|
10
|
+
if params[:include_results] == 'true'
|
11
|
+
results_repo = Inferno::Repositories::Results.new
|
12
|
+
test_run.results =
|
13
|
+
if params[:after].present?
|
14
|
+
results_repo.test_run_results_after(test_run_id: test_run.id, after: Time.parse(params[:after]))
|
15
|
+
else
|
16
|
+
repo.results_for_test_run(test_run.id)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
10
20
|
self.body = serialize(test_run)
|
11
21
|
end
|
12
22
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Inferno
|
2
|
+
module Web
|
3
|
+
module Controllers
|
4
|
+
module TestSessions
|
5
|
+
class LastTestRun < Controller
|
6
|
+
include Import[test_runs_repo: 'repositories.test_runs']
|
7
|
+
|
8
|
+
def call(params)
|
9
|
+
test_run = test_runs_repo.last_test_run(params[:test_session_id])
|
10
|
+
|
11
|
+
self.body =
|
12
|
+
if test_run.nil?
|
13
|
+
nil
|
14
|
+
else
|
15
|
+
Inferno::Web::Serializers::TestRun.render(test_run)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -7,7 +7,12 @@ module Inferno
|
|
7
7
|
include Import[test_sessions_repo: 'repositories.test_sessions']
|
8
8
|
|
9
9
|
def call(params)
|
10
|
-
self.body =
|
10
|
+
self.body =
|
11
|
+
if params[:all] == 'true'
|
12
|
+
serialize(test_sessions_repo.results_for_test_session(params[:test_session_id]))
|
13
|
+
else
|
14
|
+
serialize(repo.current_results_for_test_session(params[:test_session_id]))
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Inferno
|
2
|
+
module Web
|
3
|
+
module Controllers
|
4
|
+
module TestSessions
|
5
|
+
module SessionData
|
6
|
+
class Index < Controller
|
7
|
+
include Import[session_data_repo: 'repositories.session_data']
|
8
|
+
|
9
|
+
def self.resource_class
|
10
|
+
'SessionData'
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(params)
|
14
|
+
self.body = serialize(session_data_repo.get_all_from_session(params[:test_session_id]))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -13,7 +13,11 @@ module Inferno
|
|
13
13
|
|
14
14
|
resources 'test_sessions', only: [:create, :show] do
|
15
15
|
resources 'results', only: [:index]
|
16
|
+
resources 'session_data', only: [:index]
|
16
17
|
end
|
18
|
+
get 'test_sessions/:test_session_id/last_test_run',
|
19
|
+
to: Inferno::Web::Controllers::TestSessions::LastTestRun,
|
20
|
+
as: :last_test_run
|
17
21
|
|
18
22
|
resources 'test_suites', only: [:index, :show]
|
19
23
|
|
@@ -22,6 +26,17 @@ module Inferno
|
|
22
26
|
|
23
27
|
get '/', to: ->(_env) { [200, {}, [client_page]] }
|
24
28
|
get '/test_sessions/:id', to: ->(_env) { [200, {}, [client_page]] }
|
29
|
+
|
30
|
+
Inferno.routes.each do |route|
|
31
|
+
cleaned_id = route[:suite].id.gsub(/[^a-zA-Z\d\-._~]/, '_')
|
32
|
+
path = "/custom/#{cleaned_id}#{route[:path]}"
|
33
|
+
Application['logger'].info("Registering custom route: #{path}")
|
34
|
+
if route[:method] == :all
|
35
|
+
mount route[:handler], at: path
|
36
|
+
else
|
37
|
+
send(route[:method], path, to: route[:handler])
|
38
|
+
end
|
39
|
+
end
|
25
40
|
end
|
26
41
|
end
|
27
42
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Inferno
|
2
4
|
module Web
|
3
5
|
module Serializers
|
@@ -12,6 +14,12 @@ module Inferno
|
|
12
14
|
field :test_session_id
|
13
15
|
field :result
|
14
16
|
field :result_message, if: :field_present?
|
17
|
+
field :created_at
|
18
|
+
field :updated_at
|
19
|
+
|
20
|
+
field :outputs do |result, _options|
|
21
|
+
result.output_json.present? ? JSON.parse(result.output_json) : []
|
22
|
+
end
|
15
23
|
|
16
24
|
association :messages, blueprint: Message, if: :field_present?
|
17
25
|
association :requests, blueprint: Request, view: :summary, if: :field_present?
|
@@ -4,13 +4,10 @@ module Inferno
|
|
4
4
|
class Test < Serializer
|
5
5
|
identifier :id
|
6
6
|
field :title
|
7
|
-
field :inputs
|
8
|
-
|
9
|
-
end
|
10
|
-
field :outputs do |test, _options|
|
11
|
-
test.outputs.map { |output| { name: output } }
|
12
|
-
end
|
7
|
+
field :input_definitions, name: :inputs, extractor: HashValueExtractor, blueprint: Input
|
8
|
+
field :output_definitions, name: :outputs, extractor: HashValueExtractor
|
13
9
|
field :description
|
10
|
+
field :user_runnable?, name: :user_runnable
|
14
11
|
end
|
15
12
|
end
|
16
13
|
end
|
@@ -4,19 +4,16 @@ module Inferno
|
|
4
4
|
class TestGroup < Serializer
|
5
5
|
identifier :id
|
6
6
|
|
7
|
-
# TODO: fill out test group
|
8
7
|
field :title
|
9
8
|
field :description
|
10
|
-
|
9
|
+
field :test_count
|
10
|
+
field :run_as_group?, name: :run_as_group
|
11
|
+
field :user_runnable?, name: :user_runnable
|
11
12
|
|
12
13
|
association :groups, name: :test_groups, blueprint: TestGroup
|
13
14
|
association :tests, blueprint: Test
|
14
|
-
field :inputs
|
15
|
-
|
16
|
-
end
|
17
|
-
field :outputs do |group, _options|
|
18
|
-
group.outputs.map { |input| { name: input } }
|
19
|
-
end
|
15
|
+
field :input_definitions, name: :inputs, extractor: HashValueExtractor, blueprint: Input
|
16
|
+
field :output_definitions, name: :outputs, extractor: HashValueExtractor
|
20
17
|
end
|
21
18
|
end
|
22
19
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'dotenv'
|
3
|
+
require 'dry/system/container'
|
4
|
+
require 'sequel'
|
1
5
|
require_relative 'boot'
|
2
6
|
|
3
7
|
module Inferno
|
@@ -6,6 +10,10 @@ module Inferno
|
|
6
10
|
|
7
11
|
use :env, inferrer: -> { ENV.fetch('APP_ENV', :development).to_sym }
|
8
12
|
|
13
|
+
Application.register('js_host', ENV.fetch('JS_HOST', ''))
|
14
|
+
Application.register('async_jobs', ENV['ASYNC_JOBS'] != 'false')
|
15
|
+
Application.register('inferno_host', ENV.fetch('INFERNO_HOST', 'http://localhost:4567'))
|
16
|
+
|
9
17
|
configure do |config|
|
10
18
|
config.root = File.expand_path('../../..', __dir__)
|
11
19
|
config.default_namespace = 'inferno'
|
@@ -15,8 +23,6 @@ module Inferno
|
|
15
23
|
config.auto_register = 'lib'
|
16
24
|
end
|
17
25
|
|
18
|
-
Application.register('js_host', ENV.fetch('JS_HOST', ''))
|
19
|
-
|
20
26
|
load_paths!('lib')
|
21
27
|
end
|
22
28
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'sequel'
|
2
|
+
|
1
3
|
Inferno::Application.boot(:db) do
|
2
4
|
init do
|
3
5
|
use :logging
|
@@ -10,6 +12,7 @@ Inferno::Application.boot(:db) do
|
|
10
12
|
config = YAML.load_file(config_path)[ENV['APP_ENV']]
|
11
13
|
.merge(logger: Inferno::Application['logger'])
|
12
14
|
connection = Sequel.connect(config)
|
15
|
+
connection.sql_log_level = :debug
|
13
16
|
|
14
17
|
register('db.config', config)
|
15
18
|
register('db.connection', connection)
|
@@ -17,7 +20,5 @@ Inferno::Application.boot(:db) do
|
|
17
20
|
|
18
21
|
start do
|
19
22
|
Sequel.extension :migration
|
20
|
-
migration_path = File.join(Inferno::Application.root, 'lib', 'inferno', 'db', 'migrations')
|
21
|
-
Sequel::Migrator.run(Inferno::Application['db.connection'], migration_path)
|
22
23
|
end
|
23
24
|
end
|
@@ -4,12 +4,10 @@ Inferno::Application.boot(:suites) do
|
|
4
4
|
|
5
5
|
files_to_load = Dir.glob(File.join(Dir.pwd, 'lib', '*.rb'))
|
6
6
|
|
7
|
-
if ENV['LOAD_DEV_SUITES']
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
if ENV['LOAD_UI_SUITES'] == 'true'
|
12
|
-
files_to_load.concat Dir.glob(File.join(Inferno::Application.root, 'ui_suites', '**', '*.rb'))
|
7
|
+
if ENV['LOAD_DEV_SUITES'].present?
|
8
|
+
ENV['LOAD_DEV_SUITES'].split(',').map(&:strip).reject(&:empty?).each do |suite|
|
9
|
+
files_to_load.concat Dir.glob(File.join(Inferno::Application.root, 'dev_suites', suite, '**', '*.rb'))
|
10
|
+
end
|
13
11
|
end
|
14
12
|
|
15
13
|
if ENV['APP_ENV'] == 'test'
|
data/lib/inferno/config/boot.rb
CHANGED
@@ -1,26 +1,5 @@
|
|
1
1
|
Sequel.migration do
|
2
2
|
change do
|
3
|
-
#
|
4
|
-
# NOT NEEDED BECUASE THEY ARE DEFINED WITHIN TEST SUITE.
|
5
|
-
# MUST BE REFERENCED USING SOME KIND OF GLOBALLY UNIQUE KEY
|
6
|
-
# THAT IS REPRESENTED AS A STRING
|
7
|
-
#
|
8
|
-
|
9
|
-
# create_table :test_suites do
|
10
|
-
# end
|
11
|
-
|
12
|
-
# create_table :test_groups do
|
13
|
-
# end
|
14
|
-
|
15
|
-
# create_table :tests do
|
16
|
-
# end
|
17
|
-
|
18
|
-
# create_table :test_inputs do
|
19
|
-
# end
|
20
|
-
|
21
|
-
# create_table :test_outputs do
|
22
|
-
# end
|
23
|
-
|
24
3
|
# A way for the test to signal that it requires some kind of action by the
|
25
4
|
# app that is invoking the test (e.g. SMART Launch, perhaps mid-test manual verification)
|
26
5
|
# create_table :test_prompts do
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
drop_table :test_run_inputs
|
4
|
+
drop_table :result_inputs
|
5
|
+
|
6
|
+
set_column_type :session_data, :value, String, text: true
|
7
|
+
drop_index :session_data, [:test_session_id, :name], concurrently: true
|
8
|
+
add_index :session_data, [:test_session_id, :name], unique: true, concurrently: true
|
9
|
+
drop_index :session_data, :id, concurrently: true
|
10
|
+
add_index :session_data, :id, unique: true, concurrently: true
|
11
|
+
|
12
|
+
add_column :results, :input_json, String, text: true
|
13
|
+
add_column :results, :output_json, String, text: true
|
14
|
+
add_index :results, [:test_session_id, :test_id], concurrently: true
|
15
|
+
add_index :results, [:test_session_id, :test_group_id], concurrently: true
|
16
|
+
add_index :results, [:test_session_id, :test_suite_id], concurrently: true
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Sequel.migration do
|
2
|
+
change do
|
3
|
+
create_table :requests_results do
|
4
|
+
# using results_id instead of result_id to avoid ambiguous column error
|
5
|
+
foreign_key :results_id, :results, index: true, type: String, null: false
|
6
|
+
foreign_key :requests_id, :requests, index: true, type: String, null: false
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|