cem_acpt 0.10.4 → 0.10.5

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: 3f6d280d4ac5c56cd722e9a2a906647996cc18a5db7babc1f950b74a44306fc3
4
- data.tar.gz: f62af838277ee9e25b2af58093d1183460bc9022a175399c5830d38e49d01620
3
+ metadata.gz: dc299de4494abd1da48700f76b43223cb05aae1cb8c26235757e31e909bd6c2f
4
+ data.tar.gz: 32948e52808bd436695d69cf0c0bf2c5ccd31ada90ed401341c9c73e00653c6b
5
5
  SHA512:
6
- metadata.gz: 0d573fb143effd9425d6b38f6e764c8bafb44acb583bf95b9f2a600ca787e975875e2004edcaedc78876c303342663376334fde8fff37c5fef1bed3b131c9442
7
- data.tar.gz: a4e164fd64921e3bdde69e664f846ebe3fc307e1d919fff61df40634ac34794124d5e15539c3c657f874c6e9403228e3dca2593c4fe54358b0c588ba92e5e698
6
+ metadata.gz: 2a916fec7be6263243deeb60eac717ac097e0c477359b8abe71c374ef68880ab1608ff48859339074d97e8ae4592b9da491b5ff76b61f842a60712a9efcd1f75
7
+ data.tar.gz: e4e3b465b224f8f1431867ae19b6bee5161a91248168fd8e0c8c221c6ffa2c6caf3e2bf45a2a54e139e02069e45bc1dc7beacbddbe7fa11c15bf269811c98c54
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cem_acpt (0.10.4)
4
+ cem_acpt (0.10.5)
5
5
  async-http (>= 0.60, < 0.70)
6
6
  bcrypt_pbkdf (>= 1.0, < 2.0)
7
7
  deep_merge (>= 1.2, < 2.0)
@@ -127,6 +127,7 @@ module CemAcpt
127
127
  end
128
128
  ensure
129
129
  @items = (@cmd_output['items'] || []).map { |item| OutputItem.new(item) }
130
+ @error_obj ||= @items.find(&:error?)&.error
130
131
  if @items.empty? && @error_obj.nil? && @strict
131
132
  err = RuntimeError.new("Cannot set results, no error or items found for cmd_output:\n#{cmd_output}")
132
133
  @error_obj = err
@@ -158,11 +158,11 @@ module CemAcpt
158
158
  end
159
159
 
160
160
  def error?
161
- @command_result.is_a?(CemAcpt::Bolt::BoltActionError)
161
+ @command_result.error?
162
162
  end
163
163
 
164
164
  def error
165
- @command_result if error?
165
+ @command_result.error if error?
166
166
  end
167
167
 
168
168
  def to_h
@@ -378,7 +378,7 @@ module CemAcpt
378
378
  def load_test_data(run_data)
379
379
  run_data[:test_data].each_with_object({}) do |tdata, h|
380
380
  test_name = tdata[:test_name]
381
- next if h.key?(test_name) || tdata[:bolt_test].nil?
381
+ next if h.key?(test_name)
382
382
 
383
383
  logger.debug('CemAcpt::Bolt::Tests') { "Loading test data for test #{test_name}" }
384
384
  begin
@@ -53,6 +53,8 @@ module CemAcpt
53
53
  return false unless File.exist?(path)
54
54
 
55
55
  disk_contents = CemAcpt::Utils::Files.read(path, log_prefix: self.class.to_s)
56
+ return false unless disk_contents.is_a?(Hash)
57
+
56
58
  @hash.sort.to_h == disk_contents.sort.to_h
57
59
  end
58
60
 
@@ -60,6 +62,8 @@ module CemAcpt
60
62
  return false unless File.exist?(path)
61
63
 
62
64
  disk_contents = CemAcpt::Utils::Files.read(path, log_prefix: self.class.to_s)
65
+ return false unless disk_contents.is_a?(Hash)
66
+
63
67
  @hash.sort.to_h >= disk_contents.sort.to_h
64
68
  end
65
69
 
@@ -67,6 +71,8 @@ module CemAcpt
67
71
  return false unless File.exist?(path)
68
72
 
69
73
  disk_contents = CemAcpt::Utils::Files.read(path, log_prefix: self.class.to_s)
74
+ return false unless disk_contents.is_a?(Hash)
75
+
70
76
  @hash.sort.to_h <= disk_contents.sort.to_h
71
77
  end
72
78
  end
@@ -26,25 +26,7 @@ module CemAcpt
26
26
  super(response)
