inferno_core 0.0.2 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/lib/inferno/apps/web/controllers/test_runs/create.rb +30 -10
  3. data/lib/inferno/apps/web/controllers/test_runs/show.rb +10 -0
  4. data/lib/inferno/apps/web/controllers/test_sessions/create.rb +1 -0
  5. data/lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb +22 -0
  6. data/lib/inferno/apps/web/controllers/test_sessions/results/index.rb +6 -1
  7. data/lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb +21 -0
  8. data/lib/inferno/apps/web/router.rb +15 -0
  9. data/lib/inferno/apps/web/serializers/hash_value_extractor.rb +11 -0
  10. data/lib/inferno/apps/web/serializers/request.rb +1 -0
  11. data/lib/inferno/apps/web/serializers/result.rb +8 -0
  12. data/lib/inferno/apps/web/serializers/session_data.rb +10 -0
  13. data/lib/inferno/apps/web/serializers/test.rb +3 -6
  14. data/lib/inferno/apps/web/serializers/test_group.rb +5 -8
  15. data/lib/inferno/apps/web/serializers/test_run.rb +1 -0
  16. data/lib/inferno/apps/web/serializers/test_session.rb +1 -1
  17. data/lib/inferno/apps/web/serializers/test_suite.rb +1 -0
  18. data/lib/inferno/config/application.rb +5 -2
  19. data/lib/inferno/config/boot/db.rb +10 -1
  20. data/lib/inferno/config/boot/sidekiq.rb +11 -0
  21. data/lib/inferno/config/boot/suites.rb +4 -6
  22. data/lib/inferno/config/boot.rb +2 -0
  23. data/lib/inferno/db/migrations/001_create_initial_structure.rb +0 -21
  24. data/lib/inferno/db/migrations/002_add_wait_support.rb +7 -0
  25. data/lib/inferno/db/migrations/003_update_session_data.rb +18 -0
  26. data/lib/inferno/db/migrations/004_add_request_results_table.rb +9 -0
  27. data/lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb +5 -0
  28. data/lib/inferno/db/schema.rb +154 -0
  29. data/lib/inferno/dsl/assertions.rb +20 -0
  30. data/lib/inferno/dsl/configurable.rb +126 -0
  31. data/lib/inferno/dsl/fhir_client.rb +4 -2
  32. data/lib/inferno/dsl/fhir_client_builder.rb +16 -0
  33. data/lib/inferno/dsl/http_client.rb +10 -8
  34. data/lib/inferno/dsl/request_storage.rb +30 -9
  35. data/lib/inferno/dsl/results.rb +49 -0
  36. data/lib/inferno/dsl/resume_test_route.rb +89 -0
  37. data/lib/inferno/dsl/runnable.rb +153 -16
  38. data/lib/inferno/dsl.rb +1 -3
  39. data/lib/inferno/entities/header.rb +7 -7
  40. data/lib/inferno/entities/message.rb +8 -6
  41. data/lib/inferno/entities/request.rb +42 -16
  42. data/lib/inferno/entities/result.rb +34 -18
  43. data/lib/inferno/entities/session_data.rb +33 -0
  44. data/lib/inferno/entities/test.rb +35 -8
  45. data/lib/inferno/entities/test_group.rb +8 -0
  46. data/lib/inferno/entities/test_run.rb +13 -6
  47. data/lib/inferno/entities/test_session.rb +8 -8
  48. data/lib/inferno/entities.rb +1 -1
  49. data/lib/inferno/exceptions.rb +24 -0
  50. data/lib/inferno/jobs/execute_test_run.rb +14 -0
  51. data/lib/inferno/jobs/resume_test_run.rb +14 -0
  52. data/lib/inferno/jobs.rb +16 -0
  53. data/lib/inferno/public/bundle.js +1 -1
  54. data/lib/inferno/repositories/repository.rb +13 -0
  55. data/lib/inferno/repositories/requests.rb +5 -4
  56. data/lib/inferno/repositories/results.rb +151 -3
  57. data/lib/inferno/repositories/session_data.rb +47 -0
  58. data/lib/inferno/repositories/test_runs.rb +81 -0
  59. data/lib/inferno/test_runner.rb +125 -31
  60. data/lib/inferno/utils/markdown_formatter.rb +15 -0
  61. data/lib/inferno/utils/middleware/request_logger.rb +16 -3
  62. data/lib/inferno/version.rb +1 -1
  63. data/lib/inferno.rb +4 -0
  64. data/spec/factories/header.rb +19 -0
  65. data/spec/factories/message.rb +17 -0
  66. data/spec/factories/request.rb +42 -0
  67. data/spec/factories/result.rb +45 -0
  68. data/spec/factories/test_run.rb +24 -0
  69. data/spec/factories/test_session.rb +11 -0
  70. data/spec/fixtures/basic_test_group.rb +9 -0
  71. data/spec/fixtures/basic_test_suite.rb +8 -0
  72. metadata +57 -5
  73. data/lib/inferno/dsl/fhir_manipulation.rb +0 -25
  74. data/lib/inferno/entities/test_input.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b74c39894aba367bcde5c790b93628d31232f3a16ebbe8adc2173f766f395320
