cem_acpt 0.9.3 → 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: cf014af7878da07c60277b7442026f9858d3be6cae4115d234bbdef42e5be423
4
- data.tar.gz: 87c1b62d79d341e8c105400687dead9ac47b37f1ce71f1dfd88515f909adb1da
3
+ metadata.gz: 510e2adff3171d80515a714a2576ed434f860f52e94c367c050cb07f355294aa
4
+ data.tar.gz: b4d17cce2b4e7862e8f00558e3bebfd292c2eb3bab9f3df497d98cd881d4e9e8
5
5
  SHA512:
6
- metadata.gz: c738c837d50afbf8cab1b689fcd497587f8572517a09129259409c0319b5c0ef1d8fcd6662f7c055933fdc017a8c06871271f588cf3b14d0df5378f58fc14dd7
7
- data.tar.gz: 4fa49c1ae47ff43785b5d10b9d0c7f8c12d84d636cef9e839d1056421314e0f74082c65d098fbae171712f2b60b24a6b07f0d4a5fcc8b1aab603e550d86f77d7
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.3)
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')
@@ -261,6 +268,13 @@ module CemAcpt
261
268
  CemAcpt::Goss::Api.run_actions_async(context)
262
269
  end
263
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
+
264
278
  def run_bolt_tests(_context = {})
265
279
  logger.info('CemAcpt::TestRunner') { 'Running Bolt tests...' }
266
280
  # If the Bolt config has tests:only or tests:ignore lists, we need to filter the hosts
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.9.3'
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.3
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-06 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