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
data/lib/inferno/dsl.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require_relative 'dsl/assertions'
2
2
  require_relative 'dsl/fhir_client'
3
- require_relative 'dsl/fhir_manipulation'
4
3
  require_relative 'dsl/fhir_validation'
5
4
  require_relative 'dsl/http_client'
6
5
  require_relative 'dsl/results'
@@ -14,8 +13,7 @@ module Inferno
14
13
  FHIRClient,
15
14
  HTTPClient,
16
15
  Results,
17
- FHIRValidation,
18
- FHIRManipulation
16
+ FHIRValidation
19
17
  ].freeze
20
18
 
21
19
  EXTENDABLE_DSL_MODULES = [
@@ -2,13 +2,13 @@ module Inferno
2
2
  module Entities
3
3
  # A `Header` represents an HTTP request/response header
4
4
  #
5
- # @attr_reader [String] id of the header
6
- # @attr_reader [String] request_id index of the HTTP request
7
- # @attr_reader [String] name header name
8
- # @attr_reader [String] value header value
9
- # @attr_reader [String] type request/response
10
- # @attr_reader [Time] created_at
11
- # @attr_reader [Time] updated_at
5
+ # @attr_accessor [String] id of the header
6
+ # @attr_accessor [String] request_id index of the HTTP request
7
+ # @attr_accessor [String] name header name
8
+ # @attr_accessor [String] value header value
9
+ # @attr_accessor [String] type request/response
10
+ # @attr_accessor [Time] created_at
11
+ # @attr_accessor [Time] updated_at
12
12
  class Header < Entity
13
13
  ATTRIBUTES = [:id, :request_id, :name, :type, :value, :created_at, :updated_at].freeze
14
14
 
@@ -2,12 +2,14 @@ module Inferno
2
2
  module Entities
3
3
  # A `Message` represents a message generated during a test.
4
4
  #
5
- # @attr_reader [String] id of the message
6
- # @attr_reader [String] index of the message. Used for ordering.
7
- # @attr_reader [String] result_id
8
- # @attr_reader [Inferno::Entities::Result] result
9
- # @attr_reader [String] type
10
- # @attr_reader [String] message
5
+ # @attr_accessor [String] id of the message
6
+ # @attr_accessor [String] index of the message. Used for ordering.
7
+ # @attr_accessor [String] result_id
8
+ # @attr_accessor [Inferno::Entities::Result] result
9
+ # @attr_accessor [String] type
10
+ # @attr_accessor [String] message
11
+ # @attr_accessor [Time] created_at
12
+ # @attr_accessor [Time] updated_at
11
13
  class Message < Entity
12
14
  ATTRIBUTES = [:id, :index, :message, :result_id, :result, :type, :created_at, :updated_at].freeze
13
15
  TYPES = ['error', 'warning', 'info'].freeze
@@ -2,21 +2,21 @@ module Inferno
2
2
  module Entities
3
3
  # A `Request` represents a request and response issued during a test.
4
4
  #
5
- # @attr_reader [String] id of the request
6
- # @attr_reader [String] index of the request. Used for ordering.
7
- # @attr_reader [String] verb http verb
8
- # @attr_reader [String] url request url
9
- # @attr_reader [String] direction incoming/outgoing
10
- # @attr_reader [String] name name for the request
11
- # @attr_reader [String] status http response status code
12
- # @attr_reader [String] request_body body of the http request
13
- # @attr_reader [String] response_body body of the http response
14
- # @attr_reader [Array<Inferno::Entities::Header>] headers http
5
+ # @attr_accessor [String] id of the request
6
+ # @attr_accessor [String] index of the request. Used for ordering.
7
+ # @attr_accessor [String] verb http verb
8
+ # @attr_accessor [String] url request url
9
+ # @attr_accessor [String] direction incoming/outgoing
10
+ # @attr_accessor [String] name name for the request
11
+ # @attr_accessor [String] status http response status code
12
+ # @attr_accessor [String] request_body body of the http request
13
+ # @attr_accessor [String] response_body body of the http response
14
+ # @attr_accessor [Array<Inferno::Entities::Header>] headers http
15
15
  # request/response headers
16
- # @attr_reader [String] result_id id of the result for this request
17
- # @attr_reader [String] test_session_id id of the test session for this request
18
- # @attr_reader [Time] created_at creation timestamp
19
- # @attr_reader [Time] updated_at update timestamp
16
+ # @attr_accessor [String] result_id id of the result for this request
17
+ # @attr_accessor [String] test_session_id id of the test session for this request
18
+ # @attr_accessor [Time] created_at creation timestamp
19
+ # @attr_accessor [Time] updated_at update timestamp
20
20
  class Request < Entity
21
21
  ATTRIBUTES = [
22
22
  :id, :index, :verb, :url, :direction, :name, :status,
@@ -36,12 +36,17 @@ module Inferno
36
36
  @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || []
37
37
  end
38
38
 
39
+ # @return [Hash<String, String>]
40
+ def query_parameters
41
+ Addressable::URI.parse(url).query_values || {}
42
+ end
43
+
39
44
  # Find a response header
40
45
  #
41
46
  # @param name [String] the header name
42
47
  # @return [Inferno::Entities::RequestHeader, nil]
43
48
  def response_header(name)
44
- response_headers.find { |header| header.name == name.downcase }
49
+ response_headers.find { |header| header.name.casecmp(name).zero? }
45
50
  end
46
51
 
47
52
  # Find a request header
@@ -49,7 +54,7 @@ module Inferno
49
54
  # @param name [String] the header name
50
55
  # @return [Inferno::Entities::RequestHeader, nil]
51
56
  def request_header(name)
52
- request_headers.find { |header| header.name == name.downcase }
57
+ request_headers.find { |header| header.name.casecmp(name).zero? }
53
58
  end
54
59
 
55
60
  # All of the request headers
@@ -117,6 +122,27 @@ module Inferno
117
122
  end
118
123
 
119
124
  class << self
125
+ # @api private
126
+ def from_rack_env(env, name: nil)
127
+ rack_request = env['router.request'].rack_request
128
+ url = "#{rack_request.base_url}#{rack_request.path}"
129
+ url += "?#{rack_request.query_string}" if rack_request.query_string.present?
130
+ request_headers =
131
+ env
132
+ .select { |key, _| key.start_with? 'HTTP_' }
133
+ .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase }
134
+ .map { |header_name, value| Header.new(name: header_name, value: value, type: 'request') }
135
+
136
+ new(
137
+ verb: rack_request.request_method.downcase,
138
+ url: url,
139
+ direction: 'incoming',
140
+ name: name,
141
+ request_body: rack_request.body.string,
142
+ headers: request_headers
143
+ )
144
+ end
145
+
120
146
  # @api private
121
147
  def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil)
