Skip to content

Commit

Permalink
Merge pull request #1255 from joshcooper/ticket/stable/FACT-1281-simp…
Browse files Browse the repository at this point in the history
…lify-acceptance-tests

(FACT-1281) Simplify acceptance tests
  • Loading branch information
er0ck committed Jan 13, 2016
2 parents 55ad623 + 7771c8a commit 15b3419
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 192 deletions.
2 changes: 1 addition & 1 deletion acceptance/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def location_for(place, fake_version = nil)
end
end

gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 2.27")
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 2.32")
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 0.3")
gem 'rake', "~> 10.1.0"
gem "multi_json", "~> 1.8"
Expand Down
16 changes: 4 additions & 12 deletions acceptance/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module HarnessOptions
end
end

def beaker_test(mode = :packages, options = {})
def beaker_test(mode = :aio, options = {})
final_options = HarnessOptions.options(mode, options)

if mode == :git
Expand Down Expand Up @@ -234,7 +234,7 @@ def print_preserved(preserved)
end

def beaker_run_type
type = ENV['TYPE'] || :packages
type = ENV['TYPE'] || :aio
type = type.to_sym
end

Expand Down Expand Up @@ -265,14 +265,6 @@ You may also optionally set the git server to checkout from using GIT_SERVER='my
If there is a Beaker options hash in a ./local_options.rb, it will be included. Commandline options set through the above environment variables will override settings in this file.
EOS

desc <<-EOS
Run the acceptance tests through Beaker and install packages on the configuration targets.
#{USAGE}
EOS
task :packages => 'ci:check_env' do
beaker_test
end

desc <<-EOS
Run the acceptance tests through Beaker and install packages as part of the AIO puppet-agent installation.
#{USAGE}
Expand Down Expand Up @@ -326,9 +318,9 @@ Rerun an acceptance test using the last captured preserved_config.yaml to skip p
Or specify a CONFIG_NUMBER from `rake ci:list_preserved`.
Uses the setup/rsync/pre-suite to rsync the local puppet source onto master and agent.
You may specify an RSYNC_FILTER_FILE as well.
You may skip purgeing and reinstalling puppet packages by including SKIP_PACKAGE_REINSTALL.
You may skip purging and reinstalling puppet packages by including SKIP_PACKAGE_REINSTALL.
You may skip rsyncing local puppet files over to the tests hosts by including SKIP_RSYNC.
Defaults to a packages run, but you can set it to 'git' with TYPE='git'.
Defaults to an aio run, but you can set it to 'git' with TYPE='git'.
EOS
task :test_against_preserved_hosts do
config_number = (ENV['CONFIG_NUMBER'] || 0).to_i
Expand Down
7 changes: 0 additions & 7 deletions acceptance/config/packages/options.rb

This file was deleted.

115 changes: 0 additions & 115 deletions acceptance/lib/puppet/acceptance/install_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,121 +53,6 @@ def install_packages_on(hosts, package_hash, options = {})
end
return true
end

def fetch(base_url, file_name, dst_dir)
FileUtils.makedirs(dst_dir)
src = "#{base_url}/#{file_name}"
dst = File.join(dst_dir, file_name)
if File.exists?(dst)
logger.notify "Already fetched #{dst}"
else
logger.notify "Fetching: #{src}"
logger.notify " and saving to #{dst}"
open(src) do |remote|
File.open(dst, "w") do |file|
FileUtils.copy_stream(remote, file)
end
end
end
return dst
end

def fetch_remote_dir(url, dst_dir)
logger.notify "fetch_remote_dir (url: #{url}, dst_dir #{dst_dir})"
if url[-1, 1] !~ /\//
url += '/'
end
url = URI.parse(url)
chunks = url.path.split('/')
dst = File.join(dst_dir, chunks.last)
#determine directory structure to cut
#only want to keep the last directory, thus cut total number of dirs - 2 (hostname + last dir name)
cut = chunks.length - 2
wget_command = "wget -nv -P #{dst_dir} --reject \"index.html*\",\"*.gif\" --cut-dirs=#{cut} -np -nH --no-check-certificate -r #{url}"

logger.notify "Fetching remote directory: #{url}"
logger.notify " and saving to #{dst}"
logger.notify " using command: #{wget_command}"

