inferno_core 0.0.3 → 0.0.7

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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/bin/inferno +7 -0
  3. data/lib/inferno/apps/cli/console.rb +12 -0
  4. data/lib/inferno/apps/cli/main.rb +18 -0
  5. data/lib/inferno/apps/cli/migration.rb +14 -0
  6. data/lib/inferno/apps/cli.rb +8 -0
  7. data/lib/inferno/apps/web/controllers/test_runs/create.rb +30 -10
  8. data/lib/inferno/apps/web/controllers/test_runs/show.rb +10 -0
  9. data/lib/inferno/apps/web/controllers/test_sessions/create.rb +1 -0
  10. data/lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb +22 -0
  11. data/lib/inferno/apps/web/controllers/test_sessions/results/index.rb +6 -1
  12. data/lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb +21 -0
  13. data/lib/inferno/apps/web/router.rb +15 -0
  14. data/lib/inferno/apps/web/serializers/hash_value_extractor.rb +11 -0
  15. data/lib/inferno/apps/web/serializers/request.rb +1 -0
  16. data/lib/inferno/apps/web/serializers/result.rb +8 -0
  17. data/lib/inferno/apps/web/serializers/session_data.rb +10 -0
  18. data/lib/inferno/apps/web/serializers/test.rb +3 -6
  19. data/lib/inferno/apps/web/serializers/test_group.rb +5 -8
  20. data/lib/inferno/apps/web/serializers/test_run.rb +1 -0
  21. data/lib/inferno/apps/web/serializers/test_session.rb +1 -1
  22. data/lib/inferno/apps/web/serializers/test_suite.rb +1 -0
  23. data/lib/inferno/config/application.rb +8 -2
  24. data/lib/inferno/config/boot/db.rb +3 -2
  25. data/lib/inferno/config/boot/logging.rb +2 -0
  26. data/lib/inferno/config/boot/sidekiq.rb +11 -0
  27. data/lib/inferno/config/boot/suites.rb +4 -6
  28. data/lib/inferno/config/boot.rb +2 -0
  29. data/lib/inferno/db/migrations/001_create_initial_structure.rb +0 -21
  30. data/lib/inferno/db/migrations/002_add_wait_support.rb +7 -0
  31. data/lib/inferno/db/migrations/003_update_session_data.rb +18 -0
  32. data/lib/inferno/db/migrations/004_add_request_results_table.rb +9 -0
  33. data/lib/inferno/db/migrations/005_add_updated_at_index_to_results.rb +5 -0
  34. data/lib/inferno/db/schema.rb +154 -0
  35. data/lib/inferno/dsl/assertions.rb +85 -0
  36. data/lib/inferno/dsl/configurable.rb +126 -0
  37. data/lib/inferno/dsl/fhir_client.rb +8 -6
  38. data/lib/inferno/dsl/fhir_client_builder.rb +19 -3
  39. data/lib/inferno/dsl/fhir_validation.rb +1 -1
  40. data/lib/inferno/dsl/http_client.rb +14 -12
  41. data/lib/inferno/dsl/http_client_builder.rb +3 -3
  42. data/lib/inferno/dsl/request_storage.rb +34 -13
  43. data/lib/inferno/dsl/results.rb +49 -0
  44. data/lib/inferno/dsl/resume_test_route.rb +89 -0
  45. data/lib/inferno/dsl/runnable.rb +183 -28
  46. data/lib/inferno/dsl.rb +1 -3
  47. data/lib/inferno/entities/header.rb +14 -7
  48. data/lib/inferno/entities/message.rb +16 -6
  49. data/lib/inferno/entities/request.rb +59 -20
  50. data/lib/inferno/entities/result.rb +45 -22
  51. data/lib/inferno/entities/session_data.rb +39 -0
  52. data/lib/inferno/entities/test.rb +48 -8
  53. data/lib/inferno/entities/test_group.rb +8 -0
  54. data/lib/inferno/entities/test_run.rb +36 -6
  55. data/lib/inferno/entities/test_session.rb +17 -11
  56. data/lib/inferno/entities.rb +1 -1
  57. data/lib/inferno/exceptions.rb +24 -0
  58. data/lib/inferno/jobs/execute_test_run.rb +14 -0
  59. data/lib/inferno/jobs/resume_test_run.rb +14 -0
  60. data/lib/inferno/jobs.rb +16 -0
  61. data/lib/inferno/public/bundle.js +1 -1
  62. data/lib/inferno/repositories/in_memory_repository.rb +1 -1
  63. data/lib/inferno/repositories/repository.rb +13 -0
  64. data/lib/inferno/repositories/requests.rb +5 -4
  65. data/lib/inferno/repositories/results.rb +151 -3
  66. data/lib/inferno/repositories/session_data.rb +47 -0
  67. data/lib/inferno/repositories/test_runs.rb +81 -0
  68. data/lib/inferno/spec_support.rb +1 -1
  69. data/lib/inferno/test_runner.rb +126 -32
  70. data/lib/inferno/utils/markdown_formatter.rb +15 -0
  71. data/lib/inferno/utils/middleware/request_logger.rb +17 -4
  72. data/lib/inferno/utils/migration.rb +17 -0
  73. data/lib/inferno/version.rb +1 -1
  74. data/lib/inferno.rb +4 -4
  75. data/spec/factories/request.rb +14 -7
  76. data/spec/factories/result.rb +8 -0
  77. data/spec/factories/test_run.rb +2 -0
  78. metadata +84 -7
  79. data/bin/inferno-console +0 -8
  80. data/lib/inferno/dsl/fhir_manipulation.rb +0 -25
  81. data/lib/inferno/entities/test_input.rb +0 -20
