aboutsummaryrefslogtreecommitdiff
path: root/spec/spec_helper_acceptance.rb
blob: 75368f3b19e0f3a753a4b82430a4136db8cac89f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
require 'puppet'
require 'beaker-rspec'
require 'beaker-puppet'
require 'beaker/module_install_helper'
require 'voxpupuli/acceptance/spec_helper_acceptance'

$LOAD_PATH << File.join(__dir__, 'acceptance/lib')

def beaker_opts
  { debug: true, trace: true, expect_failures: true, acceptable_exit_codes: (0...256) }
end

def non_windows_agents
  agents.reject { |agent| agent['platform'].include?('windows') }
end

RSpec.configure do |c|
  def run_puppet_install_helper
    return unless ENV['PUPPET_INSTALL_TYPE'] == 'agent'
    if ENV['BEAKER_PUPPET_COLLECTION'].match? %r{/-nightly$/}
      # Workaround for RE-10734
      options[:release_apt_repo_url] = 'http://nightlies.puppet.com/apt'
      options[:win_download_url] = 'http://nightlies.puppet.com/downloads/windows'
      options[:mac_download_url] = 'http://nightlies.puppet.com/downloads/mac'
    end

    agent_sha = ENV['BEAKER_PUPPET_AGENT_SHA'] || ENV['PUPPET_AGENT_SHA']
    if agent_sha.nil? || agent_sha.empty?
      install_puppet_agent_on(hosts, options.merge(version: version))
    else
      # If we have a development sha, assume we're testing internally
      dev_builds_url = ENV['DEV_BUILDS_URL'] || 'http://builds.delivery.puppetlabs.net'
      install_from_build_data_url('puppet-agent', "#{dev_builds_url}/puppet-agent/#{agent_sha}/artifacts/#{agent_sha}.yaml", hosts)
    end

    # XXX install_puppet_agent_on() will only add_aio_defaults_on when the
    # nodeset type == 'aio', but we don't want to depend on that.
    add_aio_defaults_on(hosts)
    add_puppet_paths_on(hosts)
  end

  c.before :suite do
    unless ENV['BEAKER_provision'] == 'no'
      hosts.each { |host| host[:type] = 'aio' }
      run_puppet_install_helper
      install_module_on(hosts)
      install_module_dependencies_on(hosts)
    end
  end
end