4
- data.tar.gz: 36eda29d50c81c57fdc71ea723d5551b6f9963924f24a60f47720a4ec7f25689
3
+ metadata.gz: 40769c54fd3854730eb080d1bb9e0755ff1551b00761968155d463dd3a6ce3e0
4
+ data.tar.gz: 8bbf5aaa2b09d7d5ff54e56a3ed33ce4e1f4df29fc53e3737f18e9972dc34f1e
5
5
  SHA512:
6
- metadata.gz: 1f545895e3d03c20f4f8a43911ac8ac2382f1d778506c6b9422150a444aa15382ff0e2ef2ddb6b472bbcef8cf736e9d72face9d22adc7a93c11ed236a92b2d85
7
- data.tar.gz: bfeb371f3e857caf44690605a70dece84f8926b36fd37616f057aea55646374930ce209107592d5d741640ee2ac614992d4a005d4ee35397a4a09d76a5ce4c29
6
+ metadata.gz: 35fe2518d3856f01b3358da68d862318784f05ab067b579d3ac62053dc1deed2be2895e3cfb5ff8efbc97e71d2495a11ebf66eadf23c5b8b4edb502707334838
7
+ data.tar.gz: 04e37af9daf40c01f0d4182f055e4ddf187d72f0e9d8a43e8858af5c549a4a60900d71f034a8e027e20f53a56f6b5e835bce1fca3a0b98870b07e0681793a2d9
@@ -3,28 +3,48 @@ module Inferno
3
3
  module Controllers
4
4
  module TestRuns
5
5
  class Create < Controller
6
- include Import[test_sessions_repo: 'repositories.test_sessions']
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
- test_run = repo.create(create_params(params))
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
- TestRunner
20
- .new(test_session: test_session, test_run: test_run)
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
- rescue Sequel::ValidationFailed, Sequel::ForeignKeyConstraintViolation => e
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
@@ -12,6 +12,7 @@ module Inferno
12
12
  self.body = { errors: e.message }.to_json
13
13
  self.status = 422
14
14
  rescue StandardError => e
15
+ Application['logger'].error(e.full_message)
15
16
  self.body = { errors: e.message }.to_json
16
17
  self.status = 500
17
18
  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 = serialize(test_sessions_repo.results_for_test_session(params[:test_session_id]))
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
@@ -0,0 +1,11 @@
1
+ module Inferno
2
+ module Web
3
+ module Serializers
4
+ class HashValueExtractor < Blueprinter::Extractor
5
+ def extract(field_name, object, _local_options, _options)
6
+ object.send(field_name).values
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -9,6 +9,7 @@ module Inferno
9
9
  field :url
10
10
  field :direction
11
11
  field :status
12
+ field :result_id
12
13
  end