@@ -2,21 +2,34 @@ 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
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
5
+ # @!attribute id
6
+ # @return [String] id of the request
7
+ # @!attribute index
8
+ # @return [String] index of the request. Used for ordering.
9
+ # @!attribute verb
10
+ # @return [String] http verb
11
+ # @!attribute url
12
+ # @return [String] request url
13
+ # @!attribute direction
14
+ # @return [String] incoming/outgoing
15
+ # @!attribute name
16
+ # @return [String] name for the request
17
+ # @!attribute status
18
+ # @return [String] http response status code
19
+ # @!attribute request_body
20
+ # @return [String] body of the http request
21
+ # @!attribute response_body
22
+ # @return [String] body of the http response
23
+ # @!attribute headers
24
+ # @return [Array<Inferno::Entities::Header>] http request/response headers
25
+ # @!attribute result_id
26
+ # @return [String] id of the result for this request
27
+ # @!attribute test_session_id
28
+ # @return [String] id of the test session for this request
29
+ # @!attribute created_at
30
+ # @return [Time] creation timestamp
31
+ # @!attribute updated_at
32
+ # @return [Time] update timestamp
20
33
  class Request < Entity
21
34
  ATTRIBUTES = [
22
35
  :id, :index, :verb, :url, :direction, :name, :status,
@@ -36,12 +49,17 @@ module Inferno
36
49
  @headers = params[:headers]&.map { |header| header.is_a?(Hash) ? Header.new(header) : header } || []
37
50
  end
38
51
 
52
+ # @return [Hash<String, String>]
53
+ def query_parameters
54
+ Addressable::URI.parse(url).query_values || {}
55
+ end
56
+
39
57
  # Find a response header
40
58
  #
41
59
  # @param name [String] the header name
42
60
  # @return [Inferno::Entities::RequestHeader, nil]
43
61
  def response_header(name)
44
- response_headers.find { |header| header.name == name.downcase }
62
+ response_headers.find { |header| header.name.casecmp(name).zero? }
45
63
  end
46
64
 
47
65
  # Find a request header
@@ -49,7 +67,7 @@ module Inferno
49
67
  # @param name [String] the header name
50
68
  # @return [Inferno::Entities::RequestHeader, nil]
51
69
  def request_header(name)
52
- request_headers.find { |header| header.name == name.downcase }
70
+ request_headers.find { |header| header.name.casecmp(name).zero? }
53
71
  end
54
72
 
55
73
  # All of the request headers
@@ -89,7 +107,7 @@ module Inferno
89
107
  }
90
108
  end
91
109
 
92
- # @api private
110
+ # @private
93
111
  def to_hash
94
112
  {
95
113
  id: id,
@@ -117,7 +135,28 @@ module Inferno
117
135
  end
118
136
 
119
137
  class << self
120
- # @api private
138
+ # @private
139
+ def from_rack_env(env, name: nil)
140
+ rack_request = env['router.request'].rack_request
141
+ url = "#{rack_request.base_url}#{rack_request.path}"
142
+ url += "?#{rack_request.query_string}" if rack_request.query_string.present?
143
+ request_headers =
144
+ env
145
+ .select { |key, _| key.start_with? 'HTTP_' }
146
+ .transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase }
147
+ .map { |header_name, value| Header.new(name: header_name, value: value, type: 'request') }
148
+
149
+ new(
150
+ verb: rack_request.request_method.downcase,
151
+ url: url,
152
+ direction: 'incoming',
153
+ name: name,
154
+ request_body: rack_request.body.string,
155
+ headers: request_headers
156
+ )
157
+ end
158
+
159
+ # @private
121
160
  def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil)
