class Kitchen::Driver::Static

Driver for using static/physical hosts with Kitchen. This driver is a newer version of the proxy driver.

@author Thomas Heinen <theinen@tecracer.de>

Constants

Public Instance Methods

create(state) click to toggle source
# File lib/kitchen/driver/static.rb, line 26
def create(state)
  print_version

  state[:hostname] = queueing? ? request(state) : config[:host]

  if queueing?
    info format("[kitchen-static] Received %s for testing", state[:hostname])
    info format(BANNER_FORMAT, queueing_handler.banner) if queueing_handler.banner?
  end
end
destroy(state) click to toggle source
# File lib/kitchen/driver/static.rb, line 37
def destroy(state)
  print_version
  return if state[:hostname].nil?

  release(state) if queueing?
  info format("[kitchen-static] Released %s from testing", state[:hostname]) if queueing?

  state.delete(:hostname)
end

Private Instance Methods

print_version() click to toggle source
queueing?() click to toggle source
# File lib/kitchen/driver/static.rb, line 61
def queueing?
  config[:queueing] === true
end
queueing_handler() click to toggle source
# File lib/kitchen/driver/static.rb, line 65
def queueing_handler
  @queueing_handler ||= queueing_registry[queueing_type].new(config)
end
queueing_registry() click to toggle source
# File lib/kitchen/driver/static.rb, line 75
def queueing_registry
  return unless queueing?

  @queueing_registry unless @queueing_registry.nil? || @queueing_registry.empty?
  @queueing_registry = {}

  bundled_handlers = File.join(__dir__, "queueing", "*.rb")
  require_queueing_handlers(bundled_handlers)

  additional_handlers = config[:queueing_handlers]
  additional_handlers.each { |glob| require_queueing_handlers(glob) }

  Queueing::Base.descendants.each do |handler_class|
    type = queueing_type_from_class(handler_class)
    @queueing_registry[type] = handler_class

    debug format("[kitchen-static] Added queueing handler: %s", type)
  end

  @queueing_registry
end
queueing_type() click to toggle source
# File lib/kitchen/driver/static.rb, line 69
def queueing_type
  return unless queueing?

  config.fetch(:type, "script")
end
queueing_type_from_class(handler_class) click to toggle source
# File lib/kitchen/driver/static.rb, line 101
def queueing_type_from_class(handler_class)
  handler_class.to_s.split("::").last.downcase
end
release(state) click to toggle source
# File lib/kitchen/driver/static.rb, line 55
def release(state)
  info format("[kitchen-static] Queueing release via %s handler", queueing_type)

  queueing_handler.release(state)
end
request(state) click to toggle source
# File lib/kitchen/driver/static.rb, line 49
def request(state)
  info format("[kitchen-static] Queueing request via %s handler", queueing_type)

  queueing_handler.request(state)
end
require_queueing_handlers(glob) click to toggle source
# File lib/kitchen/driver/static.rb, line 97
def require_queueing_handlers(glob)
  Dir.glob(glob).each { |file| require file }
end