13
14
 
14
15
  view :full do
@@ -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?
@@ -0,0 +1,10 @@
1
+ module Inferno
2
+ module Web
3
+ module Serializers
4
+ class SessionData < Serializer
5
+ field :name
6
+ field :value
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,13 +4,10 @@ module Inferno
4
4
  class Test < Serializer
5
5
  identifier :id
6
6
  field :title
7
- field :inputs do |test, _options|
8
- test.inputs.map { |input| { name: input } }
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
- # field :run_as_group
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 do |group, _options|
15
- group.inputs.map { |input| { name: input } }
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
@@ -6,6 +6,7 @@ module Inferno
6
6
  field :test_session_id
7
7
 
8
8
  field :status
9
+ field :test_count
9
10
 
10
11
  field :test_group_id, if: :field_present?
11
12
  field :test_suite_id, if: :field_present?
@@ -9,7 +9,7 @@ module Inferno
9
9
  field :test_suite_id
10
10
 
11
11
  association :test_suite, blueprint: TestSuite, view: :full
12
- # association :test_run, blueprint: TestRun
12
+ # association :test_runs, blueprint: TestRun
13
13
  # association :results, blueprint: Result
14
14
  end
15
15
  end
@@ -6,6 +6,7 @@ module Inferno
6
6
  identifier :id
7
7
  field :title
8
8
  field :description
9
+ field :test_count
9
10
  end
10
11
 
11
12
  view :full do
@@ -1,3 +1,4 @@
1
+ require 'dry/system/container'
1
2
  require_relative 'boot'
2
3
 
3
4
  module Inferno
@@ -6,6 +7,10 @@ module Inferno
6
7
 
7
8
  use :env, inferrer: -> { ENV.fetch('APP_ENV', :development).to_sym }
8
9
 
10
+ Application.register('js_host', ENV.fetch('JS_HOST', ''))
11
+ Application.register('async_jobs', ENV['ASYNC_JOBS'] != 'false')
12
+ Application.register('inferno_host', ENV.fetch('INFERNO_HOST', 'http://localhost:4567'))
13
+
9
14
  configure do |config|
10
15
  config.root = File.expand_path('../../..', __dir__)
11
16
  config.default_namespace = 'inferno'
@@ -15,8 +20,6 @@ module Inferno
15
20
  config.auto_register = 'lib'
16
21
  end
17
22
 
18
- Application.register('js_host', ENV.fetch('JS_HOST', ''))
19
-
20
23
  load_paths!('lib')
21
24
  end
22
25
  end
@@ -1,3 +1,5 @@
1
+ require 'sequel'
2
+
1
3
  Inferno::Application.boot(:db) do
2
4
  init do
3
5
  use :logging
@@ -17,7 +19,14 @@ Inferno::Application.boot(:db) do
17
19
 
18
20
  start do
19
21
  Sequel.extension :migration
22
+ db = Inferno::Application['db.connection']
20
23
  migration_path = File.join(Inferno::Application.root, 'lib', 'inferno', 'db', 'migrations')
21
- Sequel::Migrator.run(Inferno::Application['db.connection'], migration_path)
24
+ Sequel::Migrator.run(db, migration_path)
25
+
26
+ if ENV['APP_ENV'] == 'development'
27
+ schema_path = File.join(Inferno::Application.root, 'lib', 'inferno', 'db', 'schema.rb')
28
+ db.extension :schema_dumper
29
+ File.open(schema_path, 'w') { |f| f.print(db.dump_schema_migration) }
30
+ end
22
31
  end
23
32
  end
@@ -0,0 +1,11 @@
1
+ require 'sidekiq'
2
+
3
+ Inferno::Application.boot(:sidekiq) do
4
+ init do
5
+ if Inferno::Application['async_jobs']
6
+ Sidekiq.configure_server do |config|
7
+ config.redis = { url: ENV.fetch('REDIS_URL', 'redis://127.0.0.1:6379/0') }
8
+ end
9
+ end
10
+ end
11
+ 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'] == 'true'
8
- files_to_load.concat Dir.glob(File.join(Inferno::Application.root, 'dev_suites', '**', '*.rb'))
9
- end
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'
@@ -1,3 +1,5 @@
1
+ require 'dotenv'
2
+
1
3
  ENV['APP_ENV'] ||= 'development'
