inferno_core 0.4.22 → 0.4.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inferno/apps/cli/services.rb +1 -1
- data/lib/inferno/config/boot/validator.rb +19 -0
- data/lib/inferno/db/migrations/009_add_request_tags.rb +18 -0
- data/lib/inferno/db/schema.rb +19 -0
- data/lib/inferno/dsl/fhir_client.rb +50 -24
- data/lib/inferno/dsl/fhir_resource_validation.rb +299 -0
- data/lib/inferno/dsl/http_client.rb +12 -8
- data/lib/inferno/dsl/request_storage.rb +15 -3
- data/lib/inferno/dsl/resume_test_route.rb +7 -1
- data/lib/inferno/dsl/runnable.rb +4 -2
- data/lib/inferno/dsl.rb +3 -1
- data/lib/inferno/entities/request.rb +23 -7
- data/lib/inferno/entities/test_suite.rb +1 -0
- data/lib/inferno/jobs/invoke_validator_session.rb +23 -0
- data/lib/inferno/jobs.rb +1 -0
- data/lib/inferno/public/bundle.js +1 -1
- data/lib/inferno/repositories/requests.rb +98 -12
- data/lib/inferno/repositories/tags.rb +18 -0
- data/lib/inferno/version.rb +1 -1
- data/spec/factories/request.rb +2 -0
- metadata +7 -2
@@ -1,19 +1,19 @@
|
|
1
1
|
module Inferno
|
2
2
|
module Repositories
|
3
3
|
class Requests < Repository
|
4
|
-
include Import[
|
4
|
+
include Import[
|
5
|
+
headers_repo: 'inferno.repositories.headers',
|
6
|
+
tags_repo: 'inferno.repositories.tags'
|
7
|
+
]
|
5
8
|
|
6
9
|
def create(params)
|
7
10
|
request = self.class::Model.create(db_params(params))
|
8
11
|
|
9
|
-
|
10
|
-
request.add_header(header.merge(request_id: request.index, type: 'request'))
|
11
|
-
end
|
12
|
-
response_headers = (params[:response_headers] || []).map do |header|
|
13
|
-
request.add_header(header.merge(request_id: request.index, type: 'response'))
|
14
|
-
end
|
12
|
+
headers = create_headers(request, params)
|
15
13
|
|
16
|
-
|
14
|
+
params[:tags]&.each do |tag|
|
15
|
+
request.add_tag(tag)
|
16
|
+
end
|
17
17
|
|
18
18
|
build_entity(
|
19
19
|
request.to_hash
|
@@ -22,6 +22,17 @@ module Inferno
|
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
25
|
+
def create_headers(request, params)
|
26
|
+
request_headers = (params[:request_headers] || []).map do |header|
|
27
|
+
request.add_header(header.merge(request_id: request.index, type: 'request'))
|
28
|
+
end
|
29
|
+
response_headers = (params[:response_headers] || []).map do |header|
|
30
|
+
request.add_header(header.merge(request_id: request.index, type: 'response'))
|
31
|
+
end
|
32
|
+
|
33
|
+
(request_headers + response_headers).map { |header| headers_repo.build_entity(header.to_hash) }
|
34
|
+
end
|
35
|
+
|
25
36
|
def find(id)
|
26
37
|
result =
|
27
38
|
self.class::Model
|
@@ -56,6 +67,19 @@ module Inferno
|
|
56
67
|
build_entity(result)
|
57
68
|
end
|
58
69
|
|
70
|
+
def tagged_requests(test_session_id, tags)
|
71
|
+
self.class::Model
|
72
|
+
.tagged_requests(test_session_id, tags)
|
73
|
+
.to_a
|
74
|
+
.map! do |request|
|
75
|
+
build_entity(
|
76
|
+
request
|
77
|
+
.to_json_data(json_serializer_options)
|
78
|
+
.deep_symbolize_keys!
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
59
83
|
def requests_for_result(result_id)
|
60
84
|
self.class::Model
|
61
85
|
.order(:index)
|
@@ -68,14 +92,25 @@ module Inferno
|
|
68
92
|
|
69
93
|
def json_serializer_options
|
70
94
|
{
|
71
|
-
include: :headers
|
95
|
+
include: [:headers, :tags]
|
72
96
|
}
|
73
97
|
end
|
74
98
|
|
75
99
|
class Model < Sequel::Model(db)
|
76
|
-
many_to_many :result,
|
77
|
-
|
78
|
-
|
100
|
+
many_to_many :result,
|
101
|
+
class: 'Inferno::Repositories::Results::Model',
|
102
|
+
join_table: :requests_results,
|
103
|
+
left_key: :request_id,
|
104
|
+
right_key: :result_id
|
105
|
+
many_to_many :tags,
|
106
|
+
class: 'Inferno::Repositories::Tags::Model',
|
107
|
+
join_table: :requests_tags,
|
108
|
+
left_key: :requests_id,
|
109
|
+
right_key: :tags_id,
|
110
|
+
adder: :add_tag
|
111
|
+
one_to_many :headers,
|
112
|
+
class: 'Inferno::Repositories::Headers::Model',
|
113
|
+
key: :request_id
|
79
114
|
|
80
115
|
def before_create
|
81
116
|
self.id = SecureRandom.uuid
|
@@ -84,6 +119,57 @@ module Inferno
|
|
84
119
|
self.updated_at ||= time
|
85
120
|
super
|
86
121
|
end
|
122
|
+
|
123
|
+
def add_tag(tag_name)
|
124
|
+
tag = Tags::Model.find_or_create(name: tag_name)
|
125
|
+
|
126
|
+
Inferno::Application['db.connection'][:requests_tags].insert(
|
127
|
+
tags_id: tag.id,
|
128
|
+
requests_id: index
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.tagged_requests_sql
|
133
|
+
# Find all the requests for the current session which:
|
134
|
+
# - match all supplied tags
|
135
|
+
# - are the from the most recent test run for each runnable
|
136
|
+
<<~SQL.gsub(/\s+/, ' ').freeze
|
137
|
+
select final_requests.*
|
138
|
+
from (
|
139
|
+
select uncounted_requests.request_id request_id
|
140
|
+
from (
|
141
|
+
select r.id request_id, t.id tag_id from requests r
|
142
|
+
inner join requests_tags rt on r.`index` = rt.requests_id
|
143
|
+
inner join tags t on rt.tags_id = t.id
|
144
|
+
where r.test_session_id = :test_session_id
|
145
|
+
and r.result_id in (
|
146
|
+
SELECT a.id FROM results a
|
147
|
+
WHERE a.test_session_id = r.test_session_id
|
148
|
+
AND a.id IN (
|
149
|
+
SELECT id
|
150
|
+
FROM results b
|
151
|
+
WHERE (b.test_session_id = a.test_session_id AND b.test_id = a.test_id) OR
|
152
|
+
(b.test_session_id = a.test_session_id AND b.test_group_id = a.test_group_id) OR
|
153
|
+
(b.test_session_id = a.test_session_id AND b.test_suite_id = a.test_suite_id)
|
154
|
+
ORDER BY updated_at DESC
|
155
|
+
LIMIT 1
|
156
|
+
)
|
157
|
+
)
|
158
|
+
and t.name in :tags
|
159
|
+
group by r.id, t.id
|
160
|
+
) as uncounted_requests
|
161
|
+
group by uncounted_requests.request_id
|
162
|
+
having count(*) = :tag_count
|
163
|
+
) as matched_requests
|
164
|
+
inner join requests final_requests on final_requests.id = matched_requests.request_id
|
165
|
+
where final_requests.test_session_id = :test_session_id
|
166
|
+
order by final_requests.`index`
|
167
|
+
SQL
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.tagged_requests(test_session_id, tags)
|
171
|
+
fetch(tagged_requests_sql, test_session_id:, tags:, tag_count: tags.length)
|
172
|
+
end
|
87
173
|
end
|
88
174
|
end
|
89
175
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Inferno
|
2
|
+
module Repositories
|
3
|
+
class Tags < Repository
|
4
|
+
class Model < Sequel::Model(db)
|
5
|
+
many_to_many :requests,
|
6
|
+
class: 'Inferno::Repositories::Requests::Model',
|
7
|
+
join_table: :requests_tags,
|
8
|
+
left_key: :tags_id,
|
9
|
+
right_key: :requests_id
|
10
|
+
|
11
|
+
def before_create
|
12
|
+
self.id = SecureRandom.uuid
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/inferno/version.rb
CHANGED
data/spec/factories/request.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.23
|
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: 2023-
|
13
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -577,6 +577,7 @@ files:
|
|
577
577
|
- lib/inferno/config/boot/presets.rb
|
578
578
|
- lib/inferno/config/boot/sidekiq.rb
|
579
579
|
- lib/inferno/config/boot/suites.rb
|
580
|
+
- lib/inferno/config/boot/validator.rb
|
580
581
|
- lib/inferno/config/boot/web.rb
|
581
582
|
- lib/inferno/db/migrations/001_create_initial_structure.rb
|
582
583
|
- lib/inferno/db/migrations/002_add_wait_support.rb
|
@@ -586,12 +587,14 @@ files:
|
|
586
587
|
- lib/inferno/db/migrations/006_remove_unused_tables.rb
|
587
588
|
- lib/inferno/db/migrations/007_add_suite_options.rb
|
588
589
|
- lib/inferno/db/migrations/008_remove_timestamps.rb
|
590
|
+
- lib/inferno/db/migrations/009_add_request_tags.rb
|
589
591
|
- lib/inferno/db/schema.rb
|
590
592
|
- lib/inferno/dsl.rb
|
591
593
|
- lib/inferno/dsl/assertions.rb
|
592
594
|
- lib/inferno/dsl/configurable.rb
|
593
595
|
- lib/inferno/dsl/fhir_client.rb
|
594
596
|
- lib/inferno/dsl/fhir_client_builder.rb
|
597
|
+
- lib/inferno/dsl/fhir_resource_validation.rb
|
595
598
|
- lib/inferno/dsl/fhir_validation.rb
|
596
599
|
- lib/inferno/dsl/http_client.rb
|
597
600
|
- lib/inferno/dsl/http_client_builder.rb
|
@@ -624,6 +627,7 @@ files:
|
|
624
627
|
- lib/inferno/ext/fhir_models.rb
|
625
628
|
- lib/inferno/jobs.rb
|
626
629
|
- lib/inferno/jobs/execute_test_run.rb
|
630
|
+
- lib/inferno/jobs/invoke_validator_session.rb
|
627
631
|
- lib/inferno/jobs/resume_test_run.rb
|
628
632
|
- lib/inferno/public/0e0b993fd6ff351f435ff1c2938daf2d.png
|
629
633
|
- lib/inferno/public/217.bundle.js
|
@@ -642,6 +646,7 @@ files:
|
|
642
646
|
- lib/inferno/repositories/requests.rb
|
643
647
|
- lib/inferno/repositories/results.rb
|
644
648
|
- lib/inferno/repositories/session_data.rb
|
649
|
+
- lib/inferno/repositories/tags.rb
|
645
650
|
- lib/inferno/repositories/test_groups.rb
|
646
651
|
- lib/inferno/repositories/test_runs.rb
|
647
652
|
- lib/inferno/repositories/test_sessions.rb
|