inferno_core 0.0.5 → 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.
- checksums.yaml +4 -4
- data/lib/inferno/apps/web/controllers/test_runs/create.rb +15 -2
- data/lib/inferno/apps/web/serializers/hash_value_extractor.rb +11 -0
- data/lib/inferno/apps/web/serializers/test.rb +3 -4
- data/lib/inferno/apps/web/serializers/test_group.rb +4 -6
- data/lib/inferno/config/application.rb +1 -0
- data/lib/inferno/config/boot/suites.rb +4 -6
- data/lib/inferno/dsl/assertions.rb +20 -0
- data/lib/inferno/dsl/configurable.rb +126 -0
- data/lib/inferno/dsl/fhir_client.rb +4 -2
- data/lib/inferno/dsl/http_client.rb +10 -8
- data/lib/inferno/dsl/request_storage.rb +21 -12
- data/lib/inferno/dsl/resume_test_route.rb +1 -1
- data/lib/inferno/dsl/runnable.rb +69 -21
- data/lib/inferno/entities/request.rb +2 -2
- data/lib/inferno/entities/test.rb +16 -2
- data/lib/inferno/entities/test_group.rb +8 -0
- data/lib/inferno/exceptions.rb +12 -0
- data/lib/inferno/public/bundle.js +1 -1
- data/lib/inferno/repositories/test_runs.rb +15 -0
- data/lib/inferno/test_runner.rb +20 -18
- data/lib/inferno/utils/markdown_formatter.rb +15 -0
- data/lib/inferno/version.rb +1 -1
- data/spec/factories/request.rb +14 -7
- metadata +5 -2
@@ -13,6 +13,14 @@ module Inferno
|
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
16
|
+
def build_entity(params)
|
17
|
+
super.tap do |test_run|
|
18
|
+
test_run&.results&.map! do |result|
|
19
|
+
result.is_a?(Entities::Result) ? result : Entities::Result.new(result)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
16
24
|
def results_for_test_run(test_run_id)
|
17
25
|
test_run_hash =
|
18
26
|
self.class::Model
|
@@ -107,6 +115,13 @@ module Inferno
|
|
107
115
|
super
|
108
116
|
end
|
109
117
|
end
|
118
|
+
|
119
|
+
def active_test_run_for_session?(test_session_id)
|
120
|
+
self.class::Model
|
121
|
+
.where(test_session_id: test_session_id)
|
122
|
+
.exclude(status: 'done')
|
123
|
+
.count.positive?
|
124
|
+
end
|
110
125
|
end
|
111
126
|
end
|
112
127
|
end
|
data/lib/inferno/test_runner.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require_relative './utils/markdown_formatter'
|
2
|
+
|
1
3
|
module Inferno
|
2
4
|
# @api private
|
3
5
|
class TestRunner
|
6
|
+
include Inferno::Utils::MarkdownFormatter
|
4
7
|
attr_reader :test_session, :test_run, :resuming
|
5
8
|
|
6
9
|
def initialize(test_session:, test_run:, resume: false)
|
@@ -35,13 +38,13 @@ module Inferno
|
|
35
38
|
run_results.values
|
36
39
|
end
|
37
40
|
|
38
|
-
def run(runnable)
|
41
|
+
def run(runnable, scratch = {})
|
39
42
|
if runnable < Entities::Test
|
40
|
-
return existing_test_result(runnable) || run_test(runnable) if resuming
|
43
|
+
return existing_test_result(runnable) || run_test(runnable, scratch) if resuming
|
41
44
|
|
42
|
-
run_test(runnable)
|
45
|
+
run_test(runnable, scratch)
|
43
46
|
else
|
44
|
-
run_group(runnable)
|
47
|
+
run_group(runnable, scratch)
|
45
48
|
end
|
46
49
|
end
|
47
50
|
|
@@ -49,22 +52,22 @@ module Inferno
|
|
49
52
|
results_repo.result_for_test_run(runnable.reference_hash.merge(test_run_id: test_run.id))
|
50
53
|
end
|
51
54
|
|
52
|
-
def run_test(test)
|
55
|
+
def run_test(test, scratch)
|
53
56
|
inputs = load_inputs(test)
|
54
57
|
|
55
58
|
input_json_string = JSON.generate(inputs)
|
56
|
-
test_instance = test.new(inputs: inputs, test_session_id: test_session.id)
|
59
|
+
test_instance = test.new(inputs: inputs, test_session_id: test_session.id, scratch: scratch)
|
57
60
|
|
58
61
|
result = begin
|
59
62
|
test_instance.load_named_requests
|
60
63
|
test_instance.instance_eval(&test.block)
|
61
64
|
'pass'
|
62
65
|
rescue Exceptions::TestResultException => e
|
63
|
-
test_instance.result_message = e.message
|
66
|
+
test_instance.result_message = format_markdown(e.message)
|
64
67
|
e.result
|
65
68
|
rescue StandardError => e
|
66
69
|
Application['logger'].error(e.full_message)
|
67
|
-
test_instance.result_message = "Error: #{e.message}"
|
70
|
+
test_instance.result_message = format_markdown("Error: #{e.message}\n\n#{e.backtrace.first}")
|
68
71
|
'error'
|
69
72
|
end
|
70
73
|
|
@@ -95,10 +98,10 @@ module Inferno
|
|
95
98
|
test_result
|
96
99
|
end
|
97
100
|
|
98
|
-
def run_group(group)
|
101
|
+
def run_group(group, scratch)
|
99
102
|
results = []
|
100
103
|
group.children.each do |child|
|
101
|
-
result = run(child)
|
104
|
+
result = run(child, scratch)
|
102
105
|
results << result
|
103
106
|
break if results.last.waiting?
|
104
107
|
end
|
@@ -132,26 +135,25 @@ module Inferno
|
|
132
135
|
end
|
133
136
|
|
134
137
|
def load_inputs(runnable)
|
135
|
-
runnable.inputs.each_with_object({}) do |
|
136
|
-
|
137
|
-
input_hash[
|
138
|
+
runnable.inputs.each_with_object({}) do |input_identifier, input_hash|
|
139
|
+
input_alias = runnable.config.input_name(input_identifier)
|
140
|
+
input_hash[input_identifier] = session_data_repo.load(test_session_id: test_session.id, name: input_alias)
|
138
141
|
end
|
139
142
|
end
|
140
143
|
|
141
144
|
def save_outputs(runnable_instance)
|
142
145
|
outputs =
|
143
|
-
runnable_instance.
|
146
|
+
runnable_instance.outputs_to_persist.map do |output_identifier, value|
|
144
147
|
{
|
145
|
-
name: output_name,
|
146
|
-
value:
|
148
|
+
name: runnable_instance.class.config.output_name(output_identifier),
|
149
|
+
value: value
|
147
150
|
}
|
148
151
|
end
|
152
|
+
|
149
153
|
outputs.compact!
|
150
154
|
outputs.each do |output|
|
151
155
|
session_data_repo.save(output.merge(test_session_id: test_session.id))
|
152
156
|
end
|
153
|
-
|
154
|
-
outputs
|
155
157
|
end
|
156
158
|
|
157
159
|
def persist_result(params)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Inferno
|
2
|
+
module Utils
|
3
|
+
# @api private
|
4
|
+
module MarkdownFormatter
|
5
|
+
def format_markdown(markdown) # rubocop:disable Metrics/CyclomaticComplexity
|
6
|
+
lines = markdown.lines
|
7
|
+
|
8
|
+
return markdown if lines.any? { |line| line.match?(/^\S/) }
|
9
|
+
|
10
|
+
natural_indent = lines.collect { |l| l.index(/[^ ]/) }.select { |l| !l.nil? && l.positive? }.min || 0
|
11
|
+
markdown.lines.map { |l| l[natural_indent..] || "\n" }.join
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/inferno/version.rb
CHANGED
data/spec/factories/request.rb
CHANGED
@@ -12,6 +12,20 @@ FactoryBot.define do
|
|
12
12
|
name { nil }
|
13
13
|
status { 200 }
|
14
14
|
direction { 'outgoing' }
|
15
|
+
headers do
|
16
|
+
[
|
17
|
+
{
|
18
|
+
type: 'request',
|
19
|
+
name: 'Request-Header',
|
20
|
+
value: 'REQUEST HEADER VALUE'
|
21
|
+
},
|
22
|
+
{
|
23
|
+
type: 'response',
|
24
|
+
name: 'Response-Header',
|
25
|
+
value: 'RESPONSE HEADER VALUE'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
end
|
15
29
|
|
16
30
|
request_body { nil }
|
17
31
|
|
@@ -24,12 +38,5 @@ FactoryBot.define do
|
|
24
38
|
to_create do |instance|
|
25
39
|
Inferno::Repositories::Requests.new.create(instance.to_hash)
|
26
40
|
end
|
27
|
-
|
28
|
-
after(:create) do |instance, evaluator|
|
29
|
-
instance.instance_variable_set(
|
30
|
-
:@headers,
|
31
|
-
repo_create_list(:header, evaluator.header_count, request_id: instance.index)
|
32
|
-
)
|
33
|
-
end
|
34
41
|
end
|
35
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inferno_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen MacVicar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-10-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -445,6 +445,7 @@ files:
|
|
445
445
|
- lib/inferno/apps/web/controllers/test_suites/show.rb
|
446
446
|
- lib/inferno/apps/web/index.html.erb
|
447
447
|
- lib/inferno/apps/web/router.rb
|
448
|
+
- lib/inferno/apps/web/serializers/hash_value_extractor.rb
|
448
449
|
- lib/inferno/apps/web/serializers/header.rb
|
449
450
|
- lib/inferno/apps/web/serializers/input.rb
|
450
451
|
- lib/inferno/apps/web/serializers/message.rb
|
@@ -472,6 +473,7 @@ files:
|
|
472
473
|
- lib/inferno/db/schema.rb
|
473
474
|
- lib/inferno/dsl.rb
|
474
475
|
- lib/inferno/dsl/assertions.rb
|
476
|
+
- lib/inferno/dsl/configurable.rb
|
475
477
|
- lib/inferno/dsl/fhir_client.rb
|
476
478
|
- lib/inferno/dsl/fhir_client_builder.rb
|
477
479
|
- lib/inferno/dsl/fhir_validation.rb
|
@@ -522,6 +524,7 @@ files:
|
|
522
524
|
- lib/inferno/repositories/validate_runnable_reference.rb
|
523
525
|
- lib/inferno/spec_support.rb
|
524
526
|
- lib/inferno/test_runner.rb
|
527
|
+
- lib/inferno/utils/markdown_formatter.rb
|
525
528
|
- lib/inferno/utils/middleware/request_logger.rb
|
526
529
|
- lib/inferno/version.rb
|
527
530
|
- spec/factories/header.rb
|