Class: HybridPlatformsConductor::HpcPlugins::TestReport::Confluence

Inherits:
TestReport
  • Object
show all
Defined in:
lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb

Overview

Report tests results on a generated Confluence page

Constant Summary collapse

MAX_ERROR_ITEMS_DISPLAYED =

Maximum errors to be reported by item

10
MAX_ERROR_MESSAGE_LENGTH_DISPLAYED =

Maximal length of an error message to be reported

4096
NBR_CELLS_IN_STATUS_BARS =

Number of cells in the nodes list’s progress status bars

28

Constants included from LoggerHelpers

LoggerHelpers::LEVELS_MODIFIERS, LoggerHelpers::LEVELS_TO_STDERR

Instance Method Summary collapse

Methods inherited from TestReport

#initialize

Methods inherited from Plugin

extend_config_dsl_with, #initialize, valid?

Methods included from LoggerHelpers

#err, #init_loggers, #log_component=, #log_debug?, #log_level=, #out, #section, #set_loggers_format, #stderr_device, #stderr_device=, #stderr_displayed?, #stdout_device, #stdout_device=, #stdout_displayed?, #stdouts_to_s, #with_progress_bar

Constructor Details

This class inherits a constructor from HybridPlatformsConductor::TestReport

Instance Method Details

#reportObject

Handle tests reports



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb', line 27

def report
  confluence_info = @config.confluence_info
  if confluence_info
    if confluence_info[:tests_report_page_id]
      HybridPlatformsConductor::Confluence.with_confluence(confluence_info[:url], @logger, @logger_stderr) do |confluence|
        # Get previous percentages for the evolution
        @previous_success_percentages = confluence.page_storage_format(confluence_info[:tests_report_page_id]).
          at('h1:contains("Evolution")').
          search('~ structured-macro:first-of-type').
          css('table td').
          map { |td_element| td_element.text }.
          each_slice(2).
          to_a.
          map { |(time_str, value_str)| [Time.parse("#{time_str} UTC"), value_str.to_f] }
        @nbr_cells_in_status_bars = NBR_CELLS_IN_STATUS_BARS
        log_error 'Unable to extract previous percentages from Confluence page' if @previous_success_percentages.empty?
        confluence.update_page(confluence_info[:tests_report_page_id], render('confluence'))
      end
      out "Inventory report Confluence page updated. Please visit #{confluence_info[:url]}/pages/viewpage.action?pageId=#{confluence_info[:tests_report_page_id]}"
    else
      log_warn 'No tests_report_page_id in the Confluence information defined. Ignoring the Confluence report.'
    end
  else
    log_warn 'No Confluence information defined. Ignoring the Confluence report.'
  end
end