27
27
  log_subject.each_with_object([]) do |res, ary|
28
28
  res.results.each do |r|
29
- header = [
30
- "#{success_str(r.success?).capitalize}: #{r.name}",
31
- "action: #{r.action}",
32
- "target: #{name_from_ip(r.target)}",
33
- "object: #{r.object}",
34
- "status: #{r.status}",
35
- ]
36
- parts = [
37
- header.join(', '),
38
- "validation results:\n#{JSON.pretty_generate(r.failed_validation_results)}",
39
- ]
40
- if CemAcpt::Logging.verbose?
41
- parts << "command result:\n#{JSON.pretty_generate(r.command_result.to_h)}"
42
- end
43
- parts << r.error if r.error?
44
- if r.respond_to?(:details) && !r.details&.empty?
45
- parts << "details:\n#{JSON.pretty_generate(r.details)}\n"
46
- end
47
- ary << parts.join("\n")
29
+ ary << (r.error? ? format_error_result(r) : format_result(r))
48
30
  end
49
31
  end
50
32
  end
@@ -58,6 +40,41 @@ module CemAcpt
58
40
  super(response)
59
41
  'Bolt tests'
60
42
  end
43
+
44
+ private
45
+
46
+ def result_header(r)
47
+ [
48
+ "#{success_str(r.success?).capitalize}: #{r.name}",
49
+ "action: #{r.action}",
50
+ "target: #{name_from_ip(r.target)}",
51
+ "object: #{r.object}",
52
+ "status: #{r.status}",
53
+ ].join(', ')
54
+ end
55
+
56
+ def format_result(r)
57
+ parts = [
58
+ result_header(r),
59
+ "validation results:\n#{JSON.pretty_generate(r.failed_validation_results)}",
60
+ ]
61
+ if CemAcpt::Logging.verbose?
62
+ parts << "command result:\n#{JSON.pretty_generate(r.command_result.to_h)}"
63
+ end
64
+ if r.respond_to?(:details) && !r.details&.empty?
65
+ parts << "details:\n#{JSON.pretty_generate(r.details)}\n"
66
+ end
67
+ parts.join("\n")
68
+ end
69
+
70
+ def format_error_result(r)
71
+ [
72
+ result_header(r),
73
+ "error: #{r.error.kind}",
74
+ "issue code: #{r.error.issue_code}",
75
+ r.error.msg,
76
+ ].join("\n")
77
+ end
61
78
  end
62
79
  end
63
80
  end
@@ -186,7 +186,7 @@ module CemAcpt
186
186
  @run_data[:nodes] = new_node_data
187
187
  logger.verbose('CemAcpt::TestRunner') { "Initial run data:\n#{@run_data}" }
188
188
  logger.info('CemAcpt::TestRunner') { 'Created initial run data...' }
189
- setup_bolt if CemAcpt::Actions.config.action_names.include?('bolt')
189
+ setup_bolt if CemAcpt::Actions.config.action_names.include?(:bolt)
190
190
  end
191
191
 
192
192
  def setup_bolt
@@ -197,12 +197,12 @@ module CemAcpt
197
197
  rescue CemAcpt::ShellCommandNotFoundError => e
198
198
  logger.warning('CemAcpt::TestRunner') { e.message }
199
199
  logger.warning('CemAcpt::TestRunner') { 'Adding Bolt action to ignore list...' }
200
- CemAcpt::Actions.config.ignore << 'bolt'
200
+ CemAcpt::Actions.config.ignore << :bolt
201
201
  return
202
202
  end
203
203
  return unless @bolt_test_runner.tests.to_a.empty?
204
204
 
205
- if !CemAcpt::Actions.config.only.empty? && CemAcpt::Actions.config.only.include?('bolt')
205
+ if !CemAcpt::Actions.config.only.empty? && CemAcpt::Actions.config.only.include?(:bolt)
206
206
  raise 'No Bolt tests to run and only bolt action was specified'
207
207
  end
208
208
 
@@ -348,6 +348,8 @@ module CemAcpt
348
348
  logger.info { r }
349
349
  else
350
350
  logger.error { r }
351
+ next unless result.respond_to?(:metadata) && result.metadata.key?(:run_logs)
352
+
351
353
  logs = if config.debug? && !config.get('puppet.no_debug')
352
354
  result.metadata[:run_logs]&.dup
353
355
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CemAcpt
4
- VERSION = '0.10.4'
4
+ VERSION = '0.10.5'
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.10.4
4
+ version: 0.10.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - puppetlabs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2024-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-http