2
4
 
3
5
  root_path = Dir.pwd
@@ -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,7 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column :test_runs, :identifier, String, text: true
4
+ add_column :test_runs, :wait_timeout, DateTime
5
+ add_index :test_runs, [:status, :identifier, :wait_timeout, :updated_at], concurrently: true
6
+ end
7
+ end
@@ -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
@@ -0,0 +1,5 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_index :results, [:test_run_id, :updated_at], concurrently: true
4
+ end
5
+ end
@@ -0,0 +1,154 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table(:schema_info) do
4
+ Integer :version, :default=>0, :null=>false
5
+ end
6
+
7
+ create_table(:test_sessions) do
8
+ String :id, :size=>255, :null=>false
9
+ String :test_suite_id, :size=>255
10
+ DateTime :created_at, :null=>false
11
+ DateTime :updated_at, :null=>false
12
+
13
+ primary_key [:id]
14
+ end
15
+
16
+ create_table(:session_data, :ignore_index_errors=>true) do
17
+ String :id, :size=>255, :null=>false
18
+ foreign_key :test_session_id, :test_sessions, :type=>String, :size=>255
19
+ String :name, :size=>255
20
+ String :value, :text=>true
21
+
22
+ index [:id], :unique=>true
23
+ index [:test_session_id]
24
+ index [:test_session_id, :name], :unique=>true
25
+ end
26
+
27
+ create_table(:test_runs, :ignore_index_errors=>true) do
28
+ String :id, :size=>255, :null=>false
29
+ String :status, :size=>255
30
+ foreign_key :test_session_id, :test_sessions, :type=>String, :size=>255
31
+ String :test_suite_id, :size=>255
32
+ String :test_group_id, :size=>255
33
+ String :test_id, :size=>255
34
+ DateTime :created_at, :null=>false
35
+ DateTime :updated_at, :null=>false
36
+ String :identifier, :text=>true
37
+ DateTime :wait_timeout
38
+
39
+ primary_key [:id]
40
+
41
+ index [:status, :identifier, :wait_timeout, :updated_at]
42
+ index [:test_group_id]
43
+ index [:test_id]
44
+ index [:test_session_id]
45
+ index [:test_session_id, :status]
46
+ index [:test_suite_id]
47
+ end
48
+
49
+ create_table(:results, :ignore_index_errors=>true) do
50
+ String :id, :size=>255, :null=>false
51
+ foreign_key :test_run_id, :test_runs, :type=>String, :size=>255
52
+ foreign_key :test_session_id, :test_sessions, :type=>String, :size=>255
53
+ String :result, :size=>255
54
+ String :result_message, :size=>255
55
+ String :test_suite_id, :size=>255
56
+ String :test_group_id, :size=>255
57
+ String :test_id, :size=>255
58
+ DateTime :created_at, :null=>false
59
+ DateTime :updated_at, :null=>false
60
+ String :input_json, :text=>true
61
+ String :output_json, :text=>true
62
+
63
+ primary_key [:id]
64
+
65
+ index [:test_run_id]
66
+ index [:test_run_id, :updated_at]
67
+ index [:test_session_id]
68
+ index [:test_session_id, :test_group_id]
69
+ index [:test_session_id, :test_id]
70
+ index [:test_session_id, :test_suite_id]
71
+ end
72
+
73
+ create_table(:messages, :ignore_index_errors=>true) do
74
+ primary_key :index
75
+ String :id, :size=>255, :null=>false
76
+ foreign_key :result_id, :results, :type=>String, :size=>255
77
+ String :type, :size=>255
78
+ String :message, :size=>255
79
+ DateTime :created_at, :null=>false
80
+ DateTime :updated_at, :null=>false
81
+
82
+ index [:id]
83
+ index [:result_id]
84
+ end
85
+
86
+ create_table(:requests, :ignore_index_errors=>true) do
87
+ primary_key :index
88
+ String :id, :size=>255, :null=>false
89
+ String :verb, :size=>255
90
+ String :url, :size=>255
91
+ String :direction, :size=>255
92
+ Integer :status
93
+ String :name, :size=>255
94
+ String :request_body, :text=>true
95
+ String :response_body, :text=>true
96
+ foreign_key :result_id, :results, :type=>String, :size=>255
97
+ foreign_key :test_session_id, :test_sessions, :type=>String, :size=>255
98
+ String :"[:test_session_id, :name]"
99
+ DateTime :created_at, :null=>false
100
+ DateTime :updated_at, :null=>false
101
+
102
+ index [:id]
103
+ index [:result_id]
104
+ index [:test_session_id]
105
+ end
106
+
107
+ create_table(:result_outputs, :ignore_index_errors=>true) do
108
+ String :id, :size=>255, :null=>false
109
+ foreign_key :result_id, :results, :type=>String, :size=>255
110
+ String :test_output_id, :size=>255
111
+ String :value, :size=>255
112
+ DateTime :created_at, :null=>false
113
+ DateTime :updated_at, :null=>false
114
+
115
+ primary_key [:id]
116
+
117
+ index [:result_id]
118
+ end
119
+
120
+ create_table(:result_prompt_values, :ignore_index_errors=>true) do
121
+ String :id, :size=>255, :null=>false
122
+ foreign_key :result_id, :results, :type=>String, :size=>255
123
+ String :test_prompt_id, :size=>255, :null=>false
124
+ String :value, :size=>255, :null=>false
125
+ DateTime :created_at, :null=>false
126
+ DateTime :updated_at, :null=>false
127
+
128
+ primary_key [:id]
129
+
130
+ index [:result_id]
131
+ end
132
+
133
+ create_table(:headers, :ignore_index_errors=>true) do
134
+ String :id, :size=>255, :null=>false
135
+ foreign_key :request_id, :requests, :type=>String, :size=>255
136
+ String :type, :size=>255
137
+ String :name, :size=>255
138
+ String :value, :size=>255
139
+ DateTime :created_at, :null=>false
140
+ DateTime :updated_at, :null=>false
141
+
142
+ index [:id]
143
+ index [:request_id]
144
+ end
145
+
146
+ create_table(:requests_results, :ignore_index_errors=>true) do
147
+ foreign_key :results_id, :results, :type=>String, :size=>255, :null=>false
148
+ foreign_key :requests_id, :requests, :type=>String, :size=>255, :null=>false
149
+
150
+ index [:requests_id]
151
+ index [:results_id]
152
+ end
153
+ end
154
+ end
@@ -88,6 +88,26 @@ module Inferno
88
88
  rescue JSON::ParserError
89
89
  assert false, "Invalid JSON. #{message}"
90
90
  end
91
+
92
+ def assert_valid_http_uri(uri, message = '')
93
+ error_message = message || "\"#{uri}\" is not a valid URI"
94
+ assert uri =~ /\A#{URI::DEFAULT_PARSER.make_regexp(['http', 'https'])}\z/, error_message
95
+ end
96
+
97
+ def assert_response_content_type(type, request: self.request)
98
+ header = request.response_header('Content-Type')
99
+ assert header.present?, no_content_type_message
100
+
101
+ assert header.value.start_with?(type), bad_content_type_message(type, header.value)
102
+ end
103
+
104
+ def no_content_type_message
105
+ 'Response did not contain a `Content-Type` header.'
106
+ end
107
+
108
+ def bad_content_type_message(expected, received)
109
+ "Expected `Content-Type` to be `#{expected}`, but found `#{received}`"
110
+ end
91
111
  end
92
112
  end
93
113
  end