122
161
  request_headers =
123
162
  response.env.request_headers
@@ -139,7 +178,7 @@ module Inferno
139
178
  )
140
179
  end
141
180
 
142
- # @api private
181
+ # @private
143
182
  def from_fhir_client_reply(reply, test_session_id:, direction: 'outgoing', name: nil)
144
183
  request = reply.request
145
184
  response = reply.response
@@ -3,32 +3,49 @@ 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`,
18
- # `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
22
- # belongs to
23
- # @attr_reader [Array<Inferno::Entities::Message>] messages additional
24
- # messages for this result
25
- # @attr_reader [Array<Inferno::Entities::Request>] request_summaries
26
- # summaries of the requests associated with this result
6
+ # @!attribute id
7
+ # @return [String] id of the session
8
+ # @!attribute created_at
9
+ # @return [Time] creation timestamp
10
+ # @!attribute updated_at
11
+ # @return [Time] update timestamp
12
+ # @!attribute test_id
13
+ # @return [String, nil] id of the `Test` this result belongs to
14
+ # @!attribute test
15
+ # @return [Test, nil] the `Test` this result belongs to
16
+ # @!attribute test_group_id
17
+ # @return [String, nil] id of the `TestGroup` this result belongs to
18
+ # @!attribute test_group
19
+ # @return [TestGroup, nil] the `TestGroup` this result belongs to
20
+ # @!attribute test_suite_id
21
+ # @return [String, nil] id of the `TestSuite` this result belongs to
22
+ # @!attribute test_suite
23
+ # @return [TestSuite, nil] the `TestSuite` this result belongs to
24
+ # @!attribute result
25
+ # @return [String] the result (`pass`, `fail`, `skip`, `omit`, `error`,
26
+ # `running`, `wait`, `cancel`)
27
+ # @!attribute result_message
28
+ # @return [String] summary message for this result
29
+ # @!attribute test_run_id
30
+ # @return [String] the `TestRun` this result belongs to
31
+ # @!attribute test_session_id
32
+ # @return [String] the `TestSession` this result belongs to
33
+ # @!attribute messages
34
+ # @return [Array<Inferno::Entities::Message>] additional messages for this
35
+ # result
36
+ # @!attribute requests
37
+ # @return [Array<Inferno::Entities::Request>] summaries of the requests
38
+ # associated with this result
39
+ # @!attribute input_json
40
+ # @return [String] JSON string of the inputs used for this result
41
+ # @!attribute output_json
42
+ # @return [String] JSON string of the outputs created by this result
27
43
  class Result < Entity
28
44
  ATTRIBUTES = [
29
45
  :id, :created_at, :updated_at, :test_id, :test, :test_group_id,
30
46
  :test_group, :test_suite_id, :test_suite, :test_run_id,
31
- :test_session_id, :result, :result_message, :messages, :requests
47
+ :test_session_id, :result, :result_message, :messages, :requests,
48
+ :input_json, :output_json
32
49
  ].freeze
33
50
  RESULT_OPTIONS = ['cancel', 'wait', 'running', 'error', 'fail', 'skip', 'omit', 'pass'].freeze
34
51
 
@@ -41,9 +58,15 @@ module Inferno
41
58
  @requests = (params[:requests] || []).map { |request| Request.new(request) }
42
59
  end
43
60
 
61
+ # @return [Inferno::Entities::Test, Inferno::Entities::TestGroup, Inferno::Entities::TestSuite]
44
62
  def runnable
45
63
  test || test_group || test_suite
46
64
  end
65
+
66
+ # @return [Boolean]
67
+ def waiting?
68
+ result == 'wait'
69
+ end
47
70
  end
48
71
  end
49
72
  end
