Class: CemAcpt::TestRunner::LogFormatter::BoltSummaryResultsFormatter

Inherits:
Base
  • Object
show all
Defined in:
lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb

Overview

Formats the results of a Bolt::SummaryResults object

Constant Summary

Constants inherited from Base

CemAcpt::TestRunner::LogFormatter::Base::INDENT

Instance Attribute Summary

Attributes inherited from Base

#subject

Instance Method Summary collapse

Methods inherited from Base

#inspect, #to_s

Constructor Details

#initialize(config, instance_names_ips, subject: nil) ⇒ BoltSummaryResultsFormatter

Returns a new instance of BoltSummaryResultsFormatter.



11
12
13
14
15
# File 'lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb', line 11

def initialize(config, instance_names_ips, subject: nil)
  super(subject)
  @config = config
  @instance_names_ips = instance_names_ips
end

Instance Method Details

#host_name(response = nil) ⇒ Object



52
53
54
55
# File 'lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb', line 52

def host_name(response = nil)
  super(response)
  log_subject.items.map { |i| name_from_ip(i.target) }.compact.uniq.join(', ')
end

#results(response = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb', line 25

def results(response = nil)
  super(response)
  log_subject.each_with_object([]) do |res, ary|
    res.results.each do |r|
      header = [
        "#{success_str(r.success?).capitalize}: #{r.name}",
        "action: #{r.action}",
        "target: #{name_from_ip(r.target)}",
        "object: #{r.object}",
        "status: #{r.status}",
      ]
      parts = [
        header.join(', '),
        "validation results:\n#{JSON.pretty_generate(r.failed_validation_results)}",
      ]
      if CemAcpt::Logging.verbose?
        parts << "command result:\n#{JSON.pretty_generate(r.command_result.to_h)}"
      end
      parts << r.error if r.error?
      if r.respond_to?(:details) && !r.details&.empty?
        parts << "details:\n#{JSON.pretty_generate(r.details)}\n"
      end
      ary << parts.join("\n")
    end
  end
end

#summary(response = nil) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb', line 17

def summary(response = nil)
  super(response)
  [
    "SUMMARY: #{test_name(log_subject)}:",
    normalize_whitespace(log_subject.summary),
  ].join(' ')
end

#test_name(response = nil) ⇒ Object



57
58
59
60
# File 'lib/cem_acpt/test_runner/log_formatter/bolt_summary_results_formatter.rb', line 57

def test_name(response = nil)
  super(response)
  'Bolt tests'
end