Module: BeakerRSpec::BeakerShim

Includes:
Beaker::DSL
Defined in:
lib/beaker-rspec/beaker_shim.rb

Overview

BeakerShim Module

This module provides the connection between rspec and the Beaker DSL. Additional wrappers are provided around commonly executed sets of Beaker commands.

Instance Method Summary collapse

Instance Method Details

#cleanupObject

Cleanup the testing framework, shut down test boxen and tidy up



66
67
68
# File 'lib/beaker-rspec/beaker_shim.rb', line 66

def cleanup
  @network_manager.cleanup
end

#configureObject

Run configuration steps to have hosts ready to test on (such as ensuring that hosts are correctly time synched, adding keys, etc). Assumes #setup, #provision and #validate have already been called.



42
43
44
# File 'lib/beaker-rspec/beaker_shim.rb', line 42

def configure
  @network_manager.configure
end

#hostsArray<Beaker::Host>

Accessor for hosts object



61
62
63
# File 'lib/beaker-rspec/beaker_shim.rb', line 61

def hosts
  RSpec.configuration.hosts
end

#loggerObject

Accessor for logger



14
15
16
# File 'lib/beaker-rspec/beaker_shim.rb', line 14

def logger
  @logger
end

#optionsObject

Accessor for options hash



20
21
22
# File 'lib/beaker-rspec/beaker_shim.rb', line 20

def options
  RSpec.configuration.options
end

#provisionObject

Provision the hosts to run tests on. Assumes #setup has already been called.



27
28
29
30
# File 'lib/beaker-rspec/beaker_shim.rb', line 27

def provision
  @network_manager = Beaker::NetworkManager.new(options, @logger)
  RSpec.configuration.hosts = @network_manager.provision
end

#puppet_module_install(opts = {}) ⇒ Object

Copy a puppet module from a given source to all hosts under test. Assumes each host under test has an associated ‘distmoduledir’ (set in the host configuration YAML file).

Options Hash (opts):

  • :source (String)

    The location on the test runners box where the files are found

  • :module_name (String)

    The name of the module to be copied over



77
78
79
80
81
# File 'lib/beaker-rspec/beaker_shim.rb', line 77

def puppet_module_install opts = {}
  hosts.each do |host|
    scp_to host, opts[:source], File.join(host['distmoduledir'], opts[:module_name])
  end
end

#setup(args = []) ⇒ Object

Setup the testing environment See ‘beaker –help’ for full list of supported command line options



49
50
51
52
53
54
55
56
57
# File 'lib/beaker-rspec/beaker_shim.rb', line 49

def setup(args = [])
  options_parser = Beaker::Options::Parser.new
  options = options_parser.parse_args(args)
  options[:debug] = true
  @logger = Beaker::Logger.new(options)
  options[:logger] = @logger
  RSpec.configuration.hosts = []
  RSpec.configuration.options = options
end

#validateObject

Validate that the SUTs are up and correctly configured. Checks that required packages are installed and if they are missing attempt installation. Assumes #setup and #provision has already been called.



35
36
37
# File 'lib/beaker-rspec/beaker_shim.rb', line 35

def validate
  @network_manager.validate
end