Skip to content

Commit

Permalink
Correct acceptence tests for DNF (8) system
Browse files Browse the repository at this point in the history
Use the new versionlock specification from #169 on CentOS 8.

Also test the new specification on 7 and 8 also.

Finally test that if samba-devel is filtered at
an impossible version it is no longer available.

This for the yum case probably assumes that samba-devel is not
actually installed.
  • Loading branch information
traylenator committed May 18, 2020
1 parent 5afb32f commit 85ef320
Showing 1 changed file with 56 additions and 9 deletions.
65 changes: 56 additions & 9 deletions spec/acceptance/define_versionlock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,53 @@
# Using puppet_apply as a helper
it 'must work idempotently with no errors' do
pp = <<-EOS
yum::versionlock{ '0:bash-4.1.2-9.el6_2.*':
ensure => present,
if versioncmp($facts['os']['release']['major'],'7') <= 0 {
yum::versionlock{ '0:bash-4.1.2-9.el6_2.*':
ensure => present,
}
yum::versionlock{ '0:tcsh-3.1.2-9.el6_2.*':
ensure => present,
}
} else {
yum::versionlock{ 'bash':
ensure => present,
version => '4.1.2',
release => '9.el6_2',
}
yum::versionlock{ 'tcsh':
ensure => present,
version => '3.1.2',
release => '9.el6_2',
arch => '*',
epoch => 0,
}
}
yum::versionlock{ '0:tcsh-3.1.2-9.el6_2.*':
ensure => present,
# Lock a package with new style on all OSes
yum::versionlock{ 'netscape':
ensure => present,
version => '8.1.2',
release => '9.el6_2',
arch => '*',
epoch => 2,
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe file('/etc/yum/pluginconf.d/versionlock.list') do
it { is_expected.to be_file }
it { is_expected.to contain '0:bash-4.1.2-9.el6_2.*' }
it { is_expected.to contain '0:tcsh-3.1.2-9.el6_2.*' }
if fact('os.release.major') == '7'
it { is_expected.to contain '0:bash-4.1.2-9.el6_2.*' }
it { is_expected.to contain '0:tcsh-3.1.2-9.el6_2.*' }
it { is_expected.to contain '2:netscape-8.1.2-9.el6_2.*' }
else
it { is_expected.to contain 'bash-0:4.1.2-9.el6_2.*' }
it { is_expected.to contain 'tcsh-0:3.1.2-9.el6_2.*' }
it { is_expected.to contain 'netscape-2:8.1.2-9.el6_2.*' }
end
end
end
it 'must work if clean is specified' do
Expand All @@ -28,15 +60,30 @@
class{yum::plugin::versionlock:
clean => true,
}
yum::versionlock{ '0:bash-3.1.2-9.el6_2.*':
ensure => present,
# Pick an obscure package that hopefully will not be installed.
if versioncmp($facts['os']['release']['major'],'7') <= 0 {
yum::versionlock{ '0:samba-devel-3.1.2-9.el6_2.*':
ensure => present,
}
} else {
yum::versionlock{'samba-devel':
ensure => present,
version => '3.1.2',
release => '9.el6_2',
}
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
# Check the cache is really empty.
# all repos will have 0 packages.
shell('yum -C repolist -d0 | grep -v "repo id" | awk "{print $NF}" FS= | grep -v 0', acceptable_exit_codes: [1])
# bit confused by the motivation of the first test?
if fact('os.release.major') == '7'
shell('yum -C repolist -d0 | grep -v "repo id" | awk "{print $NF}" FS= | grep -v 0', acceptable_exit_codes: [1])
shell('yum -q list available samba-devel', acceptable_exit_codes: [1])
else
shell('dnf -q list --available samba-devel', acceptable_exit_codes: [1])
end
end
end

0 comments on commit 85ef320

Please sign in to comment.