Skip to content

Commit

Permalink
Fix registry testing, remove dependency of master to enable both foss…
Browse files Browse the repository at this point in the history
… and pe testing
  • Loading branch information
Travis Fields committed Aug 22, 2014
1 parent f537363 commit 18becea
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 351 deletions.
8 changes: 6 additions & 2 deletions Gemfile
Expand Up @@ -10,16 +10,20 @@ def location_for(place, fake_version = nil)
end
end

beaker_version = ENV['BEAKER_VERSION']
group :development, :test do
gem 'rake', :require => false
gem 'mocha', '~>0.10.5', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'serverspec', :require => false
gem 'puppet-lint', :require => false
gem 'pry', :require => false
gem 'simplecov', :require => false
gem 'rspec', '~>2.14.0', :require => false
gem 'beaker', :require => false, :platforms => :ruby
if beaker_version
gem 'beaker', *location_for(beaker_version), :platforms => :ruby
else
gem 'beaker', :require => false, :platforms => :ruby
end
end

is_x64 = Gem::Platform.local.cpu == 'x64'
Expand Down
4 changes: 2 additions & 2 deletions acceptance/.beaker-pe.cfg
Expand Up @@ -3,8 +3,8 @@
:hosts_file => './acceptance/config/windows-2012-x86_64.cfg',
:type => "pe",
:pre_suite => ['./acceptance/setup/install_pe.rb'],
:tests => "./acceptance/tests",
:pe_dir => "http://neptune.delivery.puppetlabs.net/3.2/ci-ready",
:tests => "./acceptance/tests/",
:pe_dir => "http://neptune.delivery.puppetlabs.net/3.4/ci-ready",
:debug => true,
:timeout => 6000,
:ntp => true,
Expand Down
17 changes: 17 additions & 0 deletions acceptance/config/masterless-windows-2008-x86_64.cfg
@@ -0,0 +1,17 @@
HOSTS:
w2008:
roles:
- agent
- default
platform: windows-2008-x86_64
template: win-2008-x86_64
hypervisor: vcloud
CONFIG:
type: foss
keyfile: ~/.ssh/id_rsa-acceptance
nfs_server: none
consoleport: 443
datastore: instance0
folder: Delivery/Quality Assurance/FOSS/Dynamic
resourcepool: delivery/Quality Assurance/FOSS/Dynamic
pooling_api: http://vcloud.delivery.puppetlabs.net/
17 changes: 17 additions & 0 deletions acceptance/config/masterless-windows-2008r2-x86_64.cfg
@@ -0,0 +1,17 @@
HOSTS:
w2008r2:
roles:
- agent
- default
platform: windows-2008r2-x86_64
template: win-2008r2-x86_64
hypervisor: vcloud
CONFIG:
type: foss
keyfile: ~/.ssh/id_rsa-acceptance
nfs_server: none
consoleport: 443
datastore: instance0
folder: Delivery/Quality Assurance/FOSS/Dynamic
resourcepool: delivery/Quality Assurance/FOSS/Dynamic
pooling_api: http://vcloud.delivery.puppetlabs.net/
17 changes: 17 additions & 0 deletions acceptance/config/masterless-windows-2012-x86_64.cfg
@@ -0,0 +1,17 @@
HOSTS:
w2012:
roles:
- agent
- default
platform: windows-2012-x86_64
template: win-2012-x86_64
hypervisor: vcloud
CONFIG:
type: foss
keyfile: ~/.ssh/id_rsa-acceptance
nfs_server: none
consoleport: 443
datastore: instance0
folder: Delivery/Quality Assurance/FOSS/Dynamic
resourcepool: delivery/Quality Assurance/FOSS/Dynamic
pooling_api: http://vcloud.delivery.puppetlabs.net/
17 changes: 17 additions & 0 deletions acceptance/config/masterless-windows-2012r2-x86_64.cfg
@@ -0,0 +1,17 @@
HOSTS:
w2012r2:
roles:
- agent
- default
platform: windows-2012r2-x86_64
template: win-2012r2-x86_64
hypervisor: vcloud
CONFIG:
type: foss
keyfile: ~/.ssh/id_rsa-acceptance
nfs_server: none
consoleport: 443
datastore: instance0
folder: Delivery/Quality Assurance/FOSS/Dynamic
resourcepool: delivery/Quality Assurance/FOSS/Dynamic
pooling_api: http://vcloud.delivery.puppetlabs.net/
91 changes: 52 additions & 39 deletions acceptance/lib/systest/util/registry.rb
Expand Up @@ -41,13 +41,15 @@ def chmod(host, mode, path)
def all_hosts
# we need one list of all of the hosts, to assist in managing temp dirs. It's possible
# that the master is also an agent, so this will consolidate them into a unique set
@all_hosts ||= Set[master, *agents]
hosts
end

def host_test_tmp_dirs
# now we can create a hash of temp dirs--one per host, and unique to this test--without worrying about
# doing it twice on any individual host
@host_test_tmp_dirs ||= Hash[all_hosts.map do |host| [host.name, tmpdir(host, cur_test_file_shortname)] end ]
@host_test_tmp_dirs ||= Hash[all_hosts.map do |host|
[host.name, tmpdir(host, cur_test_file_shortname)]
end]
end

def master_manifest_dir
Expand All @@ -71,7 +73,7 @@ def agent_lib_dir
end

def masters
@masters ||= hosts.select { |host| host['roles'].include? 'master' }
@masters ||= hosts.select { |host| host['roles'].include? 'master' } || []
end

def windows_agents
Expand All @@ -80,14 +82,15 @@ def windows_agents

