Skip to content

Commit 9ca99a2

Browse files
(maint) Make spec tests pass on windows
Windows requires the current puppet collection to be specified in the puppet_agent class, so that is refactored to be globally specified in the `spec_helper_acceptance`. Additionally, logic was added to specifiy default install paths for the VERSION file for both linux and windows.
1 parent 7935c79 commit 9ca99a2

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

manifests/init.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
$wait_for_pxp_agent_exit = undef,
127127
$wait_for_puppet_run = undef,
128128
Array[Puppet_agent::Config] $config = [],
129+
$version_file_path = $facts['os']['family'] ? { 'windows' => 'C:\Program Files\Puppet Labs\Puppet\VERSION', default => '/opt/puppetlabs/puppet/VERSION' }
129130
) inherits ::puppet_agent::params {
130131
# The configure class uses $puppet_agent::config to manage settings in
131132
# puppet.conf, and will always be present. It does not require management of
@@ -161,7 +162,7 @@
161162
# The AIO package version and Puppet version can, on rare occasion, diverge.
162163
# This logic checks for the AIO version of the server, since that's what the package manager cares about.
163164
if $package_version == 'auto' {
164-
$master_or_package_version = chomp(file('/opt/puppetlabs/puppet/VERSION'))
165+
$master_or_package_version = chomp(file($version_file_path))
165166
} else {
166167
$master_or_package_version = $package_version
167168
}

spec/acceptance/class_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
context 'default parameters in apply' do
66
before(:all) do
77
setup_puppet_on default
8-
pp = "class { 'puppet_agent': package_version => 'auto'}"
8+
pp = "class { 'puppet_agent': package_version => 'auto', collection => #{PUPPET_COLLECTION}}"
99
apply_manifest(pp, catch_failures: true)
1010
end
1111
after(:all) { teardown_puppet_on default }

spec/spec_helper_acceptance.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def stop_firewall_on(host)
2222
# Project root
2323
PROJ_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
2424
TEST_FILES = File.expand_path(File.join(File.dirname(__FILE__), 'acceptance', 'files'))
25+
PUPPET_COLLECTION = 'puppet7'
2526

2627
def install_modules_on(host)
2728
install_ca_certs_on(host)
@@ -37,7 +38,7 @@ def install_modules_on(host)
3738
master['puppetservice'] = 'puppetserver'
3839
master['puppetserver-confdir'] = '/etc/puppetlabs/puppetserver/conf.d'
3940
master['type'] = 'aio'
40-
install_puppet_agent_on master, { version: ENV['PUPPET_CLIENT_VERSION'] || '7.23.0', puppet_collection: 'puppet7' }
41+
install_puppet_agent_on master, { version: ENV['PUPPET_CLIENT_VERSION'] || '7.23.0', puppet_collection: PUPPET_COLLECTION }
4142
install_modules_on master
4243
stop_firewall_on master
4344
end
@@ -71,7 +72,7 @@ def setup_puppet_on(host, opts = {})
7172

7273
puts "Setup aio puppet on #{host}"
7374
configure_type_defaults_on host
74-
install_puppet_agent_on host, { version: ENV['PUPPET_CLIENT_VERSION'] || '7.23.0', puppet_collection: 'puppet7' }
75+
install_puppet_agent_on host, { version: ENV['PUPPET_CLIENT_VERSION'] || '7.23.0', puppet_collection: PUPPET_COLLECTION }
7576

7677
puppet_opts = agent_opts(master.to_s)
7778
if %r{windows}i.match?(host['platform'])

0 commit comments

Comments
 (0)