Skip to content

Commit

Permalink
(maint) Restore acceptance shell
Browse files Browse the repository at this point in the history
This commit adds back the acceptance directory removed in puppetlabs#70 as our CI expects there to be such directory.
  • Loading branch information
donoghuc committed Mar 30, 2020
1 parent 343923e commit 4856861
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 0 deletions.
10 changes: 10 additions & 0 deletions acceptance/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.vagrant
.bundle
Gemfile.lock
local_options.rb
log
junit
id_rsa-acceptance
id_rsa-acceptance.pub
merged_options.rb
tmp
28 changes: 28 additions & 0 deletions acceptance/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

source ENV['GEM_SOURCE'] || "https://rubygems.org"

def location_for(place, fake_version = nil)
git_match = place.match(/^(git:[^#]*)#(.*)/)
file_match = place.match(%r{^file://(.*)})
if git_match
git, branch = git_match.captures
[fake_version, { git: git, branch: branch, require: false }].compact
elsif file_match
file_path = file_match[1]
['>= 0', { path: File.expand_path(file_path), require: false }]
else
[place, { require: false }]
end
end

gem "beaker", *location_for(ENV['BEAKER_VERSION'] || "~> 3.10")
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || "~> 0.2")
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || "~> 1.0")
gem 'beaker-puppet', *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 0.15')
gem 'rake', "~> 12.1"
gem 'rototiller'

if File.exist? "Gemfile.local"
eval_gemfile "Gemfile.local"
end
16 changes: 16 additions & 0 deletions acceptance/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require 'rototiller'
require_relative 'lib/acceptance/ace_setup_helper'

# rubocop:disable Style/MixinUsage
extend Acceptance::AceSetupHelper
# rubocop:enable Style/MixinUsage

namespace :test do
desc "Run ace acceptance tests against a published gem"

desc "Run ace acceptance tests against a git repo"

desc "Run ace acceptance tests against a package"
end
6 changes: 6 additions & 0 deletions acceptance/config/gem/options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

{
pre_suite: [],
load_path: './lib/acceptance'
}
7 changes: 7 additions & 0 deletions acceptance/config/git/options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

{
pre_suite: [],
load_path: './lib/acceptance',
ssh: { forward_agent: false }
}
6 changes: 6 additions & 0 deletions acceptance/config/package/options.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

{
pre_suite: [],
load_path: './lib/acceptance'
}
49 changes: 49 additions & 0 deletions acceptance/lib/acceptance/ace_command_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

module Acceptance
module AceCommandHelper
# A helper to build a bolt command used in acceptance testing
# @param [Beaker::Host] host the host to execute the command on
# @param [String] command the command to execute on the bolt SUT
# @param [Hash] flags the command flags to append to the command
# @option flags [String] '--nodes' the nodes to run on
# @option flags [String] '--user' the user to run the command as
# @option flags [String] '--password' the password for the user
# @option flags [nil] '--no-host-key-check' specify nil to use
# @option flags [nil] '--no-ssl' specify nil to use
# @param [Hash] opts the options hash for this method
def bolt_command_on(host, command, flags = {}, opts = {})
bolt_command = command.dup
flags.each { |k, v| bolt_command << " #{k} #{v}" }

case host['platform']
when /windows/
execute_powershell_script_on(host, bolt_command, opts)
when /osx/
# Ensure Bolt runs with UTF-8 under macOS. Otherwise we get issues with
# UTF-8 content in task results.
env = 'source /etc/profile ~/.bash_profile ~/.bash_login ~/.profile && env LANG=en_US.UTF-8'
on(host, env + ' ' + bolt_command)
else
on(host, bolt_command, opts)
end
end

def default_boltdir
@default_boltdir ||= begin
query = bolt['platform'] =~ /windows/ ? 'cygpath -m $(printenv HOME)' : 'printenv HOME'
home = on(bolt, query).stdout.chomp
File.join(home, '.puppetlabs/bolt')
end
end

def modulepath(extra)
case bolt['platform']
when /windows/
"\"#{default_boltdir}/modules;#{extra}\""
else
"#{default_boltdir}/modules:#{extra}"
end
end
end
end
45 changes: 45 additions & 0 deletions acceptance/lib/acceptance/ace_setup_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

module Acceptance
module AceSetupHelper
def ssh_user
ENV['SSH_USER'] || 'root'
end

def ssh_password
ENV['SSH_PASSWORD'] || 'bolt_secret_password'
end

def winrm_user
ENV['WINRM_USER'] || 'Administrator'
end

def winrm_password
ENV['WINRM_PASSWORD'] || 'bolt_secret_password'
end

def gem_version
ENV['GEM_VERSION'] || '> 0.1.0'
end

def gem_source
ENV['GEM_SOURCE'] || 'https://rubygems.org'
end

def git_server
ENV['GIT_SERVER'] || 'https://github.com'
end

def git_fork
ENV['GIT_FORK'] || 'puppetlabs/bolt'
end

def git_branch
ENV['GIT_BRANCH'] || 'master'
end

def git_sha
ENV['GIT_SHA'] || ''
end
end
end
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added acceptance/tests/.gitkeep
Empty file.

0 comments on commit 4856861

Please sign in to comment.