def master_options
@master_options ||= "--manifest=\"#{get_test_file_path(master, master_manifest_file)}\" " +
"--modulepath=\"#{get_test_file_path(master, master_module_dir)}\" " +
"--autosign true --pluginsync"
"--modulepath=\"#{get_test_file_path(master, master_module_dir)}\" " +
"--autosign true --pluginsync"
end

def master_options_hash
@master_options_hash ||= {
:manifest => "#{get_test_file_path(master, master_manifest_file)}",
:manifest => "#{get_test_file_path(master, master_manifest_file)}",
:modulepath => "#{get_test_file_path(master, master_module_dir)} ",
:autosign => true,
:autosign => true,
:pluginsync => true
}
end
Expand Down Expand Up @@ -145,57 +148,67 @@ def create_test_file(host, file_rel_path, file_content, options)
mkdirs(host, File.dirname(file_path)) if (options[:mkdirs] == true)
create_remote_file(host, file_path, file_content)
#
# NOTE: we need these chown/chmod calls because the acceptance framework connects to the nodes as "root", but
# NOTE: we need these `chown/chmod calls because the acceptance framework connects to the nodes as "root", but
# puppet 'master' runs as user 'puppet'. Therefore, in order for puppet master to be able to read any files
# that we've created, we have to carefully set their permissions
#
chown(host, options[:owner], options[:group], file_path)
chmod(host, options[:mode], file_path)
end

def puppet_module_install(host = nil, source = nil, module_name = nil, module_path = '/etc/puppet/modules')
opts = {:source => source, :module_name => module_name,:target_module_path => module_path}
copy_root_module_to(host,opts)
opts = {:source => source, :module_name => module_name, :target_module_path => module_path}
copy_root_module_to(host, opts)
end

def setup_master(master_manifest_content="# Intentionally Blank\n")
step "Setup Puppet Master Manifest" do
proj_root = File.expand_path(File.join(File.dirname(__FILE__),'../../../../'))
masters.each do |host|
puppet_module_install(host,proj_root,'registry',File.join(host['puppetpath'],"modules"))
create_test_file(host, master_manifest_file, master_manifest_content, :mkdirs => true)
puppet_conf_update_ini = <<-MANIFEST
ini_setting{'Update Puppet.Conf':
ensure => present,
section => 'main',
key_val_separator => '=',
path => '#{host['puppetpath']}/puppet.conf',
setting => 'manifestdir',
value => '#{host_test_tmp_dirs[host.name]}/master_manifest/' }
MANIFEST
on host, puppet('apply','--debug'), :stdin => puppet_conf_update_ini
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../'))
if any_hosts_as?('master') do
masters.each do |host|
puppet_module_install(host, proj_root, 'registry', File.join(host['puppetpath'], "modules"))
create_test_file(host, master_manifest_file, master_manifest_content, :mkdirs => true)
puppet_conf_update_ini = <<-MANIFEST
ini_setting{'Update Puppet.Conf':
ensure => present,
section => 'main',
key_val_separator => '=',
path => '#{host['puppetpath']}/puppet.conf',
setting => 'manifestdir',
value => '#{host_test_tmp_dirs[host.name]}/master_manifest/' }
MANIFEST
on host, puppet('apply', '--debug'), :stdin => puppet_conf_update_ini
end
end
end
end
step "Symlink the module(s) into the master modulepath" do
masters.each do |host|
moddir = get_test_file_path(host, master_module_dir)
mkdirs(host, moddir)
#on host, "ln -s /opt/puppet-git-repos/stdlib \"#{moddir}/stdlib\"; ln -s /opt/puppet-git-repos/registry \"#{moddir}/registry\""
if any_hosts_as?('master') do
masters.each do |host|
moddir = get_test_file_path(host, master_module_dir)
mkdirs(host, moddir)
#on host, "ln -s /opt/puppet-git-repos/stdlib \"#{moddir}/stdlib\"; ln -s /opt/puppet-git-repos/registry \"#{moddir}/registry\""
end
end
end
end
end

def clean_up
step "Clean Up" do
masters.each do |host|
puppet_conf_update_ini = <<-MANIFEST
ini_setting{'Revert Puppet.Conf':
ensure => absent,
section => 'main',
key_val_separator => '=',
path => '#{host['puppetpath']}/puppet.conf',
setting => 'manifestdir' }
MANIFEST
on host, puppet('apply','--debug'), :stdin => puppet_conf_update_ini
on host, "rm -rf \"%s\"" % get_test_file_path(host, '')
if any_hosts_as?(:master)
masters.each do |host|
puppet_conf_update_ini = <<-MANIFEST
ini_setting{'Revert Puppet.Conf':
ensure => absent,
section => 'main',
key_val_separator => '=',
path => '#{host['puppetpath']}/puppet.conf',
setting => 'manifestdir' }
MANIFEST
on host, puppet('apply', '--debug'), :stdin => puppet_conf_update_ini
on host, "rm -rf \"%s\"" % get_test_file_path(host, '')
end
end
agents.each do |host|
on host, "rm -rf \"%s\"" % get_test_file_path(host, '')
Expand Down
14 changes: 14 additions & 0 deletions acceptance/setup/install_pe.rb
@@ -1,3 +1,17 @@
test_name "Installing Puppet Enterprise" do
install_pe

proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
agents.each do |host|
if host['platform'] =~ /windows/i
on host, "mkdir -p #{host['distmoduledir']}/registry"
result = on host, "echo #{host['distmoduledir']}/registry"
target = result.raw_output.chomp

%w(lib manifests metadata.json).each do |file|
scp_to host, "#{proj_root}/#{file}", target
end
on host, "cd #{host['distmoduledir']} && git clone --branch 4.3.2 --depth 1 http://github.com/puppetlabs/puppetlabs-stdlib stdlib"
end
end
end

0 comments on commit 18becea

Please sign in to comment.