Skip to content

Commit

Permalink
Merge pull request #968 from Valantin/fix/spec
Browse files Browse the repository at this point in the history
Remove spec filter and run spec on all supported OS
  • Loading branch information
bastelfreak authored Jun 28, 2024
2 parents 24dabc3 + 56c384a commit 5db0077
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 469 deletions.
1 change: 0 additions & 1 deletion .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ spec/spec_helper.rb:
mock_with: ':mocha'
spec_overrides:
- "require 'support/acceptance/supported_versions'"
- "require 'spec_helper_methods'"
.puppet-lint.rc:
enabled_lint_checks:
- parameter_documentation
Expand Down
12 changes: 1 addition & 11 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,9 @@
String[1] $zabbix_version = $zabbix::params::zabbix_version,
) inherits zabbix::params {
if $manage_repo {
case $facts['os']['name'] {
'PSBM': {
$majorrelease = '6'
}
'Amazon': {
$majorrelease = '6'
}
default: {
$majorrelease = $facts['os']['release']['major']
}
}
case $facts['os']['family'] {
'RedHat': {
$majorrelease = $facts['os']['release']['major']
if (versioncmp(fact('os.release.major'), '7') >= 0 and $zabbix_version == '7.0') {
$gpgkey_zabbix = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005'
$gpgkey_nonsupported = 'https://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-B5333005'
Expand Down
34 changes: 0 additions & 34 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@
"9"
]
},
{
"operatingsystem": "Amazon",
"operatingsystemrelease": [
"7",
"8"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
Expand All @@ -79,18 +72,10 @@
"9"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"7",
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
Expand All @@ -108,19 +93,6 @@
"9"
]
},
{
"operatingsystem": "CloudLinux",
"operatingsystemrelease": [
"7",
"8"
]
},
{
"operatingsystem": "XenServer",
"operatingsystemrelease": [
"6"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
Expand All @@ -135,12 +107,6 @@
"12"
]
},
{
"operatingsystem": "VirtuozzoLinux",
"operatingsystemrelease": [
"7"
]
},
{
"operatingsystem": "Archlinux"
},
Expand Down
37 changes: 29 additions & 8 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
}
end

on_supported_os(baseline_os_hash).each do |os, facts|
on_supported_os.each do |os, facts|
context "on #{os}" do
config_path = case facts[:os]['name']
when 'windows'
'C:/ProgramData/zabbix/zabbix_agentd.conf'
when 'FreeBSD'
'/usr/local/etc/zabbix6/zabbix_agentd.conf'
else
'/etc/zabbix/zabbix_agentd.conf'
end
Expand All @@ -32,6 +34,8 @@
include_dir = case facts[:os]['name']
when 'windows'
'C:/ProgramData/zabbix/zabbix_agentd.d'
when 'FreeBSD'
'/usr/local/etc/zabbix6/zabbix_agentd.d'
else
'/etc/zabbix/zabbix_agentd.d'
end
Expand All @@ -50,6 +54,9 @@
when 'windows'
package_name = 'zabbix-agent'
service_name = 'Zabbix Agent'
when 'FreeBSD'
package_name = 'zabbix6-agent'
service_name = 'zabbix_agentd'
else
package_name = 'zabbix-agent'
service_name = 'zabbix-agent'
Expand All @@ -60,7 +67,7 @@
context 'with all defaults' do
it { is_expected.to contain_selinux__module('zabbix-agent') } if facts[:os]['family'] == 'RedHat'
it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name'])
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_file(include_dir).with_ensure('directory') }
Expand All @@ -75,11 +82,20 @@
)
end
else
it do
is_expected.to contain_package(package_name).
with_ensure('present').
with_tag('zabbix').
that_requires('Class[zabbix::repo]')

if facts[:os]['family'] == 'Gentoo'
it do
is_expected.to contain_package(package_name).
with_ensure('present').
with_tag('zabbix')
end
else
it do
is_expected.to contain_package(package_name).
with_ensure('present').
with_tag('zabbix').
that_requires('Class[zabbix::repo]')
end
end

it do
Expand All @@ -103,7 +119,7 @@
end

case facts[:os]['family']
when 'Archlinux'
when %w[Archlinux Gentoo FreeBSD].include?(facts[:os]['family'])
it { is_expected.not_to compile.with_all_deps }
when 'Debian'
# rubocop:disable RSpec/RepeatedExample
Expand Down Expand Up @@ -218,6 +234,9 @@
end

context 'when declaring manage_startup_script is true' do
next if facts[:os]['family'] == 'FreeBSD'
next if facts[:os]['family'] == 'Gentoo'

let :params do
{
manage_startup_script: true
Expand Down Expand Up @@ -478,6 +497,8 @@
end

context 'when zabbix_package_agent is zabbix-agent2' do
next if facts[:os]['family'] == 'Gentoo'

let :params do
{
zabbix_package_agent: 'zabbix-agent2', startagents: 1,
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/database_mysql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'rspec.puppet.com'
end

on_supported_os(baseline_os_hash).each do |os, facts|
on_supported_os.each do |os, facts|
next if facts[:os]['name'] == 'windows'

context "on #{os}" do
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/database_postgresql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'rspec.puppet.com'
end

on_supported_os(baseline_os_hash).each do |os, facts|
on_supported_os.each do |os, facts|
next if facts[:os]['name'] == 'windows'

context "on #{os}" do
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'rspec.puppet.com'
end

on_supported_os(baseline_os_hash).each do |os, facts|
on_supported_os.each do |os, facts|
next if facts[:os]['name'] == 'windows'

context "on #{os}" do
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/javagateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'rspec.puppet.com'
end

on_supported_os(baseline_os_hash).each do |os, facts|
on_supported_os.each do |os, facts|
next if facts[:os]['name'] == 'windows'

context "on #{os}" do
Expand All @@ -28,7 +28,7 @@
it { is_expected.to contain_service('zabbix-java-gateway').with_require(['Package[zabbix-java-gateway]', 'File[/etc/zabbix/zabbix_java_gateway.conf]']) }

it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7'
it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name'])
it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian'
it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian'
end
Expand Down
Loading

0 comments on commit 5db0077

Please sign in to comment.