inferno_core 0.6.10 → 0.6.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ff5c612e8052b2c2a817e5ad58d27d935b8838adc2d738a8924e61ba7ecc1a0
4
- data.tar.gz: 4324693af54d9c83d4eb60f2a2b85dc8012c72d372d9858bda39693d2b1de8b4
3
+ metadata.gz: b899985c0f229c1f91aa9218d09f9f502ed315c537398edc911e989cbe61c6a8
4
+ data.tar.gz: '08cca457d4bb79bdb70487a14fa07f8274dac19faae5623bedef8797541e993b'
5
5
  SHA512:
6
- metadata.gz: 2cbff301066bd9b295edc08790bbf8b6d658d2cd5c647a636a09c5918ff0024fc06eb566742d271bf6ea1a145745072f16ab157a674b6be3e8076a298d8110fd
7
- data.tar.gz: 5a9281d55a608b9356d535c5e7fc0b9bc8afb6d23a5cc6f76192e074582d385358b81ff07dd8959286440634b08411d8866b306313c4826d81ca85eb02a4d225
6
+ metadata.gz: 36b765180f9d7168c91238e1c7a63e8cc281f3a795f068e3d6ddb317d419d90dc2401585b8fde37e3d27c0c82fda9ef66dba3c6bd96201f1dafa9d3be301b53f
7
+ data.tar.gz: d83ffd4c0fec0cf1d3621a7f563c9d369d671bfce5f11c9bdcac9f287c5918a3c37f3ff340cd3429b4dbb1e96e9daa936ce50fe4bd889420cb66c0a41020a777
@@ -6,6 +6,7 @@ Dir[File.join(__dir__, 'execute', '*_outputter.rb')].each { |outputter| require
6
6
 
7
7
  module Inferno
8
8
  module CLI
9
+ # @private
9
10
  class Execute
10
11
  include ::Inferno::Utils::VerifyRunnable
11
12
  include ::Inferno::Utils::PersistInputs
@@ -45,7 +46,6 @@ module Inferno
45
46
  self.options = options
46
47
 
47
48
  outputter.print_start_message(self.options)
48
-
49
49
  load_preset_file_and_set_preset_id
50
50
 
51
51
  results = []
@@ -104,18 +104,6 @@ module Inferno
104
104
  @outputter ||= OUTPUTTERS[options[:outputter]].new
105
105
  end
106
106
 
107
- def load_preset_file_and_set_preset_id
108
- return unless options[:preset_file]
109
- raise StandardError, 'Cannot use `--preset-id` and `--preset-file` options together' if options[:preset_id]
110
-
111
- raise StandardError, "File #{options[:preset_file]} not found" unless File.exist? options[:preset_file]
112
-
113
- options[:preset_id] = JSON.parse(File.read(options[:preset_file]))['id']
114
- raise StandardError, "Preset #{options[:preset_file]} is missing id" if options[:preset_id].nil?
115
-
116
- presets_repo.insert_from_file(options[:preset_file])
117
- end
118
-
119
107
  def all_selected_groups_and_tests
120
108
  @all_selected_groups_and_tests ||= runnables_by_short_id + groups + tests
121
109
  end
@@ -123,7 +111,7 @@ module Inferno
123
111
  def run_one(runnable, test_run)
124
112
  verify_runnable(
125
113
  runnable,
126
- thor_hash_to_inputs_array(inputs_and_preset),
114
+ all_inputs,
127
115
  test_session.suite_options
128
116
  )
129
117
 
@@ -132,15 +120,14 @@ module Inferno
132
120
  dispatch_job(test_run)
133
121
  end
134
122
 
135
- def inputs_and_preset
123
+ def all_inputs
136
124
  if preset
137
- preset_inputs = preset.inputs.to_h do |preset_input|
138
- [preset_input[:name], preset_input[:value]]
139
- end
125
+ test_sessions_repo.apply_preset(test_session, preset.id)
126
+ preset_inputs = session_data_repo.get_all_from_session(test_session.id)
140
127
 
141
- options.fetch(:inputs, {}).reverse_merge(preset_inputs)
128
+ thor_hash_to_inputs_array(options.fetch(:inputs, {})) + preset_inputs.map(&:to_hash)
142
129
  else
143
- options.fetch(:inputs, {})
130
+ thor_hash_to_inputs_array(options.fetch(:inputs, {}))
144
131
  end
145
132
  end
146
133
 
@@ -159,6 +146,15 @@ module Inferno
159
146
  @preset
160
147
  end
161
148
 
149
+ def load_preset_file_and_set_preset_id
150
+ return unless options[:preset_file]
151
+ raise StandardError, 'Cannot use `--preset-id` and `--preset-file` options together' if options[:preset_id]
152
+
153
+ raise StandardError, "File #{options[:preset_file]} not found" unless File.exist? options[:preset_file]
154
+
155
+ options[:preset_id] = presets_repo.insert_from_file(options[:preset_file]).id
156
+ end
157
+
162
158
  def suite
163
159
  @suite ||= Inferno::Repositories::TestSuites.new.find(options[:suite])
164
160
 
@@ -214,7 +210,7 @@ module Inferno
214
210
  {
215
211
  test_session_id: test_session.id,
216
212
  runnable_id_key(runnable) => runnable.id,
217
- inputs: thor_hash_to_inputs_array(inputs_and_preset)
213
+ inputs: all_inputs
218
214
  }
219
215
  end
220
216
 
@@ -1,4 +1,5 @@
1
1
  require 'erb'
2
+ require_relative '../../feature'
2
3
 
3
4
  Dir.glob(File.join(__dir__, 'controllers', '**', '*.rb')).each { |path| require_relative path }
4
5
 
@@ -47,13 +48,17 @@ module Inferno
47
48
  put '/:id/check_configuration',
48
49
  to: Inferno::Web::Controllers::TestSuites::CheckConfiguration,
49
50
  as: :check_configuration
50
- get ':id/requirements',
51
- to: Inferno::Web::Controllers::TestSuites::Requirements::Index,
52
- as: :requirements
51
+ if Feature.requirements_enabled?
52
+ get ':id/requirements',
53
+ to: Inferno::Web::Controllers::TestSuites::Requirements::Index,
54
+ as: :requirements
55
+ end
53
56
  end
54
57
 
55
- scope 'requirements' do
56
- get '/:id', to: Inferno::Web::Controllers::Requirements::Show, as: :show
58
+ if Feature.requirements_enabled?
59
+ scope 'requirements' do
60
+ get '/:id', to: Inferno::Web::Controllers::Requirements::Show, as: :show
61
+ end
57
62
  end
58
63
 
59
64
  get '/requests/:id', to: Inferno::Web::Controllers::Requests::Show, as: :requests_show
@@ -1,5 +1,6 @@
1
1
  require 'oj'
2
2
  require 'blueprinter'
3
+ require_relative '../../../feature'
3
4
 
4
5
  module Inferno
5
6
  module Web
@@ -13,6 +14,12 @@ module Inferno
13
14
  result.send(name).present?
14
15
  end
15
16
  end
17
+
18
+ # When removing the feature flag, replace all instances of this method
19
+ # with `.field_present?`
20
+ def self.field_present_and_requirements_enabled?(field_name, result, options)
21
+ field_present?(field_name, result, options) && Feature.requirements_enabled?
22
+ end
16
23
  end
17
24
  end
18
25
  end
@@ -20,7 +20,7 @@ module Inferno
20
20
  field :input_instructions
21
21
  field :user_runnable?, name: :user_runnable
22
22
  field :optional?, name: :optional
23
- field :verifies_requirements, if: :field_present?
23
+ field :verifies_requirements, if: :field_present_and_requirements_enabled?
24
24
  end
25
25
  end
26
26
  end
@@ -32,7 +32,7 @@ module Inferno
32
32
  Input.render_as_hash(group.available_inputs(suite_options).values)
33
33
  end
34
34
  field :output_definitions, name: :outputs, extractor: HashValueExtractor
35
- field :verifies_requirements, if: :field_present?
35
+ field :verifies_requirements, if: :field_present_and_requirements_enabled?
36
36
  end
37
37
  end
38
38
  end
@@ -38,7 +38,7 @@ module Inferno
38
38
  suite_options = options[:suite_options]
39
39
  Input.render_as_hash(suite.available_inputs(suite_options).values)
40
40
  end
41
- field :requirement_sets, if: :field_present? do |suite, options|
41
+ field :requirement_sets, if: :field_present_and_requirements_enabled? do |suite, options|
42
42
  selected_options = options[:suite_options] || []
43
43
  requirement_sets = suite.requirement_sets.select do |requirement_set|
44
44
  requirement_set.suite_options.all? { |suite_option| selected_options.include? suite_option }
@@ -46,7 +46,7 @@ module Inferno
46
46
 
47
47
  RequirementSet.render_as_hash(requirement_sets)
48
48
  end
49
- field :verifies_requirements, if: :field_present?
49
+ field :verifies_requirements, if: :field_present_and_requirements_enabled?
50
50
  end
51
51
  end
52
52
  end
@@ -0,0 +1,9 @@
1
+ module Inferno
2
+ module Feature
3
+ class << self
4
+ def requirements_enabled?
5
+ ENV.fetch('ENABLE_REQUIREMENTS', 'false')&.casecmp?('true')
6
+ end
7
+ end
8
+ end
9
+ end