122
148
  request_headers =
@@ -3,32 +3,42 @@ module Inferno
3
3
  # A `Result` represents the result of running a `Test`, `TestGroup`,
4
4
  # or `TestSuite`
5
5
  #
6
- # @attr_reader [String] id id of the session
7
- # @attr_reader [Time] created_at creation timestamp
8
- # @attr_reader [Time] updated_at update timestamp
9
- # @attr_reader [String] reference_type type of entity this result belongs to
10
- # (`Test`, `TestGroup`, or `TestSuite`)
11
- # @attr_reader [String, nil] test_id id of the `Test` this result belongs to
12
- # @attr_reader [Test, nil] test the `Test` this result belongs to
13
- # @attr_reader [String, nil] test_group_id id of the `TestGroup` this result belongs to
14
- # @attr_reader [TestGroup, nil] test_group the `TestGroup` this result belongs to
15
- # @attr_reader [String, nil] test_suite_id id of the `TestSuite` this result belongs to
16
- # @attr_reader [TestSuite, nil] test_suite the `TestSuite` this result belongs to
17
- # @attr_reader [String] result the result (`pass`, `fail`, `skip`, `omit`,
6
+ # @attr_accessor [String] id id of the session
7
+ # @attr_accessor [Time] created_at creation timestamp
8
+ # @attr_accessor [Time] updated_at update timestamp
9
+ # @attr_accessor [String] reference_type type of entity this result belongs
10
+ # to (`Test`, `TestGroup`, or `TestSuite`)
11
+ # @attr_accessor [String, nil] test_id id of the `Test` this result belongs
12
+ # to
13
+ # @attr_accessor [Test, nil] test the `Test` this result belongs to
14
+ # @attr_accessor [String, nil] test_group_id id of the `TestGroup` this
15
+ # result belongs to
16
+ # @attr_accessor [TestGroup, nil] test_group the `TestGroup` this result
17
+ # belongs to
18
+ # @attr_accessor [String, nil] test_suite_id id of the `TestSuite` this
19
+ # result belongs to
20
+ # @attr_accessor [TestSuite, nil] test_suite the `TestSuite` this result
21
+ # belongs to
22
+ # @attr_accessor [String] result the result (`pass`, `fail`, `skip`, `omit`,
18
23
  # `error`, `running`, `wait`, `cancel`)
