cem_acpt 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95508415e2d43c47c4bbd08963e688133e693c395ed646c8d9d6e62f3cab04af
4
- data.tar.gz: 9b4618f3f1a544e35f00b88ff28efd755637db91d7e042c1e526e5720e6ecec2
3
+ metadata.gz: 510e2adff3171d80515a714a2576ed434f860f52e94c367c050cb07f355294aa
4
+ data.tar.gz: b4d17cce2b4e7862e8f00558e3bebfd292c2eb3bab9f3df497d98cd881d4e9e8
5
5
  SHA512:
6
- metadata.gz: 9ea28e2bb50d55cc24b96235360498cd0b76104bf48586bb9432e2d3b4e614b5d5e7a516b5587a77ff514629db897cc988e4cf4a084eb56d314b54a24d954661
7
- data.tar.gz: e95003005da232f68c058ca492e30bf4eb5f4539772494e6e733da2ecad26e740b1d560bc46ef3dc3916ffbd9449a2b0e02636d5d9554613ee7cee6c317820e7
6
+ metadata.gz: 421f5d6f9f2bd087629be54b05bd56ddb67424adf5ababbe3aa0cf042f5bb4e44c10c7ece789ae6659472b1041069e5ec7c8b355fcb2a2606da03d6397d2941c
7
+ data.tar.gz: 26de5c483c949caa0f203cf65977bdad0bd42083324589d09d6a9ad1630686e0ec410986b81ca4f4a290be55073e4ab7f61f8103e615d6fe1fc7550f1df25daa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_acpt (0.9.2)
4
+ cem_acpt (0.9.4)
5
5
  async-http (>= 0.60, < 0.70)
6
6
  bcrypt_pbkdf (>= 1.0, < 2.0)
7
7
  deep_merge (>= 1.2, < 2.0)
@@ -142,9 +142,28 @@ module CemAcpt
142
142
 
143
143
  context[:group] = group.name
144
144
  context[:actions] = actions.map(&:name)
145
- actions.each do |action|
146
- action_opts = opts[action.name.to_sym] || {}
147
- results << action.call(context.merge(action_opts))
145
+ if group.async
146
+ Async do
147
+ barrier = Async::Barrier.new
148
+ context[:internet] = Async::HTTP::Internet.new
149
+ actions.each do |action|
150
+ context[:action] = action.name
151
+ barrier.async do
152
+ action_opts = opts[action.name.to_sym] || {}
153
+ action.call(context.merge(action_opts))
154
+ end
155
+ end
156
+ barrier.wait
157
+ ensure
158
+ context[:internet]&.close
159
+ end
160
+ results << context[:results]
161
+ else
162
+ actions.each do |action|
163
+ context[:action] = action.name
164
+ action_opts = opts[action.name.to_sym] || {}
165
+ results << action.call(context.merge(action_opts))
166
+ end
148
167
  end
149
168
  end
150
169
  end
@@ -47,6 +47,7 @@ module CemAcpt
47
47
  raise ArgumentError, 'actions must be an Array' unless actions.is_a?(Array)
48
48
 
49
49
  actions.map!(&:to_sym)
50
+ actions.select! { |action| ACTIONS.key?(action) }
50
51
  logger.info('CemAcpt::Goss::Api') do
51
52
  "Running test actions #{actions.join(', ')} against #{hosts.size} host(s)..."
52
53
  end
@@ -69,6 +70,14 @@ module CemAcpt
69
70
  results
70
71
  end
71
72
 
73
+ def run_action_async(context = {})
74
+ context[:results] ||= Queue.new
75
+ context[:hosts].each do |host|
76
+ context[:results] << run_action(context[:internet], host, context[:action])
77
+ end
78
+ context[:results]
79
+ end
80
+
72
81
  # Run the specified action against the specified host.
73
82
  # @param internet [Async::HTTP::Internet] The Async::HTTP::Internet object to use for the request.
74
83
  # @param host [String] The host to run the action against. This should be
@@ -57,7 +57,6 @@ module CemAcpt
57
57
  pre_provision_test_nodes
58
58
  provision_test_nodes
59
59
  @instance_names_ips = provisioner_output
60
- logger.info('CemAcpt::TestRunner') { "Instance names and IPs class: #{@instance_names_ips.class}" }
61
60
  @provisioned = true
62
61
  logger.info('CemAcpt::TestRunner') { 'Provisioned test nodes...' }
63
62
  logger.debug('CemAcpt::TestRunner') { "Instance names and IPs: #{@instance_names_ips}" }
@@ -115,12 +114,13 @@ module CemAcpt
115
114
  # Configures the actions to run based on the config
116
115
  def configure_actions
117
116
  logger.info('CemAcpt::TestRunner') { 'Configuring and registering actions...' }
