beaker-puppet 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/lib/beaker-puppet.rb +2 -0
- data/lib/beaker-puppet/helpers/rake_helpers.rb +21 -0
- data/lib/beaker-puppet/install_utils/foss_utils.rb +77 -0
- data/lib/beaker-puppet/version.rb +1 -1
- data/setup/aio/010_Install.rb +50 -0
- data/setup/aio/020_InstallCumulusModules.rb +12 -0
- data/setup/aio/021_InstallAristaModule.rb +20 -0
- data/setup/aio/045_EnsureMasterStarted.rb +1 -0
- data/setup/common/000-delete-puppet-when-none.rb +11 -0
- data/setup/common/025_StopFirewall.rb +16 -0
- data/setup/common/030_StopSssd.rb +9 -0
- data/setup/common/040_ValidateSignCert.rb +46 -0
- data/setup/gem/010_GemInstall.rb +40 -0
- data/setup/git/000_EnvSetup.rb +144 -0
- data/setup/git/010_TestSetup.rb +103 -0
- data/setup/git/020_PuppetUserAndGroup.rb +10 -0
- data/setup/git/030_PuppetMasterSanity.rb +18 -0
- data/setup/git/060_InstallModules.rb +76 -0
- data/setup/git/070_InstallCACerts.rb +93 -0
- data/tasks/ci.rake +233 -0
- metadata +48 -31
@@ -0,0 +1,103 @@
|
|
1
|
+
test_name "Install packages and repositories on target machines..." do
|
2
|
+
extend Beaker::DSL::InstallUtils
|
3
|
+
|
4
|
+
SourcePath = Beaker::DSL::InstallUtils::SourcePath
|
5
|
+
GitHubSig = Beaker::DSL::InstallUtils::GitHubSig
|
6
|
+
|
7
|
+
repositories = options[:install].map do |url|
|
8
|
+
extract_repo_info_from(build_git_url(url))
|
9
|
+
end
|
10
|
+
|
11
|
+
hosts.each_with_index do |host, index|
|
12
|
+
on host, "echo #{GitHubSig} >> $HOME/.ssh/known_hosts"
|
13
|
+
|
14
|
+
repositories.each do |repository|
|
15
|
+
step "Install #{repository[:name]}"
|
16
|
+
if repository[:path] =~ /^file:\/\/(.+)$/
|
17
|
+
on host, "test -d #{SourcePath} || mkdir -p #{SourcePath}"
|
18
|
+
source_dir = $1
|
19
|
+
checkout_dir = "#{SourcePath}/#{repository[:name]}"
|
20
|
+
on host, "rm -f #{checkout_dir}" # just the symlink, do not rm -rf !
|
21
|
+
on host, "ln -s #{source_dir} #{checkout_dir}"
|
22
|
+
on host, "cd #{checkout_dir} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi"
|
23
|
+
else
|
24
|
+
puppet_dir = host.tmpdir('puppet')
|
25
|
+
on(host, "chmod 755 #{puppet_dir}")
|
26
|
+
|
27
|
+
sha = ENV['SHA'] || `git rev-parse HEAD`.chomp
|
28
|
+
gem_source = ENV["GEM_SOURCE"] || "https://rubygems.org"
|
29
|
+
gemfile_contents = <<END
|
30
|
+
source '#{gem_source}'
|
31
|
+
gem '#{repository[:name]}', :git => '#{repository[:path]}', :ref => '#{sha}'
|
32
|
+
END
|
33
|
+
case host['platform']
|
34
|
+
when /windows/
|
35
|
+
create_remote_file(host, "#{puppet_dir}/Gemfile", gemfile_contents)
|
36
|
+
# bundle must be passed a Windows style path for a binstubs location
|
37
|
+
bindir = host['puppetbindir'].split(':').first
|
38
|
+
binstubs_dir = on(host, "cygpath -m \"#{bindir}\"").stdout.chomp
|
39
|
+
# note passing --shebang to bundle is not useful because Cygwin
|
40
|
+
# already finds the Ruby interpreter OK with the standard shebang of:
|
41
|
+
# !/usr/bin/env ruby
|
42
|
+
# the problem is a Cygwin style path is passed to the interpreter and this can't be modified:
|
43
|
+
# http://cygwin.1069669.n5.nabble.com/Pass-windows-style-paths-to-the-interpreter-from-the-shebang-line-td43870.html
|
44
|
+
on host, "cd #{puppet_dir} && cmd.exe /c \"bundle install --system --binstubs '#{binstubs_dir}'\""
|
45
|
+
# puppet.bat isn't written by Bundler, but facter.bat is - copy this generic file
|
46
|
+
on host, "cd #{host['puppetbindir']} && test -f ./puppet.bat || cp ./facter.bat ./puppet.bat"
|
47
|
+
# to access gem / facter / puppet / bundle / irb with Cygwin generally requires aliases
|
48
|
+
# so that commands in /usr/bin are overridden and the binstub wrappers won't run inside Cygwin
|
49
|
+
# but rather will execute as batch files through cmd.exe
|
50
|
+
# without being overridden, Cygwin reads the shebang and causes errors like:
|
51
|
+
# C:\cygwin64\bin\ruby.exe: No such file or directory -- /usr/bin/puppet (LoadError)
|
52
|
+
# NOTE /usr/bin/puppet is a Cygwin style path that our custom Ruby build
|
53
|
+
# does not understand - it expects a standard Windows path like c:\cygwin64\bin\puppet
|
54
|
+
|
55
|
+
# a workaround in interactive SSH is to add aliases to local session / .bashrc:
|
56
|
+
# on host, "echo \"alias puppet='C:/\\cygwin64/\\bin/\\puppet.bat'\" >> ~/.bashrc"
|
57
|
+
# note that this WILL NOT impact Beaker runs though
|
58
|
+
puppet_bundler_install_dir = on(host, "cd #{puppet_dir} && cmd.exe /c bundle show puppet").stdout.chomp
|
59
|
+
when /el-7/
|
60
|
+
create_remote_file(host, "#{puppet_dir}/Gemfile", gemfile_contents + "gem 'json'\n")
|
61
|
+
on host, "cd #{puppet_dir} && bundle install --system --binstubs #{host['puppetbindir']}"
|
62
|
+
puppet_bundler_install_dir = on(host, "cd #{puppet_dir} && bundle show puppet").stdout.chomp
|
63
|
+
when /solaris/
|
64
|
+
create_remote_file(host, "#{puppet_dir}/Gemfile", gemfile_contents)
|
65
|
+
on host, "cd #{puppet_dir} && bundle install --system --binstubs #{host['puppetbindir']} --shebang #{host['puppetbindir']}/ruby"
|
66
|
+
puppet_bundler_install_dir = on(host, "cd #{puppet_dir} && bundle show puppet").stdout.chomp
|
67
|
+
else
|
68
|
+
create_remote_file(host, "#{puppet_dir}/Gemfile", gemfile_contents)
|
69
|
+
on host, "cd #{puppet_dir} && bundle install --system --binstubs #{host['puppetbindir']}"
|
70
|
+
puppet_bundler_install_dir = on(host, "cd #{puppet_dir} && bundle show puppet").stdout.chomp
|
71
|
+
end
|
72
|
+
|
73
|
+
# install.rb should also be called from the Puppet gem install dir
|
74
|
+
# this is required for the puppetres.dll event log dll on Windows
|
75
|
+
on host, "cd #{puppet_bundler_install_dir} && if [ -f install.rb ]; then ruby ./install.rb ; else true; fi"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
step "Hosts: create basic puppet.conf" do
|
81
|
+
hosts.each do |host|
|
82
|
+
confdir = host.puppet['confdir']
|
83
|
+
on host, "mkdir -p #{confdir}"
|
84
|
+
puppetconf = File.join(confdir, 'puppet.conf')
|
85
|
+
|
86
|
+
if host['roles'].include?('agent')
|
87
|
+
on host, "echo '[agent]' > '#{puppetconf}' && " +
|
88
|
+
"echo server=#{master} >> '#{puppetconf}'"
|
89
|
+
else
|
90
|
+
on host, "touch '#{puppetconf}'"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
step "Hosts: create environments directory like AIO does" do
|
96
|
+
hosts.each do |host|
|
97
|
+
codedir = host.puppet['codedir']
|
98
|
+
on host, "mkdir -p #{codedir}/environments/production/manifests"
|
99
|
+
on host, "mkdir -p #{codedir}/environments/production/modules"
|
100
|
+
on host, "chmod -R 755 #{codedir}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
test_name 'Puppet User and Group' do
|
2
|
+
hosts.each do |host|
|
3
|
+
|
4
|
+
step "ensure puppet user and group added to all nodes because this is what the packages do" do
|
5
|
+
on host, puppet("resource user puppet ensure=present")
|
6
|
+
on host, puppet("resource group puppet ensure=present")
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
test_name "Puppet Master sanity checks: PID file and SSL dir creation"
|
2
|
+
|
3
|
+
hostname = on(master, 'facter hostname').stdout.strip
|
4
|
+
fqdn = on(master, 'facter fqdn').stdout.strip
|
5
|
+
|
6
|
+
with_puppet_running_on(master, :main => { :dns_alt_names => "puppet,#{hostname},#{fqdn}", :verbose => true, :noop => true }) do
|
7
|
+
# SSL dir created?
|
8
|
+
step "SSL dir created?"
|
9
|
+
on master, "[ -d #{master.puppet('master')['ssldir']} ]"
|
10
|
+
|
11
|
+
# PID file exists?
|
12
|
+
step "PID file created?"
|
13
|
+
on master, "[ -f #{master.puppet('master')['pidfile']} ]"
|
14
|
+
end
|
15
|
+
|
16
|
+
step "Create module directories normally handled via packaging"
|
17
|
+
on master, "mkdir -p #{master['distmoduledir']}"
|
18
|
+
on master, "mkdir -p #{master['sitemoduledir']}"
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# Given an array of modules specified by the --modules command line option,
|
4
|
+
# Parse all of them into an array of usable hash structures.
|
5
|
+
class PuppetModules
|
6
|
+
attr_reader :modules
|
7
|
+
|
8
|
+
def initialize(modules=[])
|
9
|
+
@modules = modules
|
10
|
+
end
|
11
|
+
|
12
|
+
def list
|
13
|
+
return [] unless modules
|
14
|
+
modules.collect do |uri|
|
15
|
+
git_url, git_ref = uri.split '#'
|
16
|
+
folder = Pathname.new(git_url).basename('.git')
|
17
|
+
name = folder.to_s.split('-', 2)[1] || folder.to_s
|
18
|
+
{
|
19
|
+
:name => name,
|
20
|
+
:url => git_url,
|
21
|
+
:folder => folder.to_s,
|
22
|
+
:ref => git_ref,
|
23
|
+
:protocol => git_url.split(':')[0].intern,
|
24
|
+
}
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def install_git_module(mod, hosts)
|
30
|
+
# The idea here is that each test can symlink the modules they want from a
|
31
|
+
# temporary directory to this location. This will preserve the global
|
32
|
+
# state of the system while allowing individual test cases to quickly run
|
33
|
+
# with a module "installed" in the module path.
|
34
|
+
moddir = "/opt/puppet-git-repos"
|
35
|
+
target = "#{moddir}/#{mod[:name]}"
|
36
|
+
|
37
|
+
step "Clone #{mod[:url]} if needed"
|
38
|
+
on hosts, "test -d #{moddir} || mkdir -p #{moddir}"
|
39
|
+
on hosts, "test -d #{target} || git clone #{mod[:url]} #{target}"
|
40
|
+
step "Update #{mod[:name]} and check out revision #{mod[:ref]}"
|
41
|
+
|
42
|
+
commands = ["cd #{target}",
|
43
|
+
"remote rm origin",
|
44
|
+
"remote add origin #{mod[:url]}",
|
45
|
+
"fetch origin",
|
46
|
+
"checkout -f #{mod[:ref]}",
|
47
|
+
"reset --hard refs/remotes/origin/#{mod[:ref]}",
|
48
|
+
"clean -fdx",
|
49
|
+
]
|
50
|
+
|
51
|
+
on hosts, commands.join(" && git ")
|
52
|
+
end
|
53
|
+
|
54
|
+
def install_scp_module(mod, hosts)
|
55
|
+
moddir = "/opt/puppet-git-repos"
|
56
|
+
target = "#{moddir}/#{mod[:name]}"
|
57
|
+
|
58
|
+
step "Purge #{target} if needed"
|
59
|
+
on hosts, "test -d #{target} && rm -rf #{target} || true"
|
60
|
+
|
61
|
+
step "Copy #{mod[:name]} to hosts"
|
62
|
+
scp_to hosts, mod[:url].split(':', 2)[1], target
|
63
|
+
end
|
64
|
+
|
65
|
+
modules = PuppetModules.new(options[:modules]).list
|
66
|
+
|
67
|
+
step "Masters: Install Puppet Modules"
|
68
|
+
masters = hosts.select { |host| host['roles'].include? 'master' }
|
69
|
+
|
70
|
+
modules.each do |mod|
|
71
|
+
if mod[:protocol] == :scp
|
72
|
+
install_scp_module(mod, masters)
|
73
|
+
else
|
74
|
+
install_git_module(mod, masters)
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
test_name "Install CA Certs"
|
2
|
+
confine :to, :platform => 'windows'
|
3
|
+
|
4
|
+
GEOTRUST_GLOBAL_CA = <<-EOM
|
5
|
+
-----BEGIN CERTIFICATE-----
|
6
|
+
MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
|
7
|
+
MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
|
8
|
+
YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhc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voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee9570+sB3c4
|
75
|
+
-----END CERTIFICATE-----
|
76
|
+
EOM
|
77
|
+
|
78
|
+
hosts.each do |host|
|
79
|
+
step "Installing Geotrust CA cert"
|
80
|
+
create_remote_file(host, "geotrustglobal.pem", GEOTRUST_GLOBAL_CA)
|
81
|
+
on host, "chmod 644 geotrustglobal.pem"
|
82
|
+
on host, "cmd /c certutil -v -addstore Root `cygpath -w geotrustglobal.pem`"
|
83
|
+
|
84
|
+
step "Installing Usertrust Network CA cert"
|
85
|
+
create_remote_file(host, "usertrust-network.pem", USERTRUST_NETWORK_CA)
|
86
|
+
on host, "chmod 644 usertrust-network.pem"
|
87
|
+
on host, "cmd /c certutil -v -addstore Root `cygpath -w usertrust-network.pem`"
|
88
|
+
|
89
|
+
step "Installing Equifax CA cert"
|
90
|
+
create_remote_file(host, "equifax.pem", EQUIFAX_CA)
|
91
|
+
on host, "chmod 644 equifax.pem"
|
92
|
+
on host, "cmd /c certutil -v -addstore Root `cygpath -w equifax.pem`"
|
93
|
+
end
|
data/tasks/ci.rake
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'pp'
|
3
|
+
require 'yaml'
|
4
|
+
require 'securerandom'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'beaker-hostgenerator'
|
7
|
+
require 'beaker/dsl/install_utils'
|
8
|
+
extend Beaker::DSL::InstallUtils
|
9
|
+
|
10
|
+
REPO_CONFIGS_DIR = 'repo-configs'
|
11
|
+
CLEAN.include('*.tar', REPO_CONFIGS_DIR, 'tmp', '.beaker')
|
12
|
+
|
13
|
+
# Default test target if none specified
|
14
|
+
DEFAULT_MASTER_TEST_TARGET = 'redhat7-64m'
|
15
|
+
DEFAULT_TEST_TARGETS = "#{DEFAULT_MASTER_TEST_TARGET}a-windows2012r2-64a"
|
16
|
+
|
17
|
+
USAGE = <<-EOS
|
18
|
+
Usage: bundle exec rake <target> [arguments]
|
19
|
+
|
20
|
+
where <target> is one of:
|
21
|
+
|
22
|
+
ci:test:git
|
23
|
+
ci:test:aio
|
24
|
+
ci:test:gem
|
25
|
+
ci:test:quick
|
26
|
+
|
27
|
+
See `bundle exec rake -D <target>` for information about each target. Each rake
|
28
|
+
task accepts the following environment variables:
|
29
|
+
|
30
|
+
REQUIRED
|
31
|
+
--------
|
32
|
+
|
33
|
+
SHA:
|
34
|
+
The git SHA of either the puppet-agent package or component repo must be
|
35
|
+
specified depending on the target. The `git` and `gem` use the component
|
36
|
+
SHA, where as `aio` and `quick` use the puppet-agent package SHA.
|
37
|
+
|
38
|
+
OPTIONAL
|
39
|
+
--------
|
40
|
+
|
41
|
+
HOSTS:
|
42
|
+
The hosts to run against. Must be specified as a path to a file or a
|
43
|
+
beaker-hostgenerator string. Defaults to #{DEFAULT_TEST_TARGETS}.
|
44
|
+
|
45
|
+
HOSTS=mynodes.yaml
|
46
|
+
HOSTS=redhat7-64ma
|
47
|
+
|
48
|
+
TESTS:
|
49
|
+
A comma-delimited list of files/directories containing tests to run.
|
50
|
+
Defaults to running all tests, except for `ci:test:quick` which defaults
|
51
|
+
to running a predefined set of tests.
|
52
|
+
|
53
|
+
TESTS=tests/cycle_detection.rb
|
54
|
+
TESTS=tests/pluginsync,tests/language
|
55
|
+
|
56
|
+
OPTIONS:
|
57
|
+
Additional options to pass to beaker. Defaults to ''.
|
58
|
+
|
59
|
+
OPTIONS='--dry-run --no-color'
|
60
|
+
|
61
|
+
BEAKER_HOSTS:
|
62
|
+
Same as HOSTS.
|
63
|
+
|
64
|
+
TEST_TARGET:
|
65
|
+
A beaker-hostgenerator string of agent-only hosts to run against.
|
66
|
+
The MASTER_TEST_TARGET host will be added this list. This option is
|
67
|
+
only intended to be used in CI.
|
68
|
+
|
69
|
+
MASTER_TEST_TARGET:
|
70
|
+
Override the default master test target. Should only be used with
|
71
|
+
TEST_TARGET, and is only intended to be used in CI. Defaults to
|
72
|
+
#{DEFAULT_MASTER_TEST_TARGET}.
|
73
|
+
EOS
|
74
|
+
|
75
|
+
namespace :ci do
|
76
|
+
desc "Print usage information"
|
77
|
+
task :help do
|
78
|
+
puts USAGE
|
79
|
+
exit 1
|
80
|
+
end
|
81
|
+
|
82
|
+
task :check_env do
|
83
|
+
if ENV['SHA'].nil?
|
84
|
+
puts "Error: A SHA must be specified"
|
85
|
+
puts "\n"
|
86
|
+
puts USAGE
|
87
|
+
exit 1
|
88
|
+
end
|
89
|
+
|
90
|
+
if ENV['TESTS'].nil?
|
91
|
+
ENV['TESTS'] ||= ENV['TEST']
|
92
|
+
ENV['TESTS'] ||= 'tests'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
task :gen_hosts do
|
97
|
+
hosts =
|
98
|
+
if ENV['HOSTS']
|
99
|
+
ENV['HOSTS']
|
100
|
+
elsif ENV['BEAKER_HOSTS']
|
101
|
+
ENV['BEAKER_HOSTS']
|
102
|
+
elsif env_config = ENV['CONFIG']
|
103
|
+
puts 'Warning: environment variable CONFIG deprecated. Please use HOSTS to match beaker options.'
|
104
|
+
env_config
|
105
|
+
else
|
106
|
+
# By default we assume TEST_TARGET is an agent-only string
|
107
|
+
if agent_target = ENV['TEST_TARGET']
|
108
|
+
master_target = ENV['MASTER_TEST_TARGET'] || DEFAULT_MASTER_TEST_TARGET
|
109
|
+
"#{master_target}-#{agent_target}"
|
110
|
+
else
|
111
|
+
DEFAULT_TEST_TARGETS
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
if File.exists?(hosts)
|
116
|
+
ENV['HOSTS'] = hosts
|
117
|
+
else
|
118
|
+
hosts_file = "tmp/#{hosts}-#{SecureRandom.uuid}.yaml"
|
119
|
+
cli = BeakerHostGenerator::CLI.new([hosts, '--disable-default-role', '--osinfo-version', '1'])
|
120
|
+
FileUtils.mkdir_p('tmp') # -p ignores when dir already exists
|
121
|
+
File.open(hosts_file, 'w') do |fh|
|
122
|
+
fh.print(cli.execute)
|
123
|
+
end
|
124
|
+
ENV['HOSTS'] = hosts_file
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
namespace :test do
|
129
|
+
desc <<-EOS
|
130
|
+
Run the acceptance tests using puppet-agent (AIO) packages.
|
131
|
+
|
132
|
+
$ SHA=<full sha> bundle exec rake ci:test:aio
|
133
|
+
|
134
|
+
SHA should be the full SHA for the puppet-agent package.
|
135
|
+
EOS
|
136
|
+
task :aio => ['ci:check_env', 'ci:gen_hosts'] do
|
137
|
+
beaker_suite(:aio)
|
138
|
+
end
|
139
|
+
|
140
|
+
desc <<-EOS
|
141
|
+
Run the acceptance tests against puppet gem on various platforms, performing a
|
142
|
+
basic smoke test.
|
143
|
+
|
144
|
+
$ SHA=<full sha> bundle exec rake:ci:gem
|
145
|
+
|
146
|
+
SHA should be the full SHA for the component.
|
147
|
+
EOS
|
148
|
+
task :gem => ['ci:check_env'] do
|
149
|
+
beaker(:init, '--hosts', 'config/nodes/gem.yaml', '--options-file', 'config/gem/options.rb')
|
150
|
+
beaker(:provision)
|
151
|
+
beaker(:exec, 'pre-suite', '--pre-suite', pre_suites(:gem))
|
152
|
+
beaker(:exec, "#{File.dirname(__dir__)}/setup/gem/010_GemInstall.rb")
|
153
|
+
beaker(:destroy)
|
154
|
+
end
|
155
|
+
|
156
|
+
desc <<-EOS
|
157
|
+
Run the acceptance tests against a git checkout.
|
158
|
+
|
159
|
+
$ SHA=<full sha> bundle exec rake ci:test:git
|
160
|
+
|
161
|
+
SHA should be the full SHA for the component. Other options:
|
162
|
+
|
163
|
+
FORK: to test against your fork, defaults to 'puppetlabs'
|
164
|
+
|
165
|
+
SERVER: to git fetch from an alternate GIT server, defaults to 'github.com'
|
166
|
+
EOS
|
167
|
+
task :git => ['ci:check_env', 'ci:gen_hosts'] do
|
168
|
+
beaker_suite(:git)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
task :test_and_preserve_hosts => ['ci:check_env', 'ci:gen_hosts'] do
|
173
|
+
puts "WARNING, the test_and_preserve_hosts task is deprecated, use ci:test:aio instead."
|
174
|
+
Rake::Task['ci:test:aio'].execute
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
task :default do
|
179
|
+
sh('rake -T')
|
180
|
+
end
|
181
|
+
|
182
|
+
task :spec do
|
183
|
+
sh('rspec lib')
|
184
|
+
end
|
185
|
+
|
186
|
+
def beaker(command, *argv)
|
187
|
+
argv.concat(ENV['OPTIONS'].split(' ')) if ENV['OPTIONS']
|
188
|
+
|
189
|
+
sh('beaker', command.to_s, *argv)
|
190
|
+
end
|
191
|
+
|
192
|
+
def beaker_suite(type)
|
193
|
+
beaker(:init, '--hosts', ENV['HOSTS'], '--options-file', "config/#{String(type)}/options.rb")
|
194
|
+
beaker(:provision)
|
195
|
+
beaker(:exec, 'pre-suite', '--pre-suite', pre_suites(type))
|
196
|
+
beaker(:exec, ENV['TESTS'])
|
197
|
+
beaker(:destroy)
|
198
|
+
end
|
199
|
+
|
200
|
+
def pre_suites(type)
|
201
|
+
beaker_root = File.dirname(__dir__)
|
202
|
+
presuites = case type
|
203
|
+
when :aio
|
204
|
+
[
|
205
|
+
"#{beaker_root}/setup/common/000-delete-puppet-when-none.rb",
|
206
|
+
"#{beaker_root}/setup/aio/010_Install.rb",
|
207
|
+
"#{beaker_root}/setup/aio/020_InstallCumulusModules.rb",
|
208
|
+
"#{beaker_root}/setup/aio/021_InstallAristaModule.rb",
|
209
|
+
"#{beaker_root}/setup/common/025_StopFirewall.rb",
|
210
|
+
"#{beaker_root}/setup/common/030_StopSssd.rb",
|
211
|
+
"#{beaker_root}/setup/common/040_ValidateSignCert.rb",
|
212
|
+
"#{beaker_root}/setup/aio/045_EnsureMasterStarted.rb",
|
213
|
+
]
|
214
|
+
when :gem
|
215
|
+
[
|
216
|
+
"#{beaker_root}/setup/common/000-delete-puppet-when-none.rb",
|
217
|
+
"#{beaker_root}/setup/git/000_EnvSetup.rb",
|
218
|
+
]
|
219
|
+
when :git
|
220
|
+
[
|
221
|
+
"#{beaker_root}/setup/common/000-delete-puppet-when-none.rb",
|
222
|
+
"#{beaker_root}/setup/git/000_EnvSetup.rb",
|
223
|
+
"#{beaker_root}/setup/git/010_TestSetup.rb",
|
224
|
+
"#{beaker_root}/setup/git/020_PuppetUserAndGroup.rb",
|
225
|
+
"#{beaker_root}/setup/common/025_StopFirewall.rb",
|
226
|
+
"#{beaker_root}/setup/git/030_PuppetMasterSanity.rb",
|
227
|
+
"#{beaker_root}/setup/common/040_ValidateSignCert.rb",
|
228
|
+
"#{beaker_root}/setup/git/060_InstallModules.rb",
|
229
|
+
"#{beaker_root}/setup/git/070_InstallCACerts.rb",
|
230
|
+
]
|
231
|
+
end
|
232
|
+
presuites.join(',')
|
233
|
+
end
|