#in ruby 1.9+ we can upgrade this to popen3 to gain access to the subprocess pid
result = `#{wget_command} 2>&1`
result.each_line do |line|
logger.debug(line)
end
if $?.to_i != 0
raise "Failed to fetch_remote_dir '#{url}' (exit code #{$?}"
end
dst
end

def stop_firewall_on(host)
case host['platform']
when /debian/
on host, 'iptables -F'
when /fedora|el-7/
on host, puppet('resource', 'service', 'firewalld', 'ensure=stopped')
when /el|centos/
on host, puppet('resource', 'service', 'iptables', 'ensure=stopped')
when /ubuntu/
on host, puppet('resource', 'service', 'ufw', 'ensure=stopped')
else
logger.notify("Not sure how to clear firewall on #{host['platform']}")
end
end

def install_repos_on(host, project, sha, repo_configs_dir)
platform = host['platform'].with_version_codename
platform_configs_dir = File.join(repo_configs_dir,platform)
tld = sha == 'nightly' ? 'nightlies.puppetlabs.com' : 'builds.puppetlabs.lan'
project = sha == 'nightly' ? project + '-latest' : project
sha = sha == 'nightly' ? nil : sha

case platform
when /^(fedora|el|centos)-(\d+)-(.+)$/
variant = (($1 == 'centos') ? 'el' : $1)
fedora_prefix = ((variant == 'fedora') ? 'f' : '')
version = $2
arch = $3

repo_filename = "pl-%s%s-%s-%s%s-%s.repo" % [
project,
sha ? '-' + sha : '',
variant,
fedora_prefix,
version,
arch
]
repo_url = "http://%s/%s/%s/repo_configs/rpm/%s" % [tld, project, sha, repo_filename]

on host, "curl -o /etc/yum.repos.d/#{repo_filename} #{repo_url}"
when /^(debian|ubuntu)-([^-]+)-(.+)$/
variant = $1
version = $2
arch = $3

list_filename = "pl-%s%s-%s.list" % [
project,
sha ? '-' + sha : '',
version
]
list_url = "http://%s/%s/%s/repo_configs/deb/%s" % [tld, project, sha, list_filename]

on host, "curl -o /etc/apt/sources.list.d/#{list_filename} #{list_url}"
on host, "apt-get update"
else
if project == 'puppet-agent'
opts = {
:puppet_collection => 'PC1',
:puppet_agent_sha => ENV['SHA'],
:puppet_agent_version => ENV['SUITE_VERSION'] || ENV['SHA']
}
# this installs puppet-agent on windows (msi) and osx (dmg)
install_puppet_agent_dev_repo_on(agent, opts)
else
fail_test("No repository installation step for #{platform} yet...")
end
end
end
end
end
end
31 changes: 7 additions & 24 deletions acceptance/setup/aio/pre-suite/010_Install.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
require 'puppet/acceptance/common_utils'
require 'puppet/acceptance/install_utils'
extend Puppet::Acceptance::InstallUtils
require 'beaker/dsl/install_utils'
extend Beaker::DSL::InstallUtils

test_name "Install Packages"

step "Install repositories on target machines..." do
sha = ENV['SHA']
hosts.each do |host|
install_repos_on(host, 'puppet-agent', sha, 'repo-configs')
end
step "Install puppet-agent..." do
opts = {
:puppet_collection => 'PC1',
:puppet_agent_sha => ENV['SHA'],
:puppet_agent_version => ENV['SUITE_VERSION'] || ENV['SHA']
}
install_puppet_agent_dev_repo_on(hosts, opts)
end

PACKAGES = {
:redhat => [
'puppet-agent',
],
:debian => [
'puppet-agent',
],
# :solaris => [
# 'puppet',
# ],
# :windows => [
# 'puppet',
# ],
}

install_packages_on(hosts, PACKAGES)

# make sure install is sane, beaker has already added puppet and ruby
# to PATH in ~/.ssh/environment
agents.each do |agent|
Expand Down
33 changes: 0 additions & 33 deletions acceptance/setup/packages/pre-suite/010_Install.rb

This file was deleted.

0 comments on commit 15b3419

Please sign in to comment.