118
- goss_actions = CemAcpt::Goss::Api::ACTIONS.keys
119
117
  CemAcpt::Actions.configure(config) do |c|
120
- c.register_group(:goss, order: 0).register_action(goss_actions.first) do |context|
121
- run_goss_tests(context)
118
+ c.register_group(:goss, order: 0, async: true)
119
+ CemAcpt::Goss::Api::ACTIONS.each_key do |a|
120
+ c[:goss].register_action(a) do |context|
121
+ run_goss_test(context)
122
+ end
122
123
  end
123
- goss_actions[1..-1].each { |a| c[:goss].register_action(a) }
124
124
  c.register_group(:bolt, order: 1).register_action(:bolt) do |context|
125
125
  run_bolt_tests(context)
126
126
  end
@@ -193,8 +193,15 @@ module CemAcpt
193
193
 
194
194
  def setup_bolt
195
195
  logger.info('CemAcpt::TestRunner') { 'Setting up Bolt...' }
196
- @bolt_test_runner = CemAcpt::Bolt::TestRunner.new(config, run_data: @run_data)
197
- @bolt_test_runner.setup!
196
+ begin
197
+ @bolt_test_runner = CemAcpt::Bolt::TestRunner.new(config, run_data: @run_data)
198
+ @bolt_test_runner.setup!
199
+ rescue CemAcpt::ShellCommandNotFoundError => e
200
+ logger.warning('CemAcpt::TestRunner') { e.message }
201
+ logger.warning('CemAcpt::TestRunner') { 'Adding Bolt action to ignore list...' }
202
+ CemAcpt::Actions.config.ignore << 'bolt'
203
+ return
204
+ end
198
205
  return unless @bolt_test_runner.tests.to_a.empty?
199
206
 
200
207
  if !CemAcpt::Actions.config.only.empty? && CemAcpt::Actions.config.only.include?('bolt')
@@ -250,8 +257,6 @@ module CemAcpt
250
257
  def run_tests
251
258
  logger.info('CemAcpt::TestRunner') { 'Preparing to run tests...' }
252
259
  logger.verbose('CemAcpt::TestRunner') { "Hosts: #{@hosts}" }
253
- logger.verbose('CemAcpt::TestRunner') { "Only actions: #{CemAcpt::Actions.only}" }
254
- logger.verbose('CemAcpt::TestRunner') { "Except actions: #{CemAcpt::Actions.except}" }
255
260
  @results = CemAcpt::TestRunner::TestResults.new(config, @instance_names_ips)
256
261
  CemAcpt::Actions.execute
257
262
  end
@@ -263,6 +268,13 @@ module CemAcpt
263
268
  CemAcpt::Goss::Api.run_actions_async(context)
264
269
  end
265
270
 
271
+ def run_goss_test(context = {})
272
+ logger.info('CemAcpt::TestRunner') { "Running Goss test for action #{context[:action]}..." }
273
+ context[:hosts] = @hosts
274
+ context[:results] = @results
275
+ CemAcpt::Goss::Api.run_action_async(context)
276
+ end
277
+
266
278
  def run_bolt_tests(_context = {})
267
279
  logger.info('CemAcpt::TestRunner') { 'Running Bolt tests...' }
268
280
  # If the Bolt config has tests:only or tests:ignore lists, we need to filter the hosts
@@ -311,14 +323,17 @@ module CemAcpt
311
323
  logger.info('CemAcpt::TestRunner') { "Processing #{@results.size} test result(s)..." }
312
324
  until @results.empty?
313
325
  result = @results.pop
326
+ res_status = result.status
327
+ if @exit_code.zero? && !SUCCESS_STATUS.include?(res_status.to_i)
328
+ logger.debug('CemAcpt::TestRunner') { "Setting exit code to 1 because of result: #{result}" }
329
+ @exit_code = 1
330
+ end
314
331
  @statuses << result.status
315
332
  log_test_result(result)
316
333
  end
317
334
  if @statuses.empty?
318
335
  logger.error('CemAcpt::TestRunner') { 'No test results to process' }
319
336
  @exit_code = 1
320
- else
321
- @exit_code = (@statuses.any? { |s| SUCCESS_STATUS.include?(s.to_i) }) ? 1 : 0
322
337
  end
323
338
  end
324
339
  @duration = Time.now - @start_time
@@ -353,7 +368,7 @@ module CemAcpt
353
368
  end
354
369
 
355
370
  def log_error_test_result(result)
356
- logger.fatal { result.log_formatter.results.join("\n") }
371
+ logger.error { result.log_formatter.results.join("\n") }
357
372
  end
358
373
 
359
374
  # Upload the cem_windows module to the bucket if we're testing the cem_windows module
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.9.2'
4
+ VERSION = '0.9.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cem_acpt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-05 00:00:00.000000000 Z
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http