Skip to content

Commit

Permalink
Merge pull request #1244 from kylog/joshcooper-ticket/stable/FACT-1281-…
Browse files Browse the repository at this point in the history
…use-beaker-hg

(FACT-1281) Allow host configs to be generated at runtime
  • Loading branch information
Kylo Ginsberg committed Dec 28, 2015
2 parents 0746fab + f5ca4e4 commit 1191590
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions acceptance/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def location_for(place, fake_version = nil)
end

gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 2.27")
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 0.2")
gem 'rake', "~> 10.1.0"
gem "multi_json", "~> 1.8"

Expand Down
24 changes: 22 additions & 2 deletions acceptance/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'rake/clean'
require 'pp'
require 'yaml'
require 'securerandom'
require 'fileutils'
require 'beaker-hostgenerator'

$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
require 'puppet/acceptance/git_utils'
extend Puppet::Acceptance::GitUtils
Expand Down Expand Up @@ -89,7 +93,22 @@ EOS
tests = ENV['TESTS'] || ENV['TEST']
tests_opt = "--tests=#{tests}" if tests

config_opt = "--hosts=#{config}" if config
# The 'if ...' suffix conditional below is a temporary measure which should go
# away once the pipeline changes are made so that TEST_TARGET is always
# intended for use with beaker-hostgenerator. So please remove that
# conditional (and this comment) once that pipeline change is made.
target = ENV['TEST_TARGET'] if ENV['TEST_TARGET'] && ENV['TEST_TARGET'][-1,1] == 'a'
if target
cli = BeakerHostGenerator::CLI.new([target, '--disable-default-role'])
ENV['CONFIG'] = "tmp/#{target}-#{SecureRandom.uuid}.yaml"
FileUtils.mkdir_p('tmp')
File.open(config, 'w') do |fh|
fh.print(cli.execute)
end
config_opt = "--hosts=#{config}"
elsif config
config_opt = "--hosts=#{config}"
end

overriding_options = ENV['OPTIONS']

Expand Down Expand Up @@ -241,7 +260,8 @@ namespace :ci do

USAGE = <<-EOS
Requires commit SHA to be put under test as environment variable: SHA='<sha>'.
Also must set CONFIG=config/nodes/foo.yaml or include it in an options.rb for Beaker.
Also must set CONFIG=config/nodes/foo.yaml or include it in an options.rb for Beaker,
or specify TEST_TARGET in a form beaker-hostgenerator accepts, e.g. ubuntu1504-64a.
You may set TESTS=path/to/test,and/more/tests.
You may set additional Beaker OPTIONS='--more --options'
If testing from git checkouts, you may optionally set the github fork to checkout from using FORK='other-puppet-fork'.
Expand Down

0 comments on commit 1191590

Please sign in to comment.