Skip to content

Commit

Permalink
Drop unsupported OSes from unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jay7x committed Dec 12, 2024
1 parent 4f28e39 commit 493d420
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 300 deletions.
26 changes: 4 additions & 22 deletions spec/acceptance/define_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,9 @@
apply_manifest(pp, catch_changes: true)
end

# On stupid 7 test package has to be leaf package
# to be removed with a "groupremove". Can't find
# a common package that works.
case fact('os.release.major')
when '7'
describe package('libtool') do
it { is_expected.to be_installed }
end
else
describe package('make') do
it { is_expected.to be_installed }
end
describe package('make') do
it { is_expected.to be_installed }
end
end

context 'removing group RPM dev tools' do
# Using puppet_apply as a helper
Expand All @@ -46,15 +35,8 @@
apply_manifest(pp, catch_changes: true)
end

case fact('os.release.major')
when '7'
describe package('libtool') do
it { is_expected.not_to be_installed }
end
else
describe package('make') do
it { is_expected.not_to be_installed }
end
describe package('make') do
it { is_expected.not_to be_installed }
end
end
end
86 changes: 23 additions & 63 deletions spec/acceptance/define_versionlock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,17 @@
# Using puppet_apply as a helper
it 'must work idempotently with no errors' do
pp = <<-EOS
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{ '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,
}
# Lock a package with new style on all OSes
Expand All @@ -44,31 +35,16 @@
apply_manifest(pp, catch_changes: true)
end

if fact('os.release.major') == '7'
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.*' }
it { is_expected.to contain '2:netscape-8.1.2-9.el6_2.*' }
end
else
describe file('/etc/dnf/plugins/versionlock.list') do
it { is_expected.to be_file }
describe file('/etc/dnf/plugins/versionlock.list') do
it { is_expected.to be_file }

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
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

if fact('os.release.major') == '7'
describe package('yum-plugin-versionlock') do
it { is_expected.to be_installed }
end
else
describe package('python3-dnf-plugin-versionlock') do
it { is_expected.to be_installed }
end
describe package('python3-dnf-plugin-versionlock') do
it { is_expected.to be_installed }
end
end

Expand All @@ -79,32 +55,16 @@
clean => true,
}
# 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',
}
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.
# 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])
elsif %w[8 9].include?(fact('os.release.major'))
shell('dnf -q list --available samba-devel', acceptable_exit_codes: [1])
else
shell('dnf install -y samba-devel | grep "All matches were filtered"', acceptable_exit_codes: [0])
end
shell('dnf -q list --available samba-devel', acceptable_exit_codes: [1])
end
end
199 changes: 0 additions & 199 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,56 +151,9 @@
updates-source
centos-media
]
when '7'
it_behaves_like 'a catalog containing repos', %w[
base
updates
cr
base-source
updates-source
centos-media
extras
centosplus
fasttrack
extras-source
base-debuginfo
]
it_behaves_like 'a catalog not containing repos', %w[
contrib
AppStream
BaseOS
Devel
HA
PowerTools
BaseOS-source
Appstream-source
c8-media-BaseOS
c8-media-AppStream
]
else
it { is_expected.to have_yumrepo_resource_count(4) }
end
when 'Amazon'
it { is_expected.to have_yumrepo_resource_count(16) } # rubocop:disable RSpec/RepeatedExample

it_behaves_like 'a catalog containing repos', %w[
amzn-main
amzn-main-debuginfo
amzn-main-source
amzn-nosrc
amzn-preview
amzn-preview-debuginfo
amzn-preview-source
amzn-updates
amzn-updates-debuginfo
amzn-updates-source
epel
epel-debuginfo
epel-source
epel-testing
epel-testing-debuginfo
epel-testing-source
]
when 'RedHat'
it { is_expected.to have_yumrepo_resource_count(18) }

Expand All @@ -224,47 +177,6 @@
rhui-REGION-rhel-server-debug-supplementary
rhui-REGION-rhel-server-source-supplementary
]
when 'VirtuozzoLinux'
case facts[:os]['release']['major']
when '6'
it { is_expected.to have_yumrepo_resource_count(12) }

it_behaves_like 'a catalog containing repos', %w[
virtuozzolinux-base
virtuozzolinux-updates
virtuozzolinux-base-debuginfo
virtuozzolinux-updates-debuginfo
virtuozzolinux-factory
virtuozzolinux-factory-debuginfo
virtuozzo-os
virtuozzo-updates
virtuozzo-os-debuginfo
virtuozzo-updates-debuginfo
virtuozzo-readykernel
obsoleted_tmpls
]
when '7'
it { is_expected.to have_yumrepo_resource_count(16) } # rubocop:disable RSpec/RepeatedExample

