Skip to content

Commit

Permalink
(PE-11531) Fix upgrade issue with dev builds
Browse files Browse the repository at this point in the history
Prior to this commit the module would always upgrade with dev
builds because they have a git SHA appended to the end, which
`versioncmp` considers to be greater than the version reported
by `aio_agent_version`, which lacks the extra git sha characters.
This commit updates the update check to strip the git sha when
comparing the `aio_agent_version` to the requested `packace_version`.
  • Loading branch information
Brandon High committed Apr 20, 2016
1 parent e7eee94 commit 686ee8b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
13 changes: 10 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@
fail("invalid version ${package_version} requested")
}

$aio_upgrade_required = ($is_pe == false and $package_version != undef) or
($::aio_agent_version != undef and $package_version != undef and
versioncmp("${::aio_agent_version}", "${package_version}") < 0)
# Strip git sha from dev builds
if $packge_version != undef and $package_version =~ /g/ {
$_expected_package_version = split($package_version, /[.-]g.*/)[0]
} else {
$_expected_package_version = $package_version
}

$aio_upgrade_required = ($is_pe == false and $_expected_package_version != undef) or
($::aio_agent_version != undef and $_expected_package_version != undef and
versioncmp("${::aio_agent_version}", "${_expected_package_version}") < 0)

if $::architecture == 'x86' and $arch == 'x64' {
fail('Unable to install x64 on a x86 system')
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/puppet_agent_osfamily_solaris_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,19 @@

it { is_expected.not_to contain_transition("remove puppet-agent") }
end

context 'with up-to-date aio_agent_version missing git sha' do
let(:facts) do
facts.merge({
:is_pe => true,
:platform_tag => "solaris-10-i386",
:operatingsystemmajrelease => '10',
:aio_agent_version => '1.2.5.90',
})
end

it { is_expected.not_to contain_transition("remove puppet-agent") }
end
end

it do
Expand Down
15 changes: 14 additions & 1 deletion spec/classes/puppet_agent_windows_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,23 @@
:aio_agent_version => package_version
})}

it { is_expected.not_to contain_class('puppet_agent::windows::install') }
it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') }
end

context 'with equal package_version containing git sha' do
let(:facts) { facts.merge({
:is_pe => true,
:aio_agent_version => package_version
})}

let(:params) {
global_params.merge(:package_version => "#{package_version}.g886c5ab")
}

it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') }
it { is_expected.not_to contain_exec('install_puppet.bat') }
end

context 'with out of date aio_agent_version' do
let(:facts) { facts.merge({
:is_pe => true,
Expand Down

0 comments on commit 686ee8b

Please sign in to comment.