-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend job to start up sessions on HL7 validator wrapper (#406)
* FI-2234: starting point for a backend job that starts a validator session * FI-2234: migrate job to start via boot process * FI-2234: rework job to call Validator directly, DRY * Fix variable in error message * Add custom dockerfile for fhir_resource_validator to load SSL certs * Inherit dockerfile CMD from parent, don't just copy&paste it
- Loading branch information
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM markiantorno/validator-wrapper | ||
|
||
USER root | ||
# Java certs need to be installed as root, so switch to that user for this step only | ||
# (the image does not contain 'sudo') | ||
RUN wget https://gitlab.mitre.org/mitre-scripts/mitre-pki/-/raw/master/tool_scripts/install_certs.sh -O - | MODE=java sh | ||
|
||
USER $APPLICATION_USER | ||
|
||
# CMD is inherited from parent image as long as we don't override it or ENTRYPOINT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Inferno::Application.boot(:validator) do | ||
init do | ||
use :suites | ||
|
||
# This process should only run once, to start one job per validator, | ||
# so skipping it on workers will start it only once from the "web" process | ||
next if Sidekiq.server? | ||
|
||
Inferno::Repositories::TestSuites.new.all.each do |suite| | ||
suite.fhir_validators.each do |name, validators| | ||
validators.each_with_index do |validator, index| | ||
if validator.is_a? Inferno::DSL::FHIRResourceValidation::Validator | ||
Inferno::Jobs.perform(Inferno::Jobs::InvokeValidatorSession, suite.id, name.to_s, index) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Inferno | ||
module Jobs | ||
class InvokeValidatorSession | ||
include Sidekiq::Worker | ||
|
||
def perform(suite_id, validator_name, validator_index) | ||
suite = Inferno::Repositories::TestSuites.new.find suite_id | ||
validator = suite.fhir_validators[validator_name.to_sym][validator_index] | ||
|
||
response_body = validator.validate(FHIR::Patient.new, 'http://hl7.org/fhir/StructureDefinition/Patient') | ||
|
||
if response_body.start_with? '{' | ||
res = JSON.parse(response_body) | ||
session_id = res['sessionId'] | ||
# TODO: (FI-2311) store this session ID so it can be referenced as needed | ||
validator.session_id = session_id | ||
else | ||
Inferno::Application['logger'].error("InvokeValidatorSession - error from validator: #{response_body}") | ||
end | ||
end | ||
end | ||
end | ||
end |