Skip to content

Commit

Permalink
(MODULES-6708) fix tests for windows agent to agent upgrades
Browse files Browse the repository at this point in the history
* remove tests around configuration migration as they are not managed by the upgrade
* changed base version from 3.x to 1.7.0 and associated changes
* specified upgrade target as 1.10.0

Two Windows tests are currently red. They appear to be legitimate failues related to
idempotency.

Tests have only been updated to make things green, with no other refactoring applied
as yet.
  • Loading branch information
speedofdark committed May 4, 2018
1 parent e90ef57 commit 51bd509
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 37 deletions.
30 changes: 6 additions & 24 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

describe 'puppet_agent class' do

context 'default parameters' do
context 'default parameters in apply' do
before(:all) { setup_puppet_on default }
after (:all) { teardown_puppet_on default }

it 'should work idempotently with no errors' do
pp = <<-EOS
class { 'puppet_agent': }
class { 'puppet_agent': package_version => '1.10.0' }
EOS

# Run it twice and test for idempotency
Expand Down Expand Up @@ -44,7 +44,6 @@ class { 'puppet_agent': }
describe file(puppet_conf(default)) do
it { is_expected.to exist }
its(:content) {
is_expected.to match /cfacter[ ]*=[ ]*true/
is_expected.to_not match /stringify_facts[ ]*=[ ]*false/
is_expected.to_not match /parser[ ]*=[ ]*future/
}
Expand Down Expand Up @@ -128,7 +127,8 @@ class { 'puppet_agent': service_names => [] }
context 'agent run' do
before(:all) {
setup_puppet_on default, :agent => true
pp = "file { '#{master.puppet['codedir']}/environments/production/manifests/site.pp': ensure => file, content => 'class { \"puppet_agent\": service_names => [\"mcollective\"] }' }"
manifest = 'class { "puppet_agent": package_version => "1.10.0", service_names => ["mcollective"] }'
pp = "file { '#{master.puppet['codedir']}/environments/production/manifests/site.pp': ensure => file, content => '#{manifest}' }"
apply_manifest_on(master, pp, :catch_failures => true)
}
after (:all) {
Expand Down Expand Up @@ -167,7 +167,8 @@ class { 'puppet_agent': service_names => [] }
context 'with mcollective configured' do
before(:all) {
setup_puppet_on default, :mcollective => true, :agent => true
pp = "file { '#{master.puppet['codedir']}/environments/production/manifests/site.pp': ensure => file, content => 'class { \"puppet_agent\": service_names => [\"mcollective\"] }' }"
manifest = 'class { "puppet_agent": package_version => "1.10.0", service_names => ["mcollective"] }'
pp = "file { '#{master.puppet['codedir']}/environments/production/manifests/site.pp': ensure => file, content => '#{manifest}' }"
apply_manifest_on(master, pp, :catch_failures => true)
}
after (:all) {
Expand Down Expand Up @@ -210,25 +211,6 @@ class { 'puppet_agent': service_names => [] }
assert_match(/^#{hostname}[.\w]*\s+time=/, stdout)
end
end

describe file("#{mcollective_new_paths(default)[:etc]}/server.cfg") do
it { is_expected.to exist }
its(:content) {
is_expected.to include "libdir = #{mcollective_new_paths(default)[:server_plugins]}"
is_expected.to include "libdir = #{mcollective_new_paths(default)[:libexec]}/plugins"
is_expected.to include "logfile = #{mcollective_new_paths(default)[:logs]}/mcollective.log"
is_expected.to include "plugin.yaml = #{mcollective_new_paths(default)[:facts]}"
}
end

describe file("#{mcollective_new_paths(default)[:etc]}/client.cfg") do
it { is_expected.to exist }
its(:content) {
is_expected.to include "libdir = #{mcollective_new_paths(default)[:server_plugins]}:#{mcollective_new_paths(default)[:client_plugins]}:#{mcollective_new_paths(default)[:libexec]}"
is_expected.to include "logfile = #{mcollective_new_paths(default)[:logs]}/mcollective.log"
is_expected.to_not match /plugin.yaml[ ]*=/
}
end
end
end
end
21 changes: 8 additions & 13 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ def install_modules_on(host)
sleep 10
end

def parser_opts(master_fqdn)
# Configuration only needed on 3.x master
def agent_opts(master_fqdn)
{
:main => {:stringify_facts => false, :parser => 'future', :color => 'ansi'},
:agent => {:stringify_facts => false, :cfacter => true, :ssldir => '$vardir/ssl', :server => master_fqdn},
:main => {:color => 'ansi'},
:agent => {:ssldir => '$vardir/ssl', :server => master_fqdn},
}
end

Expand Down Expand Up @@ -135,24 +134,19 @@ def setup_puppet_on(host, opts = {})

puts "Setup foss puppet on #{host}"
configure_defaults_on host, 'foss'
install_puppet_on host, :version => ENV['PUPPET_CLIENT_VERSION'] || '3.8.6'
install_puppet_agent_on host, :version => ENV['PUPPET_CLIENT_VERSION'] || '1.7.0'

puppet_opts = parser_opts(master.to_s)
puppet_opts = agent_opts(master.to_s)
if host['platform'] =~ /windows/i
# MODULES-4242: ssldir setting is cleared but files not copied on Windows upgrading from Puppet 3
puppet_opts[:agent].delete(:ssldir)
end
configure_puppet_on(host, puppet_opts)

if opts[:mcollective]
# On Windows, mcollective is included in the MSI even for Puppet 3
unless host['platform'] =~ /windows/i
install_package host, 'mcollective'
install_package host, 'mcollective-client'
end
stop_firewall_on host

mco_paths = mcollective_paths(host)
mco_paths = mcollective_new_paths(host)
on host, "mkdir -p #{mco_paths[:etc]}"

['ca_crt.pem', 'server.crt', 'server.key', 'client.crt', 'client.key'].each do |file|
Expand All @@ -173,10 +167,11 @@ def setup_puppet_on(host, opts = {})
on host, puppet('resource', 'host', activemq_host, "ip=#{master['ip'] || master.ip}")
on host, puppet('resource', 'service', 'mcollective', 'ensure=stopped')
on host, puppet('resource', 'service', 'mcollective', 'ensure=running')
on host, puppet('resource', 'service', 'mcollective', 'enable=true')
end

if opts[:agent]
puts "Clear SSL on all hosts and disable firewalls"
puts "Clean SSL on all hosts and disable firewalls"
hosts.each do |host|
stop_firewall_on host
on(host, "rm -rf '#{host.puppet['ssldir']}'")
Expand Down

0 comments on commit 51bd509

Please sign in to comment.