Class: CemAcpt::Platform::TestBase

Inherits:
Base
  • Object
show all
Defined in:
lib/cem_acpt/platform/base.rb

Overview

Base class for all test node platform classes. This class provides an API for interacting with the underlying platform.

Constant Summary

Constants included from Logging

Logging::LEVEL_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#node_data, #platform_data, #to_json

Methods included from Logging

current_log_config, #current_log_config, current_log_format, #current_log_format, #current_log_level, current_log_level, included, #logger, logger, new_log_config, #new_log_config, new_log_formatter, #new_log_formatter, #new_log_level, new_log_level, #new_logger, new_logger, verbose?, #verbose?

Constructor Details

#initialize(config, single_test_data, **run_data) ⇒ TestBase

Returns a new instance of TestBase.

Parameters:

  • conf (CemAcpt::Config)

    the config object.

  • single_test_data (Hash)

    the test data for the current test.

  • run_data (Hash)

    the run data for the current run minus the test data key.

Raises:

  • (ArgumentError)


59
60
61
62
63
64
# File 'lib/cem_acpt/platform/base.rb', line 59

def initialize(config, single_test_data, **run_data)
  super(config, **run_data)
  raise ArgumentError, 'single_test_data must be a Hash' unless single_test_data.is_a?(Hash)

  @test_data = single_test_data
end

Instance Attribute Details

#test_dataObject (readonly)

Returns the value of attribute test_data.



54
55
56
# File 'lib/cem_acpt/platform/base.rb', line 54

def test_data
  @test_data
end

Instance Method Details

#image_nameObject

Generates or retrieves an image name from the test data.



81
82
83
# File 'lib/cem_acpt/platform/base.rb', line 81

def image_name
  @image_name ||= (@config.has?('image_name_builder') ? image_name_builder(@config, test_data) : test_data[:image_name])
end

#node_nameObject



66
67
68
# File 'lib/cem_acpt/platform/base.rb', line 66

def node_name
  @node_name ||= (@test_data[:node_name] || random_node_name)
end

#to_hObject



70
71
72
73
74
75
76
77
78
# File 'lib/cem_acpt/platform/base.rb', line 70

def to_h
  {
    node_name: node_name,
    image_name: image_name,
    test_data: test_data,
    platform_data: platform_data,
    node_data: node_data,
  }
end