19
- # @attr_reader [String] result_message summary message for this result
20
- # @attr_reader [String] test_run_id the `TestRun` this result belongs to
21
- # @attr_reader [String] test_session_id the `TestSession` this result
24
+ # @attr_accessor [String] result_message summary message for this result
25
+ # @attr_accessor [String] test_run_id the `TestRun` this result belongs to
26
+ # @attr_accessor [String] test_session_id the `TestSession` this result
22
27
  # belongs to
23
- # @attr_reader [Array<Inferno::Entities::Message>] messages additional
28
+ # @attr_accessor [Array<Inferno::Entities::Message>] messages additional
24
29
  # messages for this result
25
- # @attr_reader [Array<Inferno::Entities::Request>] request_summaries
30
+ # @attr_accessor [Array<Inferno::Entities::Request>] request_summaries
26
31
  # summaries of the requests associated with this result
32
+ # @attr_accessor [String] input_json JSON string of the inputs used for this
33
+ # result
34
+ # @attr_accessor [String] output_json JSON string of the outputs created by
35
+ # this result
27
36
  class Result < Entity
28
37
  ATTRIBUTES = [
29
38
  :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
30
39
  :test_group, :test_suite_id, :test_suite, :test_run_id,
31
- :test_session_id, :result, :result_message, :messages, :requests
40
+ :test_session_id, :result, :result_message, :messages, :requests,
41
+ :input_json, :output_json
32
42
  ].freeze
33
43
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'omit', 'pass'].freeze
34
44
 
@@ -41,9 +51,15 @@ module Inferno
41
51
  @requests = (params[:requests] || []).map { |request| Request.new(request) }
42
52
  end
43
53
 
54
+ # @return [Inferno::Entities::Test, Inferno::Entities::TestGroup, Inferno::Entities::TestSuite]
44
55
  def runnable
45
56
  test || test_group || test_suite
46
57
  end
58
+
59
+ # @return [Boolean]
60
+ def waiting?
61
+ result == 'wait'
62
+ end
47
63
  end
48
64
  end
49
65
  end
@@ -0,0 +1,33 @@
1
+ module Inferno
2
+ module Entities
3
+ # `SessionData` represents a piece of saved state for a `TestSession`.
4
+ # These are used to store test inputs and outputs.
5
+ #
6
+ # @attr_accessor [String] id of the test input
7
+ # @attr_accessor [String] name
8
+ # @attr_accessor [String] value
9
+ # @attr_accessor [String] test_session_id
10
+ # @attr_accessor [Time] created_at
11
+ # @attr_accessor [Time] updated_at
12
+ class SessionData < Entity
13
+ ATTRIBUTES = [:id, :name, :value, :test_session_id, :created_at, :updated_at].freeze
14
+
15
+ include Inferno::Entities::Attributes
16
+
17
+ def initialize(params)
18
+ super(params, ATTRIBUTES)
19
+ end
20
+
21
+ def to_hash
22
+ {
23
+ id: id,
24
+ name: name,
25
+ value: value,
26
+ test_session_id: test_session_id,
27
+ created_at: created_at,
28
+ updated_at: updated_at
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,19 +1,23 @@
1
1
  require_relative '../dsl'
2
2
  require_relative '../repositories/tests'
3
+ require_relative '../utils/markdown_formatter'
4
+ require 'pry'
3
5
 
4
6
  module Inferno
5
7
  module Entities
6
8
  class Test
7
9
  extend Forwardable
8
10
  include DSL
11
+ include Inferno::Utils::MarkdownFormatter
9
12
 
10
13
  def_delegators 'self.class', :title, :id, :block, :inputs, :outputs
11
14
 
12
15
  attr_accessor :result_message
13
- attr_reader :inputs, :test_session_id
16
+ attr_reader :test_session_id, :scratch
14
17
 
15
18
  def initialize(**params)
16
- @inputs = params[:inputs]
19
+ params[:inputs]&.each { |key, value| instance_variable_set("@#{key}", value) }
20
+ @scratch = params[:scratch]
17
21
  @test_session_id = params[:test_session_id]
18
22
  end
19
23
 
@@ -22,7 +26,7 @@ module Inferno
22
26
  end
23
27
 
24
28
  def add_message(type, message)
25
- messages << { type: type.to_s, message: message }
29
+ messages << { type: type.to_s, message: format_markdown(message) }
26
30
  end
27
31
 
28
32
  # Set output values. Once set, these values will be available to any
@@ -33,11 +37,21 @@ module Inferno
33
37
  # @example
34
38
  # output(patient_id: '5', bearer_token: 'ABC')
35
39
  def output(outputs)
40
+ # TODO: update to track outputs that need to be updated
36
41
  outputs.each do |key, value|
37
42
  send("#{key}=", value)
43
+ outputs_to_persist[key] = value
38
44
  end
39
45
  end
40
46
 
47
+ # @api private
48
+ # A hash containing outputs that have been set during execution and need
49
+ # to be persisted. A test may not always update all outputs, so this is
50
+ # used to prevent overwriting an output with nil when it wasn't updated.
51
+ def outputs_to_persist
52
+ @outputs_to_persist ||= {}
53
+ end
54
+
41
55
  # Add an informational message to the results of a test. If passed a
42
56
  # block, a failed assertion will become an info message and test execution
43
57
  # will continue.
@@ -102,15 +116,24 @@ module Inferno
102
116
  class << self
103
117
  # Define inputs for this Test
104
118
  #
105
- # @param inputs [Symbol]
119
+ # @param name [Symbol] name of the input
120
+ # @param other_names [Symbol] array of symbols if specifying multiple inputs
121
+ # @param input_definition [Hash] options for input such as type, description, or title
122
+ # @option input_definition [String] :title Human readable title for input
123
+ # @option input_definition [String] :description Description for the input
124
+ # @option input_definition [String] :type 'text' | 'textarea'
106
125
  # @return [void]
107
126
  # @example
108
- # input :patient_id, :bearer_token
109
- def input(*input_definitions)
127
+ # input :patientid, title: 'Patient ID', description: 'The ID of the patient being searched for'
128
+ # @example
129
+ # input :textarea, title: 'Textarea Input Example', type: 'textarea'
130
+ def input(name, *other_names, **input_definition)
110
131
  super
111
132
 
112
- input_definitions.each do |input|
113
- attr_reader input
133
+ if other_names.present?
134
+ [name, *other_names].each { |input| attr_reader input }
135
+ else
136
+ attr_reader name
114
137
  end
115
138
  end
116
139
 
@@ -153,6 +176,10 @@ module Inferno
153
176
  }
