Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI-3518/FI-3519: Add basic Bulk Data client test suite, groups, and tests #36

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/bulk_data_test_kit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
require_relative 'inferno_requirements_tools/ext/inferno_core/runnable'
require_relative 'bulk_data_test_kit/v1.0.1/bulk_data_test_suite'
require_relative 'bulk_data_test_kit/v2.0.0/bulk_data_test_suite'
require_relative 'bulk_data_test_kit/v2.0.0/client/bulk_data_client_test_suite'
2 changes: 1 addition & 1 deletion lib/bulk_data_test_kit/v1.0.1/bulk_data_test_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module BulkDataTestKit
module BulkDataV101
class BulkDataTestSuite < Inferno::TestSuite
title 'Bulk Data Access v1.0.1'
title 'Bulk Data Access v1.0.1 Server'
version VERSION
id :bulk_data_v101
links [
Expand Down
2 changes: 1 addition & 1 deletion lib/bulk_data_test_kit/v2.0.0/bulk_data_test_suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module BulkDataTestKit
module BulkDataV200
class BulkDataTestSuite < Inferno::TestSuite
title 'Bulk Data Access v2.0.0'
title 'Bulk Data Access v2.0.0 Server'
version VERSION
id :bulk_data_v200
links [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# frozen_string_literal: true

require_relative '../../version'

require_relative './endpoints/delete'
emichaud998 marked this conversation as resolved.
Show resolved Hide resolved
require_relative './endpoints/kick_off'
require_relative './endpoints/output'
require_relative './endpoints/status'

require_relative './groups/export'
require_relative './groups/delete'

module BulkDataTestKit
module BulkDataV200
module Client
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is something that should be changed, but I am thinking to be consistent with the rest of the bulk data test suites, there is no need to add the Client module here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to separate out the client tests in some way, right? Do you mean move Client up one level e.g. have a module BulkDataV200Client?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sorry that is what I meant, so rather than have a client module under the BulkDataV200 module, combine them so it is something like module BulkDataV200Client. Again not sure if this is a necessary change, I was just looking at the rest of the Bulk Data test kit and saw that the server tests do not have a server module.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense, I've made this change.

# Bulk Data Access v2.0.0 Client Test Suite
class BulkDataClientTestSuite < Inferno::TestSuite
include URLs

title 'Bulk Data Access v2.0.0 Client'

description File.read(File.join(__dir__, 'docs', 'suite_description.md'))

version VERSION

id :bulk_data_v200_client

links [
{
label: 'Report Issue',
url: 'https://github.com/inferno-framework/bulk-data-test-kit/issues/'
},
{
label: 'Open Source',
url: 'https://github.com/inferno-framework/bulk-data-test-kit/'
},
{
label: 'Download',
url: 'https://github.com/inferno-framework/bulk-data-test-kit/releases'
},
{
label: 'Implementation Guide',
url: 'https://hl7.org/fhir/uv/bulkdata/STU2/'
}
]

suite_endpoint :get, PATIENT_KICKOFF_ROUTE, Endpoints::KickOff
suite_endpoint :get, GROUP_KICKOFF_ROUTE, Endpoints::KickOff
suite_endpoint :get, SYSTEM_KICKOFF_ROUTE, Endpoints::KickOff
suite_endpoint :get, STATUS_ROUTE, Endpoints::Status
suite_endpoint :get, OUTPUT_ROUTE, Endpoints::Output
suite_endpoint :delete, STATUS_ROUTE, Endpoints::Delete

resume_test_route :get, RESUME_PASS_PATH do |request|
request.query_parameters['id']
end

group from: :bulk_data_client_export_group
group from: :bulk_data_client_delete_group
end
end
end
end
10 changes: 10 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/docs/suite_description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The Bulk Data Access v2.0.0 Client test suite validates the conformance of a client
to the [FHIR Bulk Data Access IG STU2](http://hl7.org/fhir/uv/bulkdata/STU2).

emichaud998 marked this conversation as resolved.
Show resolved Hide resolved
## Scope

These tests are a **DRAFT** intended to allow implementers to perform
preliminary checks of their systems against the requirements stated for Bulk Data client actors
and [provide feedback](https://github.com/inferno-framework/bulk-data-test-kit/issues)
on the tests. Future versions of these tests may verify other
requirements and may change the test verification logic.
32 changes: 32 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/endpoints/delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require_relative '../tags'

module BulkDataTestKit
module BulkDataV200
module Client
module Endpoints
# Delete Endpoint
class Delete < Inferno::DSL::SuiteEndpoint
include Tags
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including the Tags module is not necessary here. I believe if you add require_relative 'tags' to the client suite file, you can use the tag constants in all of the endpoint files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure what you mean. I'm bringing in the Tags module as a mixin to get access to the constants directly.

Copy link
Collaborator

@emichaud998 emichaud998 Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops nevermind with the way the Tags and URLs files are set up, you are right! I was looking at other test kits where it is done differently where the tags file does not have a Tags module defined. So for example for this test kit, the tags file would look like this:

module BulkDataTestKit
  module BulkDataV200
    module Client
      METADATA_TAG = 'bulk_data_metadata'
      PATIENT_KICKOFF_TAG = 'bulk_data_kickoff_patient'
      GROUP_KICKOFF_TAG = 'bulk_data_kickoff_group'
      SYSTEM_KICKOFF_TAG = 'bulk_data_kickoff_system'
      STATUS_TAG = 'bulk_data_status'
      OUTPUT_TAG = 'bulk_data_output'
      DELETE_TAG = 'bulk_data_delete'
    end
  end
end

Again maybe not a necessary change, but it does allow you to use constants from the Tags and URLs files without needing to include a new module.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see what you mean - it's definitely better to be consistent with the other test kits. I've made this change.


def test_run_identifier
export_id
end

def make_response
response.status = 202
end

def tags
[DELETE_TAG]
end

def export_id
request.params[:export_id]
end
end
end
end
end
end
48 changes: 48 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/endpoints/kick_off.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

require_relative '../tags'
require_relative '../urls'
require_relative '../export_types'

module BulkDataTestKit
module BulkDataV200
module Client
module Endpoints
# Kick Off Endpoint
class KickOff < Inferno::DSL::SuiteEndpoint
include Tags
include URLs
include ExportTypes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including ExportTypes I believe also is not necessary, since you are just using constants from that file like like the tags file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above (about Tags)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above (about Tags) and how if a new ExportTypes module is not defined in the export types file, then you do not need to include the module and can instead use the constants directly in every file by requiring the export types file from the parent suite.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


def test_run_identifier
export_id
end

def make_response
response.status = 202
response.headers['Content-Location'] = status_url(export_id)
end

def tags
case request_type.titleize
when PATIENT_EXPORT_TYPE
[PATIENT_KICKOFF_TAG]
when GROUP_EXPORT_TYPE
[GROUP_KICKOFF_TAG]
when SYSTEM_EXPORT_TYPE
[SYSTEM_KICKOFF_TAG]
end
end

def export_id
request.params[:export_id]
end

def request_type
request.params[:type] || SYSTEM_EXPORT_TYPE
emichaud998 marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
end
end
end
34 changes: 34 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/endpoints/output.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

require_relative '../tags'

module BulkDataTestKit
module BulkDataV200
module Client
module Endpoints
# Output Endpoint
class Output < Inferno::DSL::SuiteEndpoint
include Tags

def test_run_identifier
export_id
end

def make_response
response.status = 200
response.headers['Content-Type'] = 'application/fhir+ndjson'
response.body = "#{FHIR::Patient.new.to_json.squish}\n"
emichaud998 marked this conversation as resolved.
Show resolved Hide resolved
end

def tags
[OUTPUT_TAG]
end

def export_id
request.params[:export_id]
end
end
end
end
end
end
49 changes: 49 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/endpoints/status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

require_relative '../tags'
require_relative '../urls'

module BulkDataTestKit
module BulkDataV200
module Client
module Endpoints
# Status Endpoint
class Status < Inferno::DSL::SuiteEndpoint
include Tags
include URLs

def test_run_identifier
export_id
end

def make_response
response.status = 200
response.body = response_body.to_json
response.format = :json
end

def tags
[STATUS_TAG]
end

def export_id
request.params[:export_id]
end

def response_body
{
transactionTime: DateTime.now.iso8601,
request: kickoff_url(export_id),
requiresAccessToken: false,
output: [{
type: 'Patient',
url: output_url(export_id)
}],
error: []
}
end
end
end
end
end
end
14 changes: 14 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/export_types.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

module BulkDataTestKit
module BulkDataV200
module Client
# Export types for use in Bulk Data Client tests and endpoints
module ExportTypes
PATIENT_EXPORT_TYPE = 'Patient'
GROUP_EXPORT_TYPE = 'Group'
SYSTEM_EXPORT_TYPE = 'System'
end
end
end
end
101 changes: 101 additions & 0 deletions lib/bulk_data_test_kit/v2.0.0/client/groups/delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# frozen_string_literal: true

require_relative '../export_types'
require_relative '../urls'

require_relative '../tests/kick_off'
require_relative '../tests/delete'

module BulkDataTestKit
module BulkDataV200
module Client
module Groups
emichaud998 marked this conversation as resolved.
Show resolved Hide resolved
# Bulk Data Client Delete Tests
class Delete < Inferno::TestGroup
include ExportTypes
include URLs

title 'Bulk Data Client Delete Tests'

description %(
The Bulk Data Client Delete tests verify the ability of a client to delete
a kicked-off bulk data export request.
)

id :bulk_data_client_delete_group

run_as_group

input :export_type,
title: 'Export Type',
description: 'The export endpoint type to test against.',
type: 'radio',
default: SYSTEM_EXPORT_TYPE,
options: {
list_options: [
{
label: 'All Patients',
value: PATIENT_EXPORT_TYPE
},
{
label: 'Group of Patients',
value: GROUP_EXPORT_TYPE
},
{
label: 'System Level Export',
value: SYSTEM_EXPORT_TYPE
}
]
}

input :group_id,
title: 'Group ID',
description: 'If using the Group endpoint, the identifier of the Group to export.',
default: 1,
locked: true

test do
title 'Wait For Request Sequence'

description %(
This test will receive bulk data export requests until the user confirms they are finished.
)

input :export_type, :group_id

output :export_id

run do
export_id = SecureRandom.uuid

output export_id: export_id

wait(
identifier: export_id,
message: %(
Kick-off a #{export_type} endpoint type bulk export using the following base URL:

#{kickoff_url(export_id)}

#{export_type == GROUP_EXPORT_TYPE ? "Ensure the Group ID is set to #{group_id}." : ''}

Once the export request has been kicked-off,
[delete the export](https://build.fhir.org/ig/HL7/bulk-data/export.html#bulk-data-delete-request).

The entire request sequence will be recorded and used in the subsequent tests to
verify comformity to the
[Bulk Data IG](https://build.fhir.org/ig/HL7/bulk-data/export.html#sequence-overview).

[Click here](#{resume_pass_url}?id=#{export_id}) when finished.
)
)
end
end
emichaud998 marked this conversation as resolved.
Show resolved Hide resolved

test from: :bulk_data_client_kick_off
test from: :bulk_data_client_delete
end
end
end
end
end
Loading
Loading