Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(MODULES-8318) Remove spec tests for puppet < 4 #350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 5 additions & 46 deletions spec/classes/puppet_agent_osfamily_aix_spec.rb
Expand Up @@ -14,7 +14,7 @@
shared_examples 'aix' do |aixver, pkg_aixver, powerver|
let(:rpmname) {"puppet-agent-#{params[:package_version]}-1.aix#{pkg_aixver}.ppc.rpm"}
let(:tag) { "aix-#{pkg_aixver}-power" }
let(:source) { "puppet:///pe_packages/4.0.0/#{tag}/#{rpmname}" }
let(:source) { "puppet:///pe_packages/2000.0.0/#{tag}/#{rpmname}" }
let(:facts) {
common_facts.merge({
architecture: "PowerPC_POWER#{powerver}",
Expand All @@ -23,18 +23,8 @@
}

before(:each) do
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '4.0.0' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| 'x.y.z' }
end

if Puppet.version < "4.0.0"
it { is_expected.to contain_file('/etc/puppetlabs/puppet') }
it { is_expected.to contain_file('/etc/puppetlabs/puppet/puppet.conf') }

it do
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf')
is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf')
end
Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' }
Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' }
end

it { is_expected.to contain_file('/opt/puppetlabs') }
Expand All @@ -49,47 +39,16 @@
it {
is_expected.to contain_package('puppet-agent').with({
'source' => "/opt/puppetlabs/packages/#{rpmname}",
'ensure' => Puppet.version < '4.0.0' ? 'present' : params[:package_version],
'ensure' => params[:package_version],
'provider' => 'rpm',
})
}

if Puppet.version < "4.0.0"
[
'pe-augeas',
'pe-mcollective-common',
'pe-rubygem-deep-merge',
'pe-mcollective',
'pe-puppet-enterprise-release',
'pe-libldap',
'pe-libyaml',
'pe-ruby-stomp',
'pe-ruby-augeas',
'pe-ruby-shadow',
'pe-hiera',
'pe-facter',
'pe-puppet',
'pe-openssl',
'pe-ruby',
'pe-ruby-rgen',
'pe-virt-what',
'pe-ruby-ldap',
].each do |package|
it do
is_expected.to contain_package(package).with({
'ensure' => 'absent',
'uninstall_options' => '--nodeps',
'provider' => 'rpm',
})
end
end
end
end

context 'with a PC1 collection' do
let(:params) {
{
package_version: '1.2.3',
package_version: '1.10.100',
collection: 'PC1',
}
}
Expand Down
56 changes: 12 additions & 44 deletions spec/classes/puppet_agent_osfamily_darwin_spec.rb
@@ -1,29 +1,20 @@
require 'spec_helper'

describe 'puppet_agent' do
master_package_version = '1.3.5'
master_package_version = '1.10.100'
before(:each) do
# Need to mock the PE functions
Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args|
"4.0.0"
"2000.0.0"
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args|
master_package_version
end
end

if Puppet.version >= "4.0.0"
package_version = '1.2.5'
let(:params) do
{
:package_version => package_version
}
end
else
# Default to PE master package version in 3.8
package_version = master_package_version
end
package_version = '1.10.100'
let(:params) {{ package_version: package_version }}

facts = {
:is_pe => true,
Expand Down Expand Up @@ -59,7 +50,7 @@
let(:facts) do
facts.merge({
:is_pe => true,
:aio_agent_version => '1.0.4',
:aio_agent_version => '1.10.99',
:platform_tag => tag,
:macosx_productversion_major => osmajor
})
Expand All @@ -75,40 +66,17 @@
it { is_expected.to contain_class('puppet_agent::install::remove_packages_osx') }
it { is_expected.to contain_class("puppet_agent::osfamily::darwin") }

if Puppet.version < "4.0.0"
[
'pe-augeas',
'pe-ruby-augeas',
'pe-openssl',
'pe-ruby',
'pe-cfpropertylist',
'pe-facter',
'pe-puppet',
'pe-mcollective',
'pe-hiera',
'pe-puppet-enterprise-release',
'pe-stomp',
'pe-libyaml',
'pe-ruby-rgen',
'pe-deep-merge',
'pe-ruby-shadow',
].each do |package|
it { is_expected.to contain_exec("forget #{package}").with_command("/usr/sbin/pkgutil --forget com.puppetlabs.#{package}") }
it { is_expected.to contain_exec("forget #{package}").with_require('File[/opt/puppet]') }
end
else
context 'aio_agent_version is out of date' do
let(:facts) do
facts.merge({
:aio_agent_version => '1.0.0'
})
end

it { is_expected.not_to contain_exec('forget puppet-agent') }
context 'aio_agent_version is out of date' do
let(:facts) do
facts.merge({
:aio_agent_version => '0.0.1'
})
end

it { is_expected.not_to contain_exec('forget puppet-agent') }
end

it { is_expected.not_to contain_exec('forget puppet-agent') }
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/puppet_agent_osfamily_debian_spec.rb
Expand Up @@ -19,7 +19,7 @@
}

# All FOSS and all Puppet 4+ upgrades require the package_version
package_version = '1.2.5'
package_version = '1.10.100'
let(:params) {
{
:package_version => package_version
Expand All @@ -35,7 +35,7 @@
# Need to mock the PE functions

Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args|
'4.0.0'
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args|
Expand Down Expand Up @@ -179,7 +179,7 @@
}) }

it { is_expected.to contain_apt__source('pc_repo').with({
'location' => 'https://master.example.vm:8140/packages/4.0.0/debian-7-x86_64',
'location' => 'https://master.example.vm:8140/packages/2000.0.0/debian-7-x86_64',
'repos' => 'PC1',
'key' => {
'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F',
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/puppet_agent_osfamily_redhat_spec.rb
Expand Up @@ -126,7 +126,7 @@
# Need to mock the PE functions

Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args|
'4.0.0'
'2000.0.0'
end

Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args|
Expand Down Expand Up @@ -154,7 +154,7 @@
it { is_expected.to contain_yumrepo('puppetlabs-pepackages').with_ensure('absent') }

it { is_expected.to contain_yumrepo('pc_repo').with({
'baseurl' => "https://master.example.vm:8140/packages/4.0.0/#{repodir}",
'baseurl' => "https://master.example.vm:8140/packages/2000.0.0/#{repodir}",
'enabled' => 'true',
'gpgcheck' => '1',
'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs\n file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppet",
Expand Down