154
177
  end
155
178
 
179
+ def test_count
180
+ 1
181
+ end
182
+
156
183
  def method_missing(name, *args, &block)
157
184
  parent_instance = parent&.new
158
185
  if parent_instance.respond_to?(name)
@@ -79,6 +79,14 @@ module Inferno
79
79
  test_group_id: id
80
80
  }
81
81
  end
82
+
83
+ def run_as_group(value = true) # rubocop:disable Style/OptionalBooleanParameter
84
+ @run_as_group = value
85
+ end
86
+
87
+ def run_as_group?
88
+ @run_as_group || false
89
+ end
82
90
  end
83
91
  end
84
92
  end
@@ -2,13 +2,14 @@ module Inferno
2
2
  module Entities
3
3
  # A `TestRun` represents a request to execute an executable set of tests.
4
4
  #
5
- # @attr_reader [String] id of the test input
6
- # @attr_reader [String] test_session_id
7
- # @attr_reader [String] status
8
- # @attr_reader [String] test_suite_id
9
- # @attr_reader [String] test_group_id
10
- # @attr_reader [String] test_id
5
+ # @attr_accessor [String] id of the test input
6
+ # @attr_accessor [String] test_session_id
7
+ # @attr_accessor [String] status
8
+ # @attr_accessor [String] test_suite_id
9
+ # @attr_accessor [String] test_group_id
10
+ # @attr_accessor [String] test_id
11
11
  class TestRun < Entity
12
+ STATUS_OPTIONS = ['queued', 'running', 'waiting', 'done'].freeze
12
13
  ATTRIBUTES = [
13
14
  :id,
14
15
  :test_session_id,
@@ -21,6 +22,8 @@ module Inferno
21
22
  :test_suite,
22
23
  :inputs,
23
24
  :results,
25
+ :identifier,
26
+ :wait_timeout,
24
27
  :created_at,
25
28
  :updated_at
26
29
  ].freeze
@@ -47,6 +50,10 @@ module Inferno
47
50
  super.merge(test_session: test_session).compact
48
51
  end
49
52
 
53
+ def test_count
54
+ @test_count ||= runnable.test_count
55
+ end
56
+
50
57
  private
51
58
 
52
59
  def load_runnable
@@ -2,19 +2,19 @@ module Inferno
2
2
  module Entities
3
3
  # A `TestSession` represents an individual testing session.
4
4
  #