it_behaves_like 'a catalog containing repos', %w[
virtuozzolinux-base
virtuozzolinux-updates
virtuozzolinux-base-debuginfo
virtuozzolinux-updates-debuginfo
virtuozzolinux-factory
virtuozzolinux-factory-debuginfo
virtuozzo-os
virtuozzo-updates
virtuozzo-os-debuginfo
virtuozzo-updates-debuginfo
virtuozzo-readykernel
obsoleted_tmpls
factory
factory-debuginfo
virtuozzolinux-vz-factory
virtuozzolinux-vz-factory-debuginfo
]
end
when 'AlmaLinux'
case facts[:os]['release']['major']
when '8'
Expand Down Expand Up @@ -357,73 +269,7 @@
extras-common
extras-common-source
]
when '8'
it_behaves_like 'a catalog containing repos', %w[
AppStream
cr
Devel
fasttrack
HA
PowerTools
BaseOS-source
Appstream-source
c8-media-BaseOS
c8-media-AppStream
extras
centosplus
extras-source
base-debuginfo
]
when '7'
it_behaves_like 'a catalog containing repos', %w[
cr
updates
extras
base-source
updates-source
extras-source
base-debuginfo
centosplus
centos-media
extras
centosplus
extras-source
base-debuginfo
]
when '6'
it_behaves_like 'a catalog containing repos', %w[
contrib
updates
extras
base-source
updates-source
extras-source
base-debuginfo
centosplus
centos-media
]
end
when 'Amazon'
it { is_expected.to have_yumrepo_resource_count(16) } # rubocop:disable RSpec/RepeatedExample

it_behaves_like 'a catalog containing repos', %w[
amzn-main
amzn-main-debuginfo
amzn-main-source
amzn-nosrc
amzn-preview
amzn-preview-debuginfo
amzn-preview-source
amzn-updates
amzn-updates-debuginfo
amzn-updates-source
epel
epel-debuginfo
epel-source
epel-testing
epel-testing-debuginfo
epel-testing-source
]
when 'RedHat'
it { is_expected.to have_yumrepo_resource_count(18) }

Expand All @@ -447,47 +293,6 @@
rhui-REGION-rhel-server-debug-supplementary
rhui-REGION-rhel-server-source-supplementary
]
when 'VirtuozzoLinux'
case facts[:os]['release']['major']
when '6'
it { is_expected.to have_yumrepo_resource_count(12) }

it_behaves_like 'a catalog containing repos', %w[
virtuozzolinux-base
virtuozzolinux-updates
virtuozzolinux-base-debuginfo
virtuozzolinux-updates-debuginfo
virtuozzolinux-factory
virtuozzolinux-factory-debuginfo
virtuozzo-os
virtuozzo-updates
virtuozzo-os-debuginfo
virtuozzo-updates-debuginfo
virtuozzo-readykernel
obsoleted_tmpls
]
when '7'
it { is_expected.to have_yumrepo_resource_count(16) } # rubocop:disable RSpec/RepeatedExample

it_behaves_like 'a catalog containing repos', %w[
virtuozzolinux-base
virtuozzolinux-updates
virtuozzolinux-base-debuginfo
virtuozzolinux-updates-debuginfo
virtuozzolinux-factory
virtuozzolinux-factory-debuginfo
virtuozzo-os
virtuozzo-updates
virtuozzo-os-debuginfo
virtuozzo-updates-debuginfo
virtuozzo-readykernel
obsoleted_tmpls
factory
factory-debuginfo
virtuozzolinux-vz-factory
virtuozzolinux-vz-factory-debuginfo
]
end
when 'AlmaLinux'
case facts[:os]['release']['major']
when '8'
Expand Down Expand Up @@ -729,10 +534,6 @@
it { is_expected.to contain_yum__gpgkey('/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9') }
when '8'
it { is_expected.to contain_yum__gpgkey('/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8') }
when '7'
it { is_expected.to contain_yum__gpgkey('/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7') }
when '6'
it { is_expected.to contain_yum__gpgkey('/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6') }
end
end

Expand Down
Loading

0 comments on commit 493d420

Please sign in to comment.