Class: CemAcpt::TestRunner::Runner

Inherits:
Object
  • Object
show all
Includes:
LoggingAsync
Defined in:
lib/cem_acpt/test_runner/runner.rb

Overview

Runner is a class that runs a single acceptance test suite on a single node. It is responsible for managing the lifecycle of the test suite and reporting the results back to the main thread. Runner objects are created by the RunHandler and then, when started, execute their logic in a thread.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LoggingAsync

async_debug, #async_debug, async_error, #async_error, async_fatal, #async_fatal, async_info, #async_info, async_warn, #async_warn, included, log_write_thread, #log_write_thread

Constructor Details

#initialize(node, context, platform) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • node (String)

    the name of the node to run the acceptance test suite on

  • ctx (CemAcpt::RunnerCtx)

    a cem_acpt Ctx (context) object

  • module_pkg_path (Concurrent::IVar)

    the path to the module package



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cem_acpt/test_runner/runner.rb', line 36

def initialize(node, context, platform)
  @node = node
  @context = context
  @platform = platform
  @debug_mode = @context.config.debug_mode?
  @node_inventory = @context.node_inventory
  @module_pkg_path = @context.module_package_path
  @node_exists = false
  @run_result = CemAcpt::TestRunner::RunnerResult.new(@node, debug: @debug_mode)
  @completed_steps = []
  validate!
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



31
32
33
# File 'lib/cem_acpt/test_runner/runner.rb', line 31

def node
  @node
end

#node_existsObject (readonly)

Returns the value of attribute node_exists.



31
32
33
# File 'lib/cem_acpt/test_runner/runner.rb', line 31

def node_exists
  @node_exists
end

#run_resultObject (readonly)

Returns the value of attribute run_result.



31
32
33
# File 'lib/cem_acpt/test_runner/runner.rb', line 31

def run_result
  @run_result
end

Instance Method Details

#run_step(step_sym) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/cem_acpt/test_runner/runner.rb', line 49

def run_step(step_sym)
  send(step_sym)
  @completed_steps << step_sym
rescue StandardError => e
  err = CemAcpt::TestRunner::RunnerStepError.new(step_sym, e)
  step_error_logging(err)
  @run_result.from_error(err)
  destroy unless step_sym == :destroy
end

#startObject

Executes test suite steps



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cem_acpt/test_runner/runner.rb', line 60

def start
  async_info("Starting test suite for #{@node.node_name}", log_prefix('RUNNER'))
  run_step(:provision)
  run_step(:bootstrap)
  run_step(:run_tests)
  run_step(:destroy)
  true
rescue StandardError => e
  step_error_logging(e)
  @run_result.from_error(e)
  destroy
end

#test_failures?Boolean

Checks for failures in the test results.

Parameters:

  • result (Hash)

    the test result to check

Returns:

  • (Boolean)

    whether or not there are test failures in result



76
77
78
# File 'lib/cem_acpt/test_runner/runner.rb', line 76

def test_failures?
  @run_result.result_errors? || @run_result.result_failures?
end