5
- # @attr_reader [String] id id of the session
6
- # @attr_reader [Time] created_at creation timestamp
7
- # @attr_reader [Time] updated_at update timestamp
8
- # @attr_reader [String] test_suite_id id of the `TestSuite` being run in
5
+ # @attr_accessor [String] id id of the session
6
+ # @attr_accessor [Time] created_at creation timestamp
7
+ # @attr_accessor [Time] updated_at update timestamp
8
+ # @attr_accessor [String] test_suite_id id of the `TestSuite` being run in
9
9
  # this session
10
- # @attr_reader [Inferno::Entities::TestSuite] test_suite the `TestSuite` being run in
10
+ # @attr_accessor [Inferno::Entities::TestSuite] test_suite the `TestSuite` being run in
11
11
  # this session
12
- # @attr_reader [Array<Inferno::Entities::TestRun>] test_runs the `TestRuns`
12
+ # @attr_accessor [Array<Inferno::Entities::TestRun>] test_runs the `TestRuns`
13
13
  # associated with this session
14
- # @attr_reader [Array<Inferno::Entities::TestResult>] test_results the
14
+ # @attr_accessor [Array<Inferno::Entities::TestResult>] results the
15
15
  # `TestResults` associated with this session
16
16
  class TestSession < Entity
17
- ATTRIBUTES = [:id, :created_at, :updated_at, :test_suite_id, :test_suite, :test_runs, :test_results].freeze
17
+ ATTRIBUTES = [:id, :created_at, :updated_at, :test_suite_id, :test_suite, :test_runs, :results].freeze
18
18
 
19
19
  include Inferno::Entities::Attributes
20
20
 
@@ -4,9 +4,9 @@ require_relative 'entities/header'
4
4
  require_relative 'entities/message'
5
5
  require_relative 'entities/request'
6
6
  require_relative 'entities/result'
7
+ require_relative 'entities/session_data'
7
8
  require_relative 'entities/test'
8
9
  require_relative 'entities/test_group'
9
- require_relative 'entities/test_input'
10
10
  require_relative 'entities/test_run'
11
11
  require_relative 'entities/test_session'
12
12
  require_relative 'entities/test_suite'
@@ -27,6 +27,18 @@ module Inferno
27
27
  end
28
28
  end
29
29
 
30
+ class WaitException < TestResultException
31
+ def result
32
+ 'wait'
33
+ end
34
+ end
35
+
36
+ class CancelException < TestResultException
37
+ def result
38
+ 'cancel'
39
+ end
40
+ end
41
+
30
42
  class ParentNotLoadedException < RuntimeError
31
43
  def initialize(klass, id)
32
44
  super("No #{klass.name.demodulize} found with id '#{id}'")
@@ -38,5 +50,17 @@ module Inferno
38
50
  super("No '#{validator_name}' validator found")
39
51
  end
40
52
  end
53
+
54
+ class RequiredInputsNotFound < RuntimeError
55
+ def initialize(missing_inputs)
56
+ super("Missing the following required inputs: #{missing_inputs.join(', ')}")
57
+ end
58
+ end
59
+
60
+ class NotUserRunnableException < RuntimeError
61
+ def initialize
62
+ super('The chosen runnable must be run as part of a group')
63
+ end
64
+ end
41
65
  end
42
66
  end
@@ -0,0 +1,14 @@
1
+ module Inferno
2
+ module Jobs
3
+ class ExecuteTestRun
4
+ include Sidekiq::Worker
5
+
6
+ def perform(test_run_id)
7
+ test_run = Inferno::Repositories::TestRuns.new.find(test_run_id)
8
+ test_session = Inferno::Repositories::TestSessions.new.find(test_run.test_session_id)
9
+
10
+ TestRunner.new(test_session: test_session, test_run: test_run).start
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Inferno
2
+ module Jobs
3
+ class ResumeTestRun
4
+ include Sidekiq::Worker
5
+
6
+ def perform(test_run_id)
7
+ test_run = Inferno::Repositories::TestRuns.new.find(test_run_id)
8
+ test_session = Inferno::Repositories::TestSessions.new.find(test_run.test_session_id)
9
+
10
+ TestRunner.new(test_session: test_session, test_run: test_run, resume: true).start
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ require 'sidekiq'
2
+
3
+ require_relative 'jobs/execute_test_run'
4
+ require_relative 'jobs/resume_test_run'
5
+
6
+ module Inferno
7
+ module Jobs
8
+ def self.perform(job_klass, *params)
9
+ if Application['async_jobs']
10
+ job_klass.perform_async(*params)
11
+ else
12
+ job_klass.new.perform(*params)
13
+ end
14
+ end
15
+ end
16
+ end