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.
- 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
@@ -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
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
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
|
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
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
# @
|
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
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
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 :
|
16
|
+
attr_reader :test_session_id, :scratch
|
14
17
|
|
18
|
+
# @private
|
15
19
|
def initialize(**params)
|
16
|
-
|
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
|
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 :
|
109
|
-
|
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
|
-
|
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
|
@@ -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
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
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
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
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, :
|
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
|
|
data/lib/inferno/entities.rb
CHANGED
@@ -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'
|
data/lib/inferno/exceptions.rb
CHANGED
@@ -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
|
data/lib/inferno/jobs.rb
ADDED
@@ -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
|