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

Remove spec filter and run spec on all supported OS #968

Merged
merged 8 commits into from
Jun 28, 2024
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
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
13 changes: 7 additions & 6 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
$manage_startup_script = false
}
'AIX': {
$manage_repo = false
Expand All @@ -32,6 +33,7 @@
$agent_config_group = 'zabbix'
$agent_pidfile = '/var/run/zabbix/zabbix_agentd.pid'
$agent_servicename = 'zabbix-agent'
$manage_startup_script = true
}
'Archlinux': {
$server_fpinglocation = '/usr/bin/fping'
Expand All @@ -51,6 +53,7 @@
$server_zabbix_user = 'zabbix-server'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
$manage_startup_script = false
}
'FreeBSD': {
$manage_repo = false
Expand All @@ -66,6 +69,7 @@
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/local/lib/zabbix/modules'
$manage_startup_script = false
}
'Gentoo': {
$server_fpinglocation = '/usr/sbin/fping'
Expand All @@ -85,6 +89,7 @@
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
$manage_startup_script = false
}
'windows': {
$manage_repo = false
Expand All @@ -99,6 +104,7 @@
$agent_servicename = 'Zabbix Agent'
$agent_include = 'C:/ProgramData/zabbix/zabbix_agentd.d'
$agent_loadmodulepath = undef
$manage_startup_script = false
}
default : {
$server_fpinglocation = '/usr/sbin/fping'
Expand All @@ -118,6 +124,7 @@
$server_zabbix_user = 'zabbix'
$zabbix_package_provider = undef
$agent_loadmodulepath = '/usr/lib/modules'
$manage_startup_script = false
}
}

Expand All @@ -129,12 +136,6 @@
$zabbix_version = '6.0'
}

$manage_startup_script = downcase($facts['kernel']) ? {
'windows' => false,
'FreeBSD' => false,
default => true,
}

$zabbix_package_state = 'present'
$zabbix_proxy = 'localhost'
$zabbix_proxy_ip = '127.0.0.1'
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
86 changes: 57 additions & 29 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,22 +82,30 @@
)
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
is_expected.to contain_service(service_name).
with_ensure('running').
with_enable(true).
with_service_provider(facts[:os]['family'] == 'AIX' ? 'init' : nil).
that_requires(["Package[#{package_name}]", "Zabbix::Startup[#{service_name}]"])
with_service_provider(facts[:os]['family'] == 'AIX' ? 'init' : nil)
end

it { is_expected.to contain_zabbix__startup(service_name).that_requires("Package[#{package_name}]") }
it { is_expected.not_to contain_zabbix__startup(service_name) }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('zabbix::params') }
end
Expand All @@ -104,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,29 +233,40 @@
it { is_expected.not_to contain_firewall('150 zabbix-agent from 10.11.12.13') }
end

context 'it creates a startup script' do
if facts[:kernel] == 'Linux'
case facts[:os]['family']
when 'Archlinux', 'Debian', 'Gentoo', 'RedHat'
it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('absent') }
it { is_expected.to contain_file("/etc/systemd/system/#{service_name}.service").with_ensure('file') }
when 'windows'
it { is_expected.to contain_exec("install_agent_#{service_name}") }
else
it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('file') }
it { is_expected.not_to contain_file("/etc/systemd/system/#{service_name}.service") }
end
end
end
context 'when declaring manage_startup_script is true' do
next if facts[:os]['family'] == 'FreeBSD'
next if facts[:os]['family'] == 'Gentoo'

context 'when declaring manage_startup_script is false' do
let :params do
{
manage_startup_script: false
manage_startup_script: true
}
end

it { is_expected.not_to contain_zabbix__startup(service_name) }
context 'it creates a startup script' do
if facts[:kernel] == 'Linux'
case facts[:os]['family']
when 'Archlinux', 'Debian', 'Gentoo', 'RedHat'
it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('absent') }
it { is_expected.to contain_file("/etc/systemd/system/#{service_name}.service").with_ensure('file') }
when 'windows'
it { is_expected.to contain_exec("install_agent_#{service_name}") }
else
it { is_expected.to contain_file("/etc/init.d/#{service_name}").with_ensure('file') }
it { is_expected.not_to contain_file("/etc/systemd/system/#{service_name}.service") }
end
end
end

it do
is_expected.to contain_service(service_name).
with_ensure('running').
with_enable(true).
with_service_provider(facts[:os]['family'] == 'AIX' ? 'init' : nil).
that_requires(["Package[#{package_name}]", "Zabbix::Startup[#{service_name}]"])
end

it { is_expected.to contain_zabbix__startup(service_name).that_requires("Package[#{package_name}]") }
end

context 'when declaring zabbix_alias' do
Expand Down Expand Up @@ -460,17 +486,19 @@
end
end

describe 'with systemd active' do
describe 'with systemd active', skip: 'user package provided instead systemd::unit_file ' do
if facts[:kernel] == 'Linux'
let :facts do
super().merge(systemd: true)
end

it { is_expected.to contain_systemd__unit_file('zabbix-agent.service') }

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on gentoo-2-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on almalinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on almalinux-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on archlinux-rolling-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on centos-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on centos-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on debian-11-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on debian-12-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on oraclelinux-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 8 (Ruby 3.2)

zabbix::agent on oraclelinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on gentoo-2-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on almalinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on almalinux-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on archlinux-rolling-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on centos-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on centos-9-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on debian-11-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on debian-12-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on oraclelinux-7-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file

Check warning on line 495 in spec/classes/agent_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / 7 (Ruby 2.7)

zabbix::agent on oraclelinux-8-x86_64 with systemd active Skipped: user package provided instead systemd::unit_file
end
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
Loading