Class: CemAcpt::Runner

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cem_acpt/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 Logging

current_log_config, #current_log_config, current_log_format, current_log_level, #current_log_level, included, #logger, new_log_config, #new_log_config, new_log_formatter, new_log_level, #new_log_level

Constructor Details

#initialize(node, conf, tdata, node_inv, module_pkg_path, results) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • node (String)

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

  • conf (CemAcpt::Config)

    the acceptance test suite configuration

  • tdata (Hash)

    the test data to use for the acceptance test suite

  • node_inv (CemAcpt::NodeInventory)

    the node inventory to use for the acceptance test suite

  • module_pkg_path (Concurrent::IVar)

    the path to the module package

  • results (Concurrent::Map)

    the results map to use for reporting test results



196
197
198
199
200
201
202
203
204
205
# File 'lib/cem_acpt/runner.rb', line 196

def initialize(node, conf, tdata, node_inv, module_pkg_path, results)
  @node = node
  @conf = conf
  @tdata = tdata
  @node_inv = node_inv
  @module_pkg_path = module_pkg_path
  @results = results
  @spec_exit_code = 0
  validate!
end

Instance Attribute Details

#spec_exit_codeObject (readonly)

Returns the value of attribute spec_exit_code.



188
189
190
# File 'lib/cem_acpt/runner.rb', line 188

def spec_exit_code
  @spec_exit_code
end

Instance Method Details

#exitObject

Runner thread exits and runner node is destroyed, if it exists.



226
227
228
229
# File 'lib/cem_acpt/runner.rb', line 226

def exit
  @thread.exit
  @node&.destroy
end

#join(timeout = 600) ⇒ Object

Joins the runner thread.

Parameters:

  • timeout (Integer) (defaults to: 600)

    thread timeout in seconds



221
222
223
# File 'lib/cem_acpt/runner.rb', line 221

def join(timeout = 600)
  @thread.join(timeout)
end

#killObject

Runner thread is killed and runner node is destroyed, if it exists.



232
233
234
235
# File 'lib/cem_acpt/runner.rb', line 232

def kill
  @thread.kill
  @node&.destroy
end

#startObject

Starts the runner thread and runs the lifecycle stages of the acceptance test suite.



209
210
211
212
213
214
215
216
217
# File 'lib/cem_acpt/runner.rb', line 209

def start
  logger.info("Starting test suite for #{@node.node_name}")
  @thread = Thread.new do
    provision
    bootstrap
    run_tests
    destroy
  end
end