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

(maint) Fix issue #98, don't require pe_compiling_server_aio_build #100

Merged
merged 1 commit into from
Apr 6, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@

# The aio puppet-agent version currently installed on the compiling master
# (only used in PE)
$master_agent_version = $_is_pe ? {
true => pe_compiling_server_aio_build(),
default => undef,
if ($_is_pe and is_function_available('pe_compiling_server_aio_build')) {
$master_agent_version = pe_compiling_server_aio_build()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an else to explicitly set it to undef? We're going to get warnings all over the place otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I also want to add a spec test.

} else {
$master_agent_version = undef
}

if ($master_agent_version != undef and versioncmp("${::clientversion}", '4.0.0') < 0) {
Expand Down
76 changes: 65 additions & 11 deletions spec/classes/puppet_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,78 @@
global_params = {
:package_version => package_version
}
def global_facts(facts, os)
facts.merge(
if os =~ /sles/
{
:is_pe => true,
:operatingsystemmajrelease => facts[:operatingsystemrelease].split('.')[0],
}
elsif os =~ /solaris/
{
:is_pe => true,
}
else
{}
end).merge({:servername => 'master.example.vm'})
end

context 'supported operating systems' do
context 'supported_operating systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
if os =~ /sles/
facts.merge({
:is_pe => true,
:operatingsystemmajrelease => facts[:operatingsystemrelease].split('.')[0],
})
elsif os =~ /solaris/
facts.merge({
:is_pe => true,
})
global_facts(facts, os)
end

if os !~ /sles/ and os !~ /sles/
context 'package_version is undef by default' do
let(:facts) do
global_facts(facts, os).merge({:is_pe => false})
end
it { is_expected.to contain_class('puppet_agent').with_package_version(nil) }
end
end

context 'package_version is undef if pe_compiling_server_aio_build is not defined' do
let(:facts) do
global_facts(facts, os).merge({:is_pe => true})
end
it { is_expected.to contain_class('puppet_agent').with_package_version(nil) }
end
end
end
end

context 'supported_operating systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
global_facts(facts, os).merge({:is_pe => true})
end

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| '1.2.5'}
Puppet::Parser::Functions.newfunction(:pe_compiling_server_version, :type => :rvalue) {|args| '2.2.0'}
end

context 'package_version is initialized automatically' do
if Puppet.version < '4.0.0'
it { is_expected.to contain_class('puppet_agent').with_package_version('1.2.5') }
else
facts
it { is_expected.to contain_class('puppet_agent').with_package_version(nil) }
end
end
end
end
end

context 'supported operating systems' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
global_facts(facts, os)
end

before(:each) do
if os =~ /sles/ || os =~ /solaris/
Expand Down