cem_acpt 0.9.3 → 0.9.4
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cem_acpt/actions.rb +22 -3
- data/lib/cem_acpt/goss/api.rb +9 -0
- data/lib/cem_acpt/test_runner.rb +21 -7
- data/lib/cem_acpt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 510e2adff3171d80515a714a2576ed434f860f52e94c367c050cb07f355294aa
|
4
|
+
data.tar.gz: b4d17cce2b4e7862e8f00558e3bebfd292c2eb3bab9f3df497d98cd881d4e9e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 421f5d6f9f2bd087629be54b05bd56ddb67424adf5ababbe3aa0cf042f5bb4e44c10c7ece789ae6659472b1041069e5ec7c8b355fcb2a2606da03d6397d2941c
|
7
|
+
data.tar.gz: 26de5c483c949caa0f203cf65977bdad0bd42083324589d09d6a9ad1630686e0ec410986b81ca4f4a290be55073e4ab7f61f8103e615d6fe1fc7550f1df25daa
|
data/Gemfile.lock
CHANGED
data/lib/cem_acpt/actions.rb
CHANGED
@@ -142,9 +142,28 @@ module CemAcpt
|
|
142
142
|
|
143
143
|
context[:group] = group.name
|
144
144
|
context[:actions] = actions.map(&:name)
|
145
|
-
|
146
|
-
|
147
|
-
|
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
|
data/lib/cem_acpt/goss/api.rb
CHANGED
@@ -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
|
data/lib/cem_acpt/test_runner.rb
CHANGED
@@ -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
|
121
|
-
|
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
|
-
|
197
|
-
|
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
|
data/lib/cem_acpt/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-http
|