Class: Navo::Sandbox
- Inherits:
-
Object
- Object
- Navo::Sandbox
- Defined in:
- lib/navo/sandbox.rb
Overview
Manages the creation and maintenance of the test suite sandbox.
The sandbox is just a directory that contains the files and configuration needed to run a test within the suite’s container. A temporary directory on the host is maintained
Instance Method Summary collapse
-
#initialize(suite:, logger:) ⇒ Sandbox
constructor
A new instance of Sandbox.
- #update_chef_config ⇒ Object
- #update_test_config ⇒ Object
Constructor Details
#initialize(suite:, logger:) ⇒ Sandbox
Returns a new instance of Sandbox.
11 12 13 14 |
# File 'lib/navo/sandbox.rb', line 11 def initialize(suite:, logger:) @suite = suite @logger = logger end |
Instance Method Details
#update_chef_config ⇒ Object
16 17 18 19 |
# File 'lib/navo/sandbox.rb', line 16 def update_chef_config install_cookbooks install_chef_config end |
#update_test_config ⇒ Object
21 22 23 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 59 60 61 |
# File 'lib/navo/sandbox.rb', line 21 def update_test_config test_files_dir = File.join(@suite.repo_root, %w[test integration]) suite_dir = File.join(test_files_dir, @suite.name) unless File.exist?(suite_dir) @logger.warn "No test files found at #{suite_dir} for #{@suite.name} suite" return end # serverspec, bats, etc. frameworks = Pathname.new(suite_dir).children .select(&:directory?) .map(&:basename) .map(&:to_s) suites_directory = File.join(@suite.busser_directory, 'suites') @suite.exec!(%w[mkdir -p] + [suites_directory]) frameworks.each do |framework| host_framework_dir = File.join(suite_dir, framework) container_framework_dir = File.join(suites_directory, framework) @suite.exec!(%w[rm -rf] + [container_framework_dir]) # In order to work with Busser, we need to copy the helper files into # the same directory as the suite's spec files. This avoids issues with # symlinks not matching up due to differences in directory structure # between host and container (test-kitchen does the same thing). helpers_directory = File.join(test_files_dir, 'helpers', framework) if File.directory?(helpers_directory) @logger.info "Transferring #{framework} test suite helpers..." @suite.copy(from: File.join(helpers_directory, '.'), to: container_framework_dir) end @logger.info "Transferring #{framework} tests..." @suite.copy(from: File.join(host_framework_dir, '.'), to: container_framework_dir) end end |