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

Centralize the logic which server/agent versions are supported #932

Merged
merged 1 commit into from
Mar 12, 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
5 changes: 1 addition & 4 deletions spec/acceptance/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

require 'spec_helper_acceptance'

supported_versions.each do |version|
# < 6.0 agent packages are not available for Debian 12
next if version < '6.0' && default[:platform] =~ %r{debian-12}

supported_agent_versions(default[:platform]).each do |version|
describe "zabbix::agent class with zabbix_version #{version}" do
context 'With minimal parameter' do
it 'works idempotently with no errors' do
Expand Down
11 changes: 1 addition & 10 deletions spec/acceptance/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,7 @@ class { 'zabbix::database': }
end
end

supported_versions.each do |zabbix_version|
# >= 5.2 server packages are not available for RHEL 7
next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

supported_server_versions(default[:platform]).each do |zabbix_version|
context "deploys a zabbix #{zabbix_version} server" do
# Using puppet_apply as a helper
it 'works idempotently with no errors' do
Expand Down
10 changes: 2 additions & 8 deletions spec/acceptance/zabbix_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
require 'spec_helper_acceptance'
require 'serverspec_type_zabbixapi'

describe 'zabbix_application type', unless: default[:platform] =~ %r{archlinux} do
supported_versions.each do |zabbix_version|
describe 'zabbix_application type' do
supported_server_versions(default[:platform]).each do |zabbix_version|
# Application API was removed in Zabbix 5.4
next if zabbix_version >= '5.4'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

template = case zabbix_version
when '5.0'
Expand Down
13 changes: 2 additions & 11 deletions spec/acceptance/zabbix_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@
require 'serverspec_type_zabbixapi'

# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_host type', unless: default[:platform] =~ %r{archlinux} do
supported_versions.each do |zabbix_version|
# >= 5.2 server packages are not available for RHEL 7
next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

describe 'zabbix_host type' do
supported_server_versions(default[:platform]).each do |zabbix_version|
context "create zabbix_host resources with zabbix version #{zabbix_version}" do
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
Expand Down
13 changes: 2 additions & 11 deletions spec/acceptance/zabbix_hostgroup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@
require 'spec_helper_acceptance'
require 'serverspec_type_zabbixapi'

describe 'zabbix_hostgroup type', unless: default[:platform] =~ %r{archlinux} do
supported_versions.each do |zabbix_version|
# >= 5.2 server packages are not available for RHEL 7
next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

describe 'zabbix_hostgroup type' do
supported_server_versions(default[:platform]).each do |zabbix_version|
context "create zabbix_hostgroup resources with zabbix version #{zabbix_version}" do
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
Expand Down
13 changes: 2 additions & 11 deletions spec/acceptance/zabbix_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,8 @@
require 'serverspec_type_zabbixapi'

# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_proxy type', unless: default[:platform] =~ %r{archlinux} do
supported_versions.each do |zabbix_version|
# >= 5.2 server packages are not available for RHEL 7
next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

describe 'zabbix_proxy type' do
supported_server_versions(default[:platform]).each do |zabbix_version|
context "create zabbix_proxy resources with zabbix version #{zabbix_version}" do
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
Expand Down
12 changes: 2 additions & 10 deletions spec/acceptance/zabbix_template_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@
require 'spec_helper_acceptance'
require 'serverspec_type_zabbixapi'

describe 'zabbix_template_host type', unless: default[:platform] =~ %r{archlinux} do
supported_versions.each do |zabbix_version|
describe 'zabbix_template_host type' do
supported_server_versions(default[:platform]).each do |zabbix_version|
# Zabbix 6.0 removed the ability to attach templates directly to hosts.
next if zabbix_version == '6.0'
# >= 5.2 server packages are not available for RHEL 7
next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

context "create zabbix_template_host resources with zabbix version #{zabbix_version}" do
template = case zabbix_version
Expand Down
13 changes: 2 additions & 11 deletions spec/acceptance/zabbix_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@
require 'spec_helper_acceptance'
require 'serverspec_type_zabbixapi'

describe 'zabbix_template type', unless: default[:platform] =~ %r{archlinux} do
supported_versions.each do |zabbix_version|
# >= 5.2 server packages are not available for RHEL 7
next if zabbix_version >= '5.2' && default[:platform] == 'el-7-x86_64'
# < 6.0 server packages are not available for RHEL 9
next if zabbix_version < '6.0' && default[:platform] == 'el-9-x86_64'
# <6.0 server packages are not available for ubuntu 22.04
next if zabbix_version < '6.0' && default[:platform] =~ %r{ubuntu-22}
# < 6.0 server packages are not available for Debian 12
next if zabbix_version < '6.0' && default[:platform] =~ %r{debian-12}

describe 'zabbix_template type' do
supported_server_versions(default[:platform]).each do |zabbix_version|
context "create zabbix_template resources with zabbix version #{zabbix_version}" do
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
Expand Down
14 changes: 14 additions & 0 deletions spec/support/acceptance/supported_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ def supported_versions
end
supported_versions
end

def supported_agent_versions(platform)
supported_versions.reject do |version|
version < '6.0' && platform.start_with?('debian-12')
end
end

def supported_server_versions(platform)
supported_versions.reject do |version|
platform.start_with?('archlinux') ||
(version >= '5.2' && platform.start_with?('el-7')) ||
(version < '6.0' && platform.start_with?('el-9', 'ubuntu-22', 'debian-12'))
end
end