Skip to content

Commit

Permalink
FI-2222: no tests hang fix (#425)
Browse files Browse the repository at this point in the history
* add titles to infrastructure test suite external groups

* add rspec tests

* fix server side error for empty group

* rubocop conformance
  • Loading branch information
Shaumik-Ashraf authored Jan 19, 2024
1 parent b7ecc81 commit 144929d
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ group :test do
gem 'simplecov-cobertura'
gem 'webmock'
gem 'factory_bot'
end
end
10 changes: 10 additions & 0 deletions dev_suites/dev_infrastructure_test/empty_group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module InfrastructureTest
class EmptyGroup < Inferno::TestGroup
id 'empty_group'
title 'Empty Group'

fhir_client :empty_group do
url 'EMPTY_GROUP'
end
end
end
1 change: 1 addition & 0 deletions dev_suites/dev_infrastructure_test/external_inner_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module InfrastructureTest
class ExternalInnerGroup < Inferno::TestGroup
id 'external_inner_group'
title 'External Inner Group'

input :external_inner_group_input, type: 'text'
output :external_inner_group_output
Expand Down
1 change: 1 addition & 0 deletions dev_suites/dev_infrastructure_test/external_outer_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module InfrastructureTest
class ExternalOuterGroup < Inferno::TestGroup
id 'external_outer_group'
title 'External Outer Group'

input :external_outer_group_input
output :external_outer_group_output
Expand Down
2 changes: 2 additions & 0 deletions dev_suites/dev_infrastructure_test/infrastructure_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_relative 'failing_optional_group'
require_relative 'passing_optional_group'
require_relative 'mixed_optional_group'
require_relative 'empty_group'

module InfrastructureTest
class Suite < Inferno::TestSuite
Expand Down Expand Up @@ -111,6 +112,7 @@ def inline_test1_helper
group from: 'passing_optional_group'
group from: 'failing_optional_group'
group from: 'mixed_optional_group', exclude_optional: true
group from: 'empty_group'
group from: 'external_outer_group'
end
end
9 changes: 9 additions & 0 deletions lib/inferno/test_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ def run_group(group, scratch)
}
end

if group.children.empty?
group_result = persist_result(group.reference_hash.merge(result: 'omit',
result_message: 'No tests defined',
input_json: JSON.generate(group_inputs_with_values),
output_json: '[]'))
update_parent_result(group.parent)
return group_result
end

results = []
group.children(test_session.suite_options).each do |child|
result = run(child, scratch)
Expand Down
24 changes: 21 additions & 3 deletions spec/inferno/dsl/test_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
end

it 'contains the correct groups' do
expect(suite.groups.length).to eq(5)
expect(suite.groups.length).to eq(6)
expect(suite.groups.first).to eq(outer_inline_group)
end

Expand Down Expand Up @@ -62,12 +62,15 @@

results = results_repo.current_results_for_test_session(test_session.id)

expect(results.length).to eq(16)
expect(results.length).to eq(17)

required_results = results.reject(&:optional?)
non_passing_results = required_results.reject { |result| result.result == 'pass' }
bad_results = non_passing_results.reject do |result|
result.test_group.id == 'infra_test-empty_group' && result.result == 'omit'
end

expect(non_passing_results).to be_empty, non_passing_results.map { |r|
expect(bad_results).to be_empty, bad_results.map { |r|
"#{r.runnable.title}: #{r.result_message}"
}.join("\n")
end
Expand Down Expand Up @@ -434,6 +437,21 @@
end
end
end

describe 'empty_group' do
let(:empty_group) { InfrastructureTest::EmptyGroup }
let(:test_run) do
repo_create(
:test_run,
runnable: { test_group_id: empty_group.id },
test_session:
)
end

it 'contains zero tests' do
expect(empty_group.tests.length).to eq(0)
end
end
end
end

Expand Down
19 changes: 19 additions & 0 deletions spec/inferno/test_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,23 @@ def error_results_message(error_results)
expect(results).to all(eq('pass'))
end
end

describe 'when running an empty group' do
let(:test_session) { repo_create(:test_session, test_suite_id: 'infra_test') }
let(:empty_group) { InfrastructureTest::EmptyGroup }
let(:test_run) do
repo_create(
:test_run,
runnable: { test_group_id: empty_group.id },
test_session:
)
end

it 'results in omit' do
result = runner.run(empty_group)

expect(result.result).to eq('omit')
expect(result.result_message).to eq('No tests defined')
end
end
end

0 comments on commit 144929d

Please sign in to comment.