Run acceptance tests for all supported versions
MODIFY
manifests/server.pp
manifests/server.pp
@@ -389,6 +389,14 @@ class zabbix::server (
Boolean $manage_startup_script = $zabbix::params::manage_startup_script,
Optional[Stdlib::Absolutepath] $socketdir = $zabbix::params::server_socketdir,
) inherits zabbix::params {
+ # zabbix server 5.2 is not supported on RHEL 7.
+ # https://www.zabbix.com/documentation/current/manual/installation/install_from_packages/rhel_centos
+ if $facts['os']['family'] == 'RedHat' and versioncmp($zabbix_version, '5.2') == 0 {
+ if versioncmp($facts['os']['release']['major'], '7') == 0 {
+ fail("${facts['os']['family']} ${$facts['os']['release']['major']} is not supported for zabbix::server (yet)")
+ }
+ }
+
# the following codeblock is a bit blargh. The correct default value for
# $real_additional_service_params changes based on the value of $zabbix_version
# We handle this in the params.pp, but that doesn't work if somebody provides a specific

MODIFY
manifests/web.pp
manifests/web.pp
@@ -287,8 +287,8 @@ class zabbix::web (
'3.4': {
$zabbixapi_version = '4.0.0'
}
- /^4\.[02]$/: {
- $zabbixapi_version = '4.1.2'
+ '4.0': {
+ $zabbixapi_version = '4.2.0'
}
'4.4': {
$zabbixapi_version = '4.2.0'

MODIFY
spec/acceptance/zabbix_application_spec.rb
spec/acceptance/zabbix_application_spec.rb
@@ -3,7 +3,18 @@ require 'serverspec_type_zabbixapi'
# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_application type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9|debian-10)-amd64} do
- context 'create zabbix_application resources' do
+ %w[4.0 5.0 5.2].each do |zabbix_version|
+ # 5.2 server packages are not available for RHEL 7
+ next if zabbix_version == '5.2' and default[:platform] == 'el-7-x86_64'
+
+ template = case zabbix_version
+ when '4.0'
+ 'Template OS Linux'
+ else
+ 'Template OS Linux by Zabbix agent'
+ end
+
+ context "create zabbix_application 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
pp1 = <<-EOS
@@ -18,7 +29,6 @@ describe 'zabbix_application type', unless: default[:platform] =~ %r{(ubuntu-16.
}
include apache::mod::php
class { 'postgresql::globals':
- encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => true,
version => '12',
@@ -26,7 +36,7 @@ describe 'zabbix_application type', unless: default[:platform] =~ %r{(ubuntu-16.
-> class { 'postgresql::server': }
class { 'zabbix':
- zabbix_version => '5.0',
+ zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
@@ -39,7 +49,7 @@ describe 'zabbix_application type', unless: default[:platform] =~ %r{(ubuntu-16.
pp2 = <<-EOS
zabbix_application { 'TestApplication1':
- template => 'Template OS Linux by Zabbix agent',
+ template => "#{template}",
}
EOS
# setup zabbix. Apache module isn't idempotent and requires a second run
@@ -68,10 +78,11 @@ describe 'zabbix_application type', unless: default[:platform] =~ %r{(ubuntu-16.
end
context 'TestApplication1' do
- let(:template1) { result_templates.select { |t| t['host'] == 'Template OS Linux by Zabbix agent' }.first }
+ let(:template1) { result_templates.select { |t| t['host'] == template }.first }
- it 'is attached to Template OS Linux by Zabbix agent' do
+ it "is attached to #{template}" do
expect(template1['applications'].map { |a| a['name'] }).to include('TestApplication1')
end
end
end
+end

MODIFY
spec/acceptance/zabbix_host_spec.rb
spec/acceptance/zabbix_host_spec.rb
@@ -3,16 +3,32 @@ require 'serverspec_type_zabbixapi'
# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_host type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9|debian-10)-amd64} do
- context 'create zabbix_host resources' do
+ %w[4.0 5.0 5.2].each do |zabbix_version|
+ # 5.2 server packages are not available for RHEL 7
+ next if zabbix_version == '5.2' and default[:platform] == 'el-7-x86_64'
+ 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
+
+ template = case zabbix_version
+ when '4.0'
+ 'Template OS Linux'
+ else
+ 'Template OS Linux by Zabbix agent'
+ end
+
pp1 = <<-EOS
+ $compile_packages = $facts['os']['family'] ? {
+ 'RedHat' => [ 'make', 'gcc-c++', 'rubygems', 'ruby'],
+ 'Debian' => [ 'make', 'g++', 'ruby-dev', 'ruby', 'pkg-config',],
+ default => [],
+ }
+ ensure_packages($compile_packages, { before => Package['zabbixapi'], })
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php
class { 'postgresql::globals':
- encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => true,
version => '12',
@@ -20,7 +36,7 @@ class { 'postgresql::globals':
-> class { 'postgresql::server': }
class { 'zabbix':
- zabbix_version => '5.0',
+ zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
@@ -29,6 +45,7 @@ class { 'zabbix':
require => [ Class['postgresql::server'], Class['apache'], ],
}
EOS
+
# setup zabbix. Apache module isn't idempotent and requires a second run
it 'works with no error on the first apply' do
# Cleanup old database
@@ -48,15 +65,16 @@ zabbix_host { 'test1.example.com':
port => 10050,
groups => ['TestgroupOne'],
group_create => true,
- templates => [ 'Template OS Linux by Zabbix agent', ],
+ templates => [ "#{template}", ],
macros => [],
}
+
zabbix_host { 'test2.example.com':
ipaddress => '127.0.0.2',
use_ip => false,
port => 1050,
groups => ['Virtual machines'],
- templates => [ 'Template OS Linux by Zabbix agent', 'Template Module ICMP Ping', ],
+ templates => [ "#{template}", 'Template Module ICMP Ping', ],
macros => [],
}
EOS
@@ -102,7 +120,7 @@ zabbix_host { 'test2.example.com':
expect(test1['interfaces'][0]['useip']).to eq('1')
end
it 'has templates attached' do
- expect(test1['parentTemplates'].map { |t| t['host'] }.sort).to eq(['Template OS Linux by Zabbix agent'])
+ expect(test1['parentTemplates'].map { |t| t['host'] }.sort).to eq([template])
end
end
@@ -134,7 +152,8 @@ zabbix_host { 'test2.example.com':
expect(test2['interfaces'][0]['useip']).to eq('0')
end
it 'has templates attached' do
- expect(test2['parentTemplates'].map { |t| t['host'] }.sort).to eq(['Template Module ICMP Ping', 'Template OS Linux by Zabbix agent'])
+ expect(test2['parentTemplates'].map { |t| t['host'] }.sort).to eq(['Template Module ICMP Ping', template])
+ end
end
end
end

MODIFY
spec/acceptance/zabbix_hostgroup_spec.rb
spec/acceptance/zabbix_hostgroup_spec.rb
@@ -3,17 +3,18 @@ require 'serverspec_type_zabbixapi'
# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_hostgroup type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9|debian-10)-amd64} do
- context 'create zabbix_hostgroup resources' do
- it 'runs successfully' do
+ %w[4.0 5.0 5.2].each do |zabbix_version|
+ # 5.2 server packages are not available for RHEL 7
+ next if zabbix_version == '5.2' and default[:platform] == 'el-7-x86_64'
+ 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
- pp = <<-EOS
+ pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php
class { 'postgresql::globals':
- encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => true,
version => '12',
@@ -21,7 +22,7 @@ describe 'zabbix_hostgroup type', unless: default[:platform] =~ %r{(ubuntu-16.04
-> class { 'postgresql::server': }
class { 'zabbix':
- zabbix_version => '5.0',
+ zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
@@ -29,10 +30,10 @@ describe 'zabbix_hostgroup type', unless: default[:platform] =~ %r{(ubuntu-16.04
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
+ EOS
- Zabbix_hostgroup {
- require => [ Service['zabbix-server'], Package['zabbixapi'], ],
- }
+ pp2 = <<-EOS
+ Zabbix_hostgroup { }
zabbix_hostgroup { 'Testgroup2': }
zabbix_hostgroup { 'Linux servers':
@@ -40,10 +41,21 @@ describe 'zabbix_hostgroup type', unless: default[:platform] =~ %r{(ubuntu-16.04
}
EOS
+ # setup zabbix. Apache module isn't idempotent and requires a second run
+ it 'works with no error on the first apply' do
# Cleanup old database
prepare_host
- apply_manifest(pp, catch_failures: true)
+ apply_manifest(pp1, catch_failures: true)
+ end
+
+ it 'works with no error on the second apply' do
+ apply_manifest(pp1, catch_failures: true)
+ end
+
+ it 'works with no error on the third apply' do
+ apply_manifest(pp2, catch_failures: true)
+ end
end
let(:result_hostgroups) do

MODIFY
spec/acceptance/zabbix_proxy_spec.rb
spec/acceptance/zabbix_proxy_spec.rb
@@ -3,7 +3,10 @@ require 'serverspec_type_zabbixapi'
# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_proxy type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9|debian-10)-amd64} do
- context 'create zabbix_proxy resources' do
+ %w[4.0 5.0 5.2].each do |zabbix_version|
+ # 5.2 server packages are not available for RHEL 7
+ next if zabbix_version == '5.2' and default[:platform] == 'el-7-x86_64'
+ 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
pp1 = <<-EOS
@@ -12,7 +15,6 @@ describe 'zabbix_proxy type', unless: default[:platform] =~ %r{(ubuntu-16.04|deb
}
include apache::mod::php
class { 'postgresql::globals':
- encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => true,
version => '12',
@@ -20,7 +22,7 @@ describe 'zabbix_proxy type', unless: default[:platform] =~ %r{(ubuntu-16.04|deb
-> class { 'postgresql::server': }
class { 'zabbix':
- zabbix_version => '5.0',
+ zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
@@ -30,13 +32,15 @@ describe 'zabbix_proxy type', unless: default[:platform] =~ %r{(ubuntu-16.04|deb
}
EOS
+ # setup zabbix. Apache module isn't idempotent and requires a second run
+ it 'works with no error on first apply' do
# Cleanup old database
prepare_host
- it 'works idempotently with no errors' do
- # Run it twice and test for idempotency
apply_manifest(pp1, catch_failures: true)
- apply_manifest(pp1, catch_changes: true)
+ end
+ it 'works with no error on second apply' do
+ apply_manifest(pp1, catch_failures: true)
end
# setup proxies within zabbix
@@ -197,3 +201,4 @@ describe 'zabbix_proxy type', unless: default[:platform] =~ %r{(ubuntu-16.04|deb
end
end
end
+end

MODIFY
spec/acceptance/zabbix_template_host_spec.rb
spec/acceptance/zabbix_template_host_spec.rb
@@ -3,17 +3,26 @@ require 'serverspec_type_zabbixapi'
# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_template_host type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9|debian-10)-amd64} do
- context 'create zabbix_template_host resources' do
- it 'runs successfully' do
+ %w[4.0 5.0 5.2].each do |zabbix_version|
+ # 5.2 server packages are not available for RHEL 7
+ next if zabbix_version == '5.2' and default[:platform] == 'el-7-x86_64'
+ context "create zabbix_template_host resources with zabbix version #{zabbix_version}" do
+ template = case zabbix_version
+ when '4.0'
+ 'Template OS Linux'
+ else
+ 'Template OS Linux by Zabbix agent'
+ end
+
+
# This will deploy a running Zabbix setup (server, web, db) which we can
# use for custom type tests
- pp = <<-EOS
+ pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php
class { 'postgresql::globals':
- encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => true,
version => '12',
@@ -21,7 +30,7 @@ describe 'zabbix_template_host type', unless: default[:platform] =~ %r{(ubuntu-1
-> class { 'postgresql::server': }
class { 'zabbix':
- zabbix_version => '5.0',
+ zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
@@ -29,33 +38,42 @@ describe 'zabbix_template_host type', unless: default[:platform] =~ %r{(ubuntu-1
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
+ EOS
+ pp2 = <<-EOS
zabbix_host { 'test1.example.com':
ipaddress => '127.0.0.1',
use_ip => true,
port => 10050,
group => 'TestgroupOne',
group_create => true,
- templates => [ 'Template OS Linux by Zabbix agent', ],
- require => [ Service['zabbix-server'], Package['zabbixapi'], ],
+ templates => [ "#{template}", ],
}
zabbix_template { 'TestTemplate1':
template_source => '/root/TestTemplate1.xml',
- require => [ Service['zabbix-server'], Package['zabbixapi'], ],
}
- zabbix_template_host{"TestTemplate1@test1.example.com":
- require => [ Service['zabbix-server'], Package['zabbixapi'], ],
- }
+ zabbix_template_host{ "TestTemplate1@test1.example.com": }
EOS
shell("echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?><zabbix_export><version>4.0</version><date>2018-12-13T15:00:46Z</date><groups><group><name>Templates/Applications</name></group></groups><templates><template><template>TestTemplate1</template><name>TestTemplate1</name><description/><groups><group><name>Templates/Applications</name></group></groups><applications/><items/><discovery_rules/><macros/><templates/><screens/></template></templates></zabbix_export>' > /root/TestTemplate1.xml")
+ # setup zabbix. Apache module isn't idempotent and requires a second run
+ it 'works with no error on the first apply' do
# Cleanup old database
prepare_host
- apply_manifest(pp, catch_failures: true)
+ apply_manifest(pp1, catch_failures: true)
+ end
+
+ it 'works with no error on the second apply' do
+ apply_manifest(pp1, catch_failures: true)
+ end
+
+ it 'works with no error on the third apply' do
+ apply_manifest(pp2, catch_failures: true)
+ end
end
let(:result_hosts) do

MODIFY
spec/acceptance/zabbix_template_spec.rb
spec/acceptance/zabbix_template_spec.rb
@@ -3,17 +3,18 @@ require 'serverspec_type_zabbixapi'
# rubocop:disable RSpec/LetBeforeExamples
describe 'zabbix_template type', unless: default[:platform] =~ %r{(ubuntu-16.04|debian-9|debian-10)-amd64} do
- context 'create zabbix_template resources' do
- it 'runs successfully' do
+ %w[4.0 5.0 5.2].each do |zabbix_version|
+ # 5.2 server packages are not available for RHEL 7
+ next if zabbix_version == '5.2' and default[:platform] == 'el-7-x86_64'
+ 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
- pp = <<-EOS
+ pp1 = <<-EOS
class { 'apache':
mpm_module => 'prefork',
}
include apache::mod::php
class { 'postgresql::globals':
- encoding => 'UTF-8',
locale => 'en_US.UTF-8',
manage_package_repo => true,
version => '12',
@@ -21,7 +22,7 @@ describe 'zabbix_template type', unless: default[:platform] =~ %r{(ubuntu-16.04|
-> class { 'postgresql::server': }
class { 'zabbix':
- zabbix_version => '5.0',
+ zabbix_version => "#{zabbix_version}",
zabbix_url => 'localhost',
zabbix_api_user => 'Admin',
zabbix_api_pass => 'zabbix',
@@ -29,19 +30,31 @@ describe 'zabbix_template type', unless: default[:platform] =~ %r{(ubuntu-16.04|
manage_resources => true,
require => [ Class['postgresql::server'], Class['apache'], ],
}
+ EOS
+ pp2 = <<-EOS
zabbix_template { 'TestTemplate1':
template_source => '/root/TestTemplate1.xml',
- require => [ Service['zabbix-server'], Package['zabbixapi'], ],
}
EOS
shell("echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?><zabbix_export><version>4.0</version><date>2018-12-13T15:00:46Z</date><groups><group><name>Templates/Applications</name></group></groups><templates><template><template>TestTemplate1</template><name>TestTemplate1</name><description/><groups><group><name>Templates/Applications</name></group></groups><applications/><items/><discovery_rules/><macros/><templates/><screens/></template></templates></zabbix_export>' > /root/TestTemplate1.xml")
+ # setup zabbix. Apache module isn't idempotent and requires a second run
+ it 'works with no error on the first apply' do
# Cleanup old database
prepare_host
- apply_manifest(pp, catch_failures: true)
+ apply_manifest(pp1, catch_failures: true)
+ end
+
+ it 'works with no error on the second apply' do
+ apply_manifest(pp1, catch_failures: true)
+ end
+
+ it 'works with no error on the third apply' do
+ apply_manifest(pp2, catch_failures: true)
+ end
end
let(:result_templates) do

MODIFY
spec/support/acceptance/prepare_host.rb
spec/support/acceptance/prepare_host.rb
@@ -19,6 +19,7 @@ def prepare_host
/opt/puppetlabs/bin/puppet resource package zabbix-web-pgsql-scl ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-web-mysql-scl ensure=purged
/opt/puppetlabs/bin/puppet resource package zabbix-frontend-php ensure=purged
+ /opt/puppetlabs/bin/puppet/gem uninstall zabbixapi -a
rm -f /etc/zabbix/.*done
if id postgres > /dev/null 2>&1; then
su - postgres -c "psql -c 'drop database if exists zabbix_server;'"

Run acceptance tests for all supported versions

Signed-off-by: Christos Papageorgiou <root.expert.xda@gmail.com>