Module: CemAcpt::Context
- Extended by:
- Logging
- Defined in:
- lib/cem_acpt/context.rb
Overview
Context provides the context in which the RunHandler creates and starts Runners.
Class Method Summary collapse
-
.with(config_opts: nil, config_file: nil, &block) ⇒ Object
Creates a context for the RunHandler to create and start Runners.
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
Class Method Details
.with(config_opts: nil, config_file: nil, &block) ⇒ Object
Creates a context for the RunHandler to create and start Runners. Provides the following objects for the Runners: a config object, the test data hash, the node inventory, and the local port allocator. Additionally, it creates the platform-specific node objects for each test suite in the test data. It then calls the provided block with the context objects nodes, config, test_data, and node_inventory.
24 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 51 52 53 54 55 56 57 58 |
# File 'lib/cem_acpt/context.rb', line 24 def self.with(config_opts: nil, config_file: nil, &block) logger.debug('In context with:') logger.debug("config_opts: #{config_opts}") logger.debug("config_file: #{config_file}") config = CemAcpt::Config.new.load(opts: config_opts, config_file: config_file) logger.debug("Loaded config: #{config.to_h}") test_data = CemAcpt::TestData.acceptance_test_data(config) logger.debug("Loaded test data: #{test_data}") node_inventory = CemAcpt::NodeInventory.new logger.debug("Initialized new node inventory: #{node_inventory}") local_port_allocator = CemAcpt::LocalPortAllocator.new logger.debug("Initialized new local port allocator: #{local_port_allocator}") if config.has?('platform') logger.debug("Using platform: #{config.get('platform')}") nodes = CemAcpt::Platform.use(config.get('platform'), config, test_data, local_port_allocator) block.call(nodes, config, test_data, node_inventory) elsif config.has?('platforms') config.get('platforms').each do |platform| logger.debug("Using platform: #{platform}") nodes = CemAcpt::Platform.use(platform, config, test_data, local_port_allocator) block.call(nodes, config, test_data, node_inventory) end else raise CemAcpt::Error, 'No platform(s) specified' end rescue StandardError => e logger.fatal("Fatal error: #{e.}") logger.debug(e.backtrace.join('; ')) exit(1) end |