@@ -0,0 +1,39 @@
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
+ # @!attribute id
7
+ # @return [String] id of the test input
8
+ # @!attribute name
9
+ # @return [String]
10
+ # @!attribute value
11
+ # @return [String]
12
+ # @!attribute test_session_id
13
+ # @return [String]
14
+ # @!attribute created_at
15
+ # @return [Time]
16
+ # @!attribute updated_at
17
+ # @return [Time]
18
+ class SessionData < Entity
19
+ ATTRIBUTES = [:id, :name, :value, :test_session_id, :created_at, :updated_at].freeze
20
+
21
+ include Inferno::Entities::Attributes
22
+
23
+ def initialize(params)
24
+ super(params, ATTRIBUTES)
25
+ end
26
+
27
+ def to_hash
28
+ {
29
+ id: id,
30
+ name: name,
31
+ value: value,
32
+ test_session_id: test_session_id,
33
+ created_at: created_at,
34
+ updated_at: updated_at
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,28 +1,34 @@
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
 
18
+ # @private
15
19
  def initialize(**params)
16
- @inputs = params[:inputs]
20
+ params[:inputs]&.each { |key, value| instance_variable_set("@#{key}", value) }
21
+ @scratch = params[:scratch]
17
22
  @test_session_id = params[:test_session_id]
18
23
  end
19
24
 
25
+ # @private
20
26
  def messages
21
27
  @messages ||= []
22
28
  end
23
29
 
24
30
  def add_message(type, message)
25
- messages << { type: type.to_s, message: message }
31
+ messages << { type: type.to_s, message: format_markdown(message) }
26
32
  end
27
33
 
28
34
  # Set output values. Once set, these values will be available to any
@@ -33,11 +39,21 @@ module Inferno
33
39
  # @example
34
40
  # output(patient_id: '5', bearer_token: 'ABC')
35
41
  def output(outputs)
42
+ # TODO: update to track outputs that need to be updated
36
43
  outputs.each do |key, value|
37
44
  send("#{key}=", value)
45
+ outputs_to_persist[key] = value
38
46
  end
39
47
  end
40
48
 
49
+ # @api private
50
+ # A hash containing outputs that have been set during execution and need
51
+ # to be persisted. A test may not always update all outputs, so this is
52
+ # used to prevent overwriting an output with nil when it wasn't updated.
53
+ def outputs_to_persist
54
+ @outputs_to_persist ||= {}
55
+ end
56
+
41
57
  # Add an informational message to the results of a test. If passed a
42
58
  # block, a failed assertion will become an info message and test execution
43
59
  # will continue.
@@ -86,6 +102,7 @@ module Inferno
86
102
  add_message('warning', e.message)
87
103
  end
88
104
 
105
+ # @private
89
106
  def method_missing(name, *args, &block)
90
107
  parent_instance = self.class.parent&.new
91
108
  if parent_instance.respond_to?(name)
@@ -95,6 +112,7 @@ module Inferno
95
112
  end
96
113
  end
97
114
 
115
+ # @private
98
116
  def respond_to_missing?(name, _include_private = false)
99
117
  self.class.parent&.new&.respond_to?(name)
100
118
  end
@@ -102,15 +120,24 @@ module Inferno
102
120
  class << self
103
121
  # Define inputs for this Test
104
122
  #
105
- # @param inputs [Symbol]
123
+ # @param name [Symbol] name of the input
124
+ # @param other_names [Symbol] array of symbols if specifying multiple inputs
125
+ # @param input_definition [Hash] options for input such as type, description, or title
126
+ # @option input_definition [String] :title Human readable title for input
127
+ # @option input_definition [String] :description Description for the input
128
+ # @option input_definition [String] :type 'text' | 'textarea'
106
129
  # @return [void]
107
130
  # @example
108
- # input :patient_id, :bearer_token
109
- def input(*input_definitions)
131
+ # input :patientid, title: 'Patient ID', description: 'The ID of the patient being searched for'
132
+ # @example
133
+ # input :textarea, title: 'Textarea Input Example', type: 'textarea'
134
+ def input(name, *other_names, **input_definition)
110
135
  super
111
136
 
112
- input_definitions.each do |input|
113
- attr_reader input
137
+ if other_names.present?
138
+ [name, *other_names].each { |input| attr_reader input }
139
+ else
140
+ attr_reader name
114
141
  end
115
142
  end
116
143
 
@@ -132,6 +159,10 @@ module Inferno
132
159
  Inferno::Repositories::Tests.new
133
160
  end
134
161
 
162
+ # Set/Get the block that is executed when a Test is run
163
+ #
164
+ # @param block [Proc]
165
+ # @return [Proc] the block that is executed when a Test is run
135
166
  def block(&block)
136
167
  return @block unless block_given?
137
168
 
@@ -140,6 +171,7 @@ module Inferno
140
171
 
141
172
  alias run block
142
173
 
174
+ # @private
143
175
  def default_id
144
176
  return name if name.present?
145
177
 
@@ -147,12 +179,19 @@ module Inferno
147
179
  "Test#{suffix}"
148
180
  end
149
181
 
182
+ # @private
150
183
  def reference_hash
151
184
  {
152
185
  test_id: id
153
186
  }
154
187
  end
155
188
 
189
+ # @private
190
+ def test_count
191
+ 1
192
+ end
193
+
194
+ # @private
156
195
  def method_missing(name, *args, &block)
157
196
  parent_instance = parent&.new
158
197
  if parent_instance.respond_to?(name)
@@ -162,6 +201,7 @@ module Inferno
162
201
  end
163
202
  end
164
203
 
204
+ # @private
165
205
  def respond_to_missing?(name, _include_private = false)
166
206
  parent&.new&.respond_to?(name)
167
207
  end
@@ -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,37 @@ 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
+ # @!attribute id
6
+ # @return [String] id of the test run
7
+ # @!attribute created_at
8
+ # @return [Time] creation timestamp
9
+ # @!attribute updated_at
10
+ # @return [Time] update timestamp
11
+ # @!attribute test_session_id
12
+ # @return [String]
13
+ # @!attribute status
14
+ # @return [String]
15
+ # @!attribute test_id
16
+ # @return [String, nil] id of the `Test` this result belongs to
17
+ # @!attribute test
18
+ # @return [Test, nil] the `Test` this result belongs to
19
+ # @!attribute test_group_id
20
+ # @return [String, nil] id of the `TestGroup` this result belongs to
21
+ # @!attribute test_group
22
+ # @return [TestGroup, nil] the `TestGroup` this result belongs to
23
+ # @!attribute test_suite_id
24
+ # @return [String, nil] id of the `TestSuite` this result belongs to
25
+ # @!attribute test_suite
26
+ # @return [TestSuite, nil] the `TestSuite` this result belongs to
27
+ # @!attribute inputs
28
+ # @return [Array<Hash>]
29
+ # @!attribute results
30
+ # @return [Array<Inferno::Entities::Result>]
31
+ # @!attribute identifier
32
+ # @return [String, nil] identfier for a waiting `TestRun`
33
+ # @!attribute wait_timeout
11
34
  class TestRun < Entity
35
+ STATUS_OPTIONS = ['queued', 'running', 'waiting', 'done'].freeze
12
36
  ATTRIBUTES = [
13
37
  :id,
14
38
  :test_session_id,
@@ -21,6 +45,8 @@ module Inferno
21
45
  :test_suite,
22
46
  :inputs,
23
47
  :results,
48
+ :identifier,
49
+ :wait_timeout,
24
50
  :created_at,
25
51
  :updated_at
26
52
  ].freeze
@@ -47,6 +73,10 @@ module Inferno
47
73
  super.merge(test_session: test_session).compact
48
74
  end
49
75
 
76
+ def test_count
77
+ @test_count ||= runnable.test_count
78
+ end
79
+
50
80
  private
51
81
 
52
82
  def load_runnable
@@ -2,19 +2,25 @@ 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
9
- # this session
10
- # @attr_reader [Inferno::Entities::TestSuite] test_suite the `TestSuite` being run in
11
- # this session
12
- # @attr_reader [Array<Inferno::Entities::TestRun>] test_runs the `TestRuns`
5
+ # @!attribute id
6
+ # @return [String] id of the session
7
+ # @!attribute created_at
8
+ # @return [Time] creation timestamp
9
+ # @!attribute updated_at
10
+ # @return [Time] update timestamp
11
+ # @!attribute test_suite_id
12
+ # @return [String] id of the `TestSuite` being run in this session
13
+ # @!attribute test_suite
14
+ # @return [Inferno::Entities::TestSuite] the `TestSuite` being run in this
15
+ # session
16
+ # @!attribute test_runs
17
+ # @return [Array<Inferno::Entities::TestRun>] the `TestRuns` associated
18
+ # with this session
19
+ # @!attribute results
20
+ # @return [Array<Inferno::Entities::TestResult>] the `TestResults`
13
21
  # associated with this session
14
- # @attr_reader [Array<Inferno::Entities::TestResult>] test_results the
15
- # `TestResults` associated with this session
16
22
  class TestSession < Entity
17
- ATTRIBUTES = [:id, :created_at, :updated_at, :test_suite_id, :test_suite, :test_runs, :test_results].freeze
23
+ ATTRIBUTES = [:id, :created_at, :updated_at, :test_suite_id, :test_suite, :test_runs, :results].freeze
18
24
 
19
25
  include Inferno::Entities::Attributes
20
26
 
@@ -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