2014-05-07 11:49:25 +02:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
2014-03-12 19:22:23 +01:00
|
|
|
require 'beaker-rspec'
|
2015-07-10 02:11:10 +02:00
|
|
|
require 'beaker/puppet_install_helper'
|
2014-03-12 19:22:23 +01:00
|
|
|
|
|
|
|
UNSUPPORTED_PLATFORMS = []
|
|
|
|
|
2015-07-10 02:11:10 +02:00
|
|
|
run_puppet_install_helper
|
2014-03-12 19:22:23 +01:00
|
|
|
|
|
|
|
RSpec.configure do |c|
|
|
|
|
# Project root
|
|
|
|
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
|
|
|
|
|
|
# Readable test descriptions
|
|
|
|
c.formatter = :documentation
|
|
|
|
|
|
|
|
# Configure all nodes in nodeset
|
|
|
|
c.before :suite do
|
2015-04-09 16:56:43 +02:00
|
|
|
if ENV['FUTURE_PARSER'] == 'yes'
|
2014-10-28 23:27:24 +01:00
|
|
|
default[:default_apply_opts] ||= {}
|
|
|
|
default[:default_apply_opts].merge!({:parser => 'future'})
|
|
|
|
end
|
|
|
|
|
2014-11-12 00:33:43 +01:00
|
|
|
copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib')
|
2014-03-12 19:22:23 +01:00
|
|
|
end
|
|
|
|
end
|
2014-10-28 23:27:24 +01:00
|
|
|
|
|
|
|
def is_future_parser_enabled?
|
2016-04-13 21:50:11 +02:00
|
|
|
if default[:type] == 'aio' || ENV['PUPPET_INSTALL_TYPE'] == 'agent'
|
2015-06-19 23:29:42 +02:00
|
|
|
return true
|
|
|
|
elsif default[:default_apply_opts]
|
2014-10-28 23:27:24 +01:00
|
|
|
return default[:default_apply_opts][:parser] == 'future'
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
2015-07-22 18:30:39 +02:00
|
|
|
|
2015-09-21 23:12:25 +02:00
|
|
|
def get_puppet_version
|
|
|
|
(on default, puppet('--version')).output.chomp
|
|
|
|
end
|
|
|
|
|
2015-07-22 18:30:39 +02:00
|
|
|
RSpec.shared_context "with faked facts" do
|
|
|
|
let(:facts_d) do
|
2015-09-21 23:12:25 +02:00
|
|
|
puppet_version = get_puppet_version
|
2015-08-11 01:15:54 +02:00
|
|
|
if fact('osfamily') =~ /windows/i
|
|
|
|
if fact('kernelmajversion').to_f < 6.0
|
|
|
|
'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
|
2015-07-22 18:30:39 +02:00
|
|
|
else
|
2015-08-11 01:15:54 +02:00
|
|
|
'C:/ProgramData/PuppetLabs/facter/facts.d'
|
|
|
|
end
|
2015-08-12 04:52:43 +02:00
|
|
|
elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true"
|
2015-08-11 17:29:48 +02:00
|
|
|
'/etc/puppetlabs/facter/facts.d'
|
2015-07-22 18:30:39 +02:00
|
|
|
else
|
|
|
|
'/etc/facter/facts.d'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
before :each do
|
|
|
|
#No need to create on windows, PE creates by default
|
|
|
|
if fact('osfamily') !~ /windows/i
|
|
|
|
shell("mkdir -p '#{facts_d}'")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
after :each do
|
2015-08-12 01:23:06 +02:00
|
|
|
shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1])
|
2015-07-22 18:30:39 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def fake_fact(name, value)
|
|
|
|
shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'")
|
|
|
|
end
|
|
|
|
end
|