inferno_core 0.3.11 → 0.4.0
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/lib/inferno/apps/cli/main.rb +13 -0
- data/lib/inferno/apps/cli/services.rb +56 -0
- data/lib/inferno/apps/web/application.rb +1 -0
- data/lib/inferno/apps/web/controllers/controller.rb +6 -8
- data/lib/inferno/apps/web/controllers/requests/show.rb +3 -3
- data/lib/inferno/apps/web/controllers/test_runs/create.rb +13 -17
- data/lib/inferno/apps/web/controllers/test_runs/destroy.rb +8 -10
- data/lib/inferno/apps/web/controllers/test_runs/results/index.rb +4 -4
- data/lib/inferno/apps/web/controllers/test_runs/show.rb +9 -7
- data/lib/inferno/apps/web/controllers/test_sessions/create.rb +9 -8
- data/lib/inferno/apps/web/controllers/test_sessions/last_test_run.rb +4 -4
- data/lib/inferno/apps/web/controllers/test_sessions/results/index.rb +6 -6
- data/lib/inferno/apps/web/controllers/test_sessions/session_data/apply_preset.rb +10 -10
- data/lib/inferno/apps/web/controllers/test_sessions/session_data/index.rb +5 -3
- data/lib/inferno/apps/web/controllers/test_sessions/show.rb +3 -3
- data/lib/inferno/apps/web/controllers/test_suites/check_configuration.rb +3 -3
- data/lib/inferno/apps/web/controllers/test_suites/index.rb +2 -2
- data/lib/inferno/apps/web/controllers/test_suites/show.rb +3 -3
- data/lib/inferno/apps/web/index.html.erb +4 -0
- data/lib/inferno/apps/web/router.rb +55 -41
- data/lib/inferno/apps/web/serializers/message.rb +2 -0
- data/lib/inferno/apps/web/serializers/preset.rb +2 -5
- data/lib/inferno/apps/web/serializers/request.rb +4 -1
- data/lib/inferno/apps/web/serializers/result.rb +5 -1
- data/lib/inferno/apps/web/serializers/session_data.rb +2 -0
- data/lib/inferno/apps/web/serializers/suite_option.rb +2 -0
- data/lib/inferno/apps/web/serializers/test.rb +3 -0
- data/lib/inferno/apps/web/serializers/test_group.rb +4 -2
- data/lib/inferno/apps/web/serializers/test_run.rb +3 -0
- data/lib/inferno/apps/web/serializers/test_suite.rb +5 -1
- data/lib/inferno/config/application.rb +1 -6
- data/lib/inferno/config/boot/web.rb +2 -7
- data/lib/inferno/config/boot.rb +6 -1
- data/lib/inferno/dsl/assertions.rb +2 -2
- data/lib/inferno/dsl/configurable.rb +4 -4
- data/lib/inferno/dsl/fhir_client.rb +3 -2
- data/lib/inferno/dsl/fhir_client_builder.rb +2 -2
- data/lib/inferno/dsl/fhir_validation.rb +5 -6
- data/lib/inferno/dsl/http_client.rb +17 -18
- data/lib/inferno/dsl/http_client_builder.rb +4 -4
- data/lib/inferno/dsl/input_output_handling.rb +1 -1
- data/lib/inferno/dsl/request_storage.rb +2 -2
- data/lib/inferno/dsl/resume_test_route.rb +36 -34
- data/lib/inferno/dsl/runnable.rb +13 -10
- data/lib/inferno/entities/header.rb +7 -7
- data/lib/inferno/entities/request.rb +35 -36
- data/lib/inferno/entities/session_data.rb +6 -6
- data/lib/inferno/entities/test.rb +4 -4
- data/lib/inferno/entities/test_group.rb +2 -2
- data/lib/inferno/entities/test_run.rb +1 -1
- data/lib/inferno/jobs/execute_test_run.rb +1 -1
- data/lib/inferno/jobs/resume_test_run.rb +1 -1
- data/lib/inferno/public/bundle.js +15 -15
- data/lib/inferno/repositories/messages.rb +1 -1
- data/lib/inferno/repositories/repository.rb +1 -1
- data/lib/inferno/repositories/requests.rb +6 -6
- data/lib/inferno/repositories/results.rb +16 -16
- data/lib/inferno/repositories/session_data.rb +6 -6
- data/lib/inferno/repositories/test_runs.rb +6 -6
- data/lib/inferno/repositories/test_sessions.rb +7 -7
- data/lib/inferno/test_runner.rb +3 -3
- data/lib/inferno/utils/preset_template_generator.rb +1 -1
- data/lib/inferno/version.rb +1 -1
- data/spec/factories/test_run.rb +1 -1
- data/spec/factories/test_session.rb +1 -1
- data/spec/fixtures/basic_test_suite.rb +1 -0
- metadata +25 -24
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'hanami
|
1
|
+
require 'hanami/controller'
|
2
2
|
|
3
3
|
module Inferno
|
4
4
|
module DSL
|
@@ -6,44 +6,40 @@ module Inferno
|
|
6
6
|
# an incoming request.
|
7
7
|
# @private
|
8
8
|
# @see Inferno::DSL::Runnable#resume_test_route
|
9
|
-
class ResumeTestRoute
|
10
|
-
include Hanami::Action
|
9
|
+
class ResumeTestRoute < Hanami::Action
|
11
10
|
include Import[
|
12
|
-
requests_repo: 'repositories.requests',
|
13
|
-
results_repo: 'repositories.results',
|
14
|
-
test_runs_repo: 'repositories.test_runs',
|
15
|
-
tests_repo: 'repositories.tests'
|
11
|
+
requests_repo: 'inferno.repositories.requests',
|
12
|
+
results_repo: 'inferno.repositories.results',
|
13
|
+
test_runs_repo: 'inferno.repositories.test_runs',
|
14
|
+
tests_repo: 'inferno.repositories.tests'
|
16
15
|
]
|
17
16
|
|
18
|
-
def self.call(
|
19
|
-
new.call(
|
17
|
+
def self.call(...)
|
18
|
+
new.call(...)
|
20
19
|
end
|
21
20
|
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
def request
|
26
|
-
@request ||= Inferno::Entities::Request.from_rack_env(@params.env)
|
21
|
+
# @private
|
22
|
+
def test_run_identifier_block
|
23
|
+
self.class.singleton_class.instance_variable_get(:@test_run_identifier_block)
|
27
24
|
end
|
28
25
|
|
29
26
|
# @private
|
30
|
-
def
|
31
|
-
|
32
|
-
test_runs_repo.find_latest_waiting_by_identifier(test_run_identifier)
|
27
|
+
def find_test_run(test_run_identifier)
|
28
|
+
test_runs_repo.find_latest_waiting_by_identifier(test_run_identifier)
|
33
29
|
end
|
34
30
|
|
35
31
|
# @private
|
36
|
-
def
|
37
|
-
|
32
|
+
def find_waiting_result(test_run)
|
33
|
+
results_repo.find_waiting_result(test_run_id: test_run.id)
|
38
34
|
end
|
39
35
|
|
40
36
|
# @private
|
41
|
-
def update_result
|
37
|
+
def update_result(waiting_result)
|
42
38
|
results_repo.pass_waiting_result(waiting_result.id)
|
43
39
|
end
|
44
40
|
|
45
41
|
# @private
|
46
|
-
def persist_request
|
42
|
+
def persist_request(request, test_run, waiting_result, test)
|
47
43
|
requests_repo.create(
|
48
44
|
request.to_hash.merge(
|
49
45
|
test_session_id: test_run.test_session_id,
|
@@ -54,35 +50,41 @@ module Inferno
|
|
54
50
|
end
|
55
51
|
|
56
52
|
# @private
|
57
|
-
def redirect_route
|
58
|
-
"#{Application['base_url']}/test_sessions/#{test_run.test_session_id}##{resume_ui_at_id}"
|
53
|
+
def redirect_route(test_run, test)
|
54
|
+
"#{Application['base_url']}/test_sessions/#{test_run.test_session_id}##{resume_ui_at_id(test_run, test)}"
|
59
55
|
end
|
60
56
|
|
61
57
|
# @private
|
62
|
-
def
|
63
|
-
|
58
|
+
def find_test(waiting_result)
|
59
|
+
tests_repo.find(waiting_result.test_id)
|
64
60
|
end
|
65
61
|
|
66
62
|
# @private
|
67
|
-
def resume_ui_at_id
|
63
|
+
def resume_ui_at_id(test_run, test)
|
68
64
|
test_run.test_suite_id || test_run.test_group_id || test.parent.id
|
69
65
|
end
|
70
66
|
|
71
67
|
# @private
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
68
|
+
def handle(req, res)
|
69
|
+
request = Inferno::Entities::Request.from_hanami_request(req)
|
70
|
+
|
71
|
+
test_run_identifier = instance_exec(request, &test_run_identifier_block)
|
72
|
+
|
73
|
+
test_run = find_test_run(test_run_identifier)
|
74
|
+
|
75
|
+
halt 500, "Unable to find test run with identifier '#{test_run_identifier}'." if test_run.nil?
|
77
76
|
|
78
77
|
test_runs_repo.mark_as_no_longer_waiting(test_run.id)
|
79
78
|
|
80
|
-
|
81
|
-
|
79
|
+
waiting_result = find_waiting_result(test_run)
|
80
|
+
test = find_test(waiting_result)
|
81
|
+
|
82
|
+
update_result(waiting_result)
|
83
|
+
persist_request(request, test_run, waiting_result, test)
|
82
84
|
|
83
85
|
Jobs.perform(Jobs::ResumeTestRun, test_run.id)
|
84
86
|
|
85
|
-
redirect_to redirect_route
|
87
|
+
res.redirect_to redirect_route(test_run, test)
|
86
88
|
end
|
87
89
|
end
|
88
90
|
end
|
data/lib/inferno/dsl/runnable.rb
CHANGED
@@ -88,7 +88,7 @@ module Inferno
|
|
88
88
|
# alias the method name they wish to use to define child entities to this
|
89
89
|
# method.
|
90
90
|
# @private
|
91
|
-
def define_child(*args, &
|
91
|
+
def define_child(*args, &)
|
92
92
|
hash_args = process_args(args)
|
93
93
|
|
94
94
|
klass = create_child_class(hash_args)
|
@@ -99,7 +99,7 @@ module Inferno
|
|
99
99
|
|
100
100
|
configure_child_class(klass, hash_args)
|
101
101
|
|
102
|
-
handle_child_definition_block(klass, &
|
102
|
+
handle_child_definition_block(klass, &)
|
103
103
|
|
104
104
|
klass.add_self_to_repository
|
105
105
|
|
@@ -190,8 +190,8 @@ module Inferno
|
|
190
190
|
end
|
191
191
|
|
192
192
|
# @private
|
193
|
-
def handle_child_definition_block(klass, &
|
194
|
-
klass.class_eval(&
|
193
|
+
def handle_child_definition_block(klass, &)
|
194
|
+
klass.class_eval(&) if block_given?
|
195
195
|
end
|
196
196
|
|
197
197
|
# Set/Get a runnable's id
|
@@ -353,9 +353,8 @@ module Inferno
|
|
353
353
|
# {Inferno::Entities::Request} object with the information for the
|
354
354
|
# incoming request.
|
355
355
|
def resume_test_route(method, path, &block)
|
356
|
-
route_class = Class.new(ResumeTestRoute) do
|
357
|
-
|
358
|
-
define_method(:request_name, -> { options[:name] })
|
356
|
+
route_class = Class.new(ResumeTestRoute) do |klass|
|
357
|
+
klass.singleton_class.instance_variable_set(:@test_run_identifier_block, block)
|
359
358
|
end
|
360
359
|
|
361
360
|
route(method, path, route_class)
|
@@ -375,14 +374,18 @@ module Inferno
|
|
375
374
|
# app](http://sinatrarb.com/)) as described in the [Hanami Router
|
376
375
|
# documentation.](https://github.com/hanami/router/tree/f41001d4c3ee9e2d2c7bb142f74b43f8e1d3a265#mount-rack-applications)
|
377
376
|
def route(method, path, handler)
|
378
|
-
Inferno.routes << { method
|
377
|
+
Inferno.routes << { method:, path:, handler:, suite: }
|
379
378
|
end
|
380
379
|
|
381
380
|
# @private
|
382
381
|
def test_count(selected_suite_options = [])
|
383
382
|
@test_counts ||= {}
|
384
383
|
|
385
|
-
|
384
|
+
options_json = selected_suite_options.to_json
|
385
|
+
|
386
|
+
return @test_counts[options_json] if @test_counts[options_json]
|
387
|
+
|
388
|
+
@test_counts[options_json] =
|
386
389
|
children(selected_suite_options)
|
387
390
|
&.reduce(0) { |sum, child| sum + child.test_count(selected_suite_options) } || 0
|
388
391
|
end
|
@@ -397,7 +400,7 @@ module Inferno
|
|
397
400
|
def required_suite_options(suite_option_requirements)
|
398
401
|
@suite_option_requirements =
|
399
402
|
suite_option_requirements.map do |key, value|
|
400
|
-
DSL::SuiteOption.new(id: key, value:
|
403
|
+
DSL::SuiteOption.new(id: key, value:)
|
401
404
|
end
|
402
405
|
end
|
403
406
|
|
@@ -35,13 +35,13 @@ module Inferno
|
|
35
35
|
|
36
36
|
def to_hash
|
37
37
|
{
|
38
|
-
id
|
39
|
-
request_id
|
40
|
-
type
|
41
|
-
name
|
42
|
-
value
|
43
|
-
created_at
|
44
|
-
updated_at:
|
38
|
+
id:,
|
39
|
+
request_id:,
|
40
|
+
type:,
|
41
|
+
name:,
|
42
|
+
value:,
|
43
|
+
created_at:,
|
44
|
+
updated_at:
|
45
45
|
}.compact
|
46
46
|
end
|
47
47
|
end
|
@@ -89,8 +89,8 @@ module Inferno
|
|
89
89
|
# @return [Hash]
|
90
90
|
def request
|
91
91
|
{
|
92
|
-
verb
|
93
|
-
url
|
92
|
+
verb:,
|
93
|
+
url:,
|
94
94
|
headers: request_headers,
|
95
95
|
body: request_body
|
96
96
|
}
|
@@ -101,7 +101,7 @@ module Inferno
|
|
101
101
|
# @return [Hash]
|
102
102
|
def response
|
103
103
|
{
|
104
|
-
status
|
104
|
+
status:,
|
105
105
|
headers: response_headers,
|
106
106
|
body: response_body
|
107
107
|
}
|
@@ -110,20 +110,20 @@ module Inferno
|
|
110
110
|
# @private
|
111
111
|
def to_hash
|
112
112
|
{
|
113
|
-
id
|
114
|
-
verb
|
115
|
-
url
|
116
|
-
direction
|
117
|
-
status
|
118
|
-
name
|
119
|
-
request_body
|
120
|
-
response_body
|
121
|
-
result_id
|
122
|
-
test_session_id
|
113
|
+
id:,
|
114
|
+
verb:,
|
115
|
+
url:,
|
116
|
+
direction:,
|
117
|
+
status:,
|
118
|
+
name:,
|
119
|
+
request_body:,
|
120
|
+
response_body:,
|
121
|
+
result_id:,
|
122
|
+
test_session_id:,
|
123
123
|
request_headers: request_headers.map(&:to_hash),
|
124
124
|
response_headers: response_headers.map(&:to_hash),
|
125
|
-
created_at
|
126
|
-
updated_at:
|
125
|
+
created_at:,
|
126
|
+
updated_at:
|
127
127
|
}.compact
|
128
128
|
end
|
129
129
|
|
@@ -136,22 +136,21 @@ module Inferno
|
|
136
136
|
|
137
137
|
class << self
|
138
138
|
# @private
|
139
|
-
def
|
140
|
-
|
141
|
-
url
|
142
|
-
url += "?#{rack_request.query_string}" if rack_request.query_string.present?
|
139
|
+
def from_hanami_request(request, name: nil)
|
140
|
+
url = "#{request.base_url}#{request.path}"
|
141
|
+
url += "?#{request.query_string}" if request.query_string.present?
|
143
142
|
request_headers =
|
144
|
-
env
|
143
|
+
request.params.env
|
145
144
|
.select { |key, _| key.start_with? 'HTTP_' }
|
146
145
|
.transform_keys { |key| key.delete_prefix('HTTP_').tr('_', '-').downcase }
|
147
|
-
.map { |header_name, value| Header.new(name: header_name, value
|
146
|
+
.map { |header_name, value| Header.new(name: header_name, value:, type: 'request') }
|
148
147
|
|
149
148
|
new(
|
150
|
-
verb:
|
151
|
-
url
|
149
|
+
verb: request.request_method.downcase,
|
150
|
+
url:,
|
152
151
|
direction: 'incoming',
|
153
|
-
name
|
154
|
-
request_body:
|
152
|
+
name:,
|
153
|
+
request_body: request.body.string,
|
155
154
|
headers: request_headers
|
156
155
|
)
|
157
156
|
end
|
@@ -160,20 +159,20 @@ module Inferno
|
|
160
159
|
def from_http_response(response, test_session_id:, direction: 'outgoing', name: nil)
|
161
160
|
request_headers =
|
162
161
|
response.env.request_headers
|
163
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
162
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') }
|
164
163
|
response_headers =
|
165
164
|
response.headers
|
166
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
165
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') }
|
167
166
|
|
168
167
|
new(
|
169
168
|
verb: response.env.method,
|
170
169
|
url: response.env.url.to_s,
|
171
|
-
direction
|
172
|
-
name
|
170
|
+
direction:,
|
171
|
+
name:,
|
173
172
|
status: response.status,
|
174
173
|
request_body: response.env.request_body,
|
175
174
|
response_body: response.body,
|
176
|
-
test_session_id
|
175
|
+
test_session_id:,
|
177
176
|
headers: request_headers + response_headers
|
178
177
|
)
|
179
178
|
end
|
@@ -183,9 +182,9 @@ module Inferno
|
|
183
182
|
request = reply.request
|
184
183
|
response = reply.response
|
185
184
|
request_headers = request[:headers]
|
186
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
185
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'request') }
|
187
186
|
response_headers = response[:headers]
|
188
|
-
.map { |header_name, value| Header.new(name: header_name.downcase, value
|
187
|
+
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') }
|
189
188
|
request_body =
|
190
189
|
if request.dig(:headers, 'Content-Type')&.include?('application/x-www-form-urlencoded')
|
191
190
|
URI.encode_www_form(request[:payload])
|
@@ -196,12 +195,12 @@ module Inferno
|
|
196
195
|
new(
|
197
196
|
verb: request[:method],
|
198
197
|
url: request[:url],
|
199
|
-
direction
|
200
|
-
name
|
198
|
+
direction:,
|
199
|
+
name:,
|
201
200
|
status: response[:code].to_i,
|
202
|
-
request_body
|
201
|
+
request_body:,
|
203
202
|
response_body: response[:body],
|
204
|
-
test_session_id
|
203
|
+
test_session_id:,
|
205
204
|
headers: request_headers + response_headers
|
206
205
|
)
|
207
206
|
end
|
@@ -26,12 +26,12 @@ module Inferno
|
|
26
26
|
|
27
27
|
def to_hash
|
28
28
|
{
|
29
|
-
id
|
30
|
-
name
|
31
|
-
value
|
32
|
-
test_session_id
|
33
|
-
created_at
|
34
|
-
updated_at:
|
29
|
+
id:,
|
30
|
+
name:,
|
31
|
+
value:,
|
32
|
+
test_session_id:,
|
33
|
+
created_at:,
|
34
|
+
updated_at:
|
35
35
|
}
|
36
36
|
end
|
37
37
|
end
|
@@ -104,10 +104,10 @@ module Inferno
|
|
104
104
|
end
|
105
105
|
|
106
106
|
# @private
|
107
|
-
def method_missing(name, *args, &
|
107
|
+
def method_missing(name, *args, &)
|
108
108
|
parent_instance = self.class.parent&.new
|
109
109
|
if parent_instance.respond_to?(name)
|
110
|
-
parent_instance.send(name, *args, &
|
110
|
+
parent_instance.send(name, *args, &)
|
111
111
|
else
|
112
112
|
super
|
113
113
|
end
|
@@ -204,10 +204,10 @@ module Inferno
|
|
204
204
|
end
|
205
205
|
|
206
206
|
# @private
|
207
|
-
def method_missing(name, *args, &
|
207
|
+
def method_missing(name, *args, &)
|
208
208
|
parent_instance = parent&.new
|
209
209
|
if parent_instance.respond_to?(name)
|
210
|
-
parent_instance.send(name, *args, &
|
210
|
+
parent_instance.send(name, *args, &)
|
211
211
|
else
|
212
212
|
super
|
213
213
|
end
|
@@ -13,10 +13,10 @@ module Inferno
|
|
13
13
|
|
14
14
|
def_delegators 'self.class', :title, :id, :groups, :inputs, :outputs, :tests
|
15
15
|
|
16
|
-
def method_missing(name, *args, &
|
16
|
+
def method_missing(name, *args, &)
|
17
17
|
parent_instance = self.class.parent&.new
|
18
18
|
if parent_instance.respond_to?(name)
|
19
|
-
parent_instance.send(name, *args, &
|
19
|
+
parent_instance.send(name, *args, &)
|
20
20
|
else
|
21
21
|
super
|
22
22
|
end
|
@@ -7,7 +7,7 @@ module Inferno
|
|
7
7
|
test_run = Inferno::Repositories::TestRuns.new.find(test_run_id)
|
8
8
|
test_session = Inferno::Repositories::TestSessions.new.find(test_run.test_session_id)
|
9
9
|
|
10
|
-
TestRunner.new(test_session
|
10
|
+
TestRunner.new(test_session:, test_run:).start
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -7,7 +7,7 @@ module Inferno
|
|
7
7
|
test_run = Inferno::Repositories::TestRuns.new.find(test_run_id)
|
8
8
|
test_session = Inferno::Repositories::TestSessions.new.find(test_run.test_session_id)
|
9
9
|
|
10
|
-
TestRunner.new(test_session
|
10
|
+
TestRunner.new(test_session:, test_run:, resume: true).start
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|