Skip to content

Commit

Permalink
Added/updated tests for Zabbix 3.0 #176
Browse files Browse the repository at this point in the history
  • Loading branch information
Werner Dijkerman committed Mar 3, 2016
1 parent 45d7dba commit 1b21cfb
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 23 deletions.
26 changes: 23 additions & 3 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
}
end

context 'On RedHat 6.5' do
context 'On RedHat 7.1' do
let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.5',
:operatingsystemrelease => '7.1',
:architecture => 'x86_64',
:lsbdistid => 'RedHat',
:concat_basedir => '/tmp',
Expand All @@ -38,7 +38,7 @@
}
end

it { should contain_class('zabbix::repo').with_zabbix_version('2.4') }
it { should contain_class('zabbix::repo').with_zabbix_version('3.0') }
it { should contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]')}
end

Expand Down Expand Up @@ -105,6 +105,16 @@
:startagents => '3',
:timeout => '30',
:unsafeuserparameters => '0',
:tlsconnect => 'cert',
:tlsaccept => 'cert',
:tlscafile => '/etc/zabbix/keys/file.ca',
:tlscrlfile => '/etc/zabbix/keys/file.crl',
:tlsservercertissuer => 'Zabbix.Com',
:tlsservercertsubject => 'MySubJect',
:tlscertfile => '/etc/zabbix/keys/tls.crt',
:tlskeyfile => '/etc/zabbix/keys/tls.key',
:tlspskidentity => '/etc/zabbix/keys/tlspskidentity.id',
:tlspskfile => '/etc/zabbix/keys/tlspskfile.key',
}
end

Expand All @@ -127,6 +137,16 @@
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^StartAgents=3$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Timeout=30$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^UnsafeUserParameters=0$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSConnect=cert$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSAccept=cert$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/file.ca$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/file.crl$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSServerCertIssuer=Zabbix.Com$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSServerCertSubject=MySubJect$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/tls.crt$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/tls.key$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSPSKIdentity=/etc/zabbix/keys/tlspskidentity.id$}}
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSPSKFile=/etc/zabbix/keys/tlspskfile.key$}}
end
end
end
43 changes: 36 additions & 7 deletions spec/classes/proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
}
end

context 'On RedHat 6.5' do
context 'On RedHat 7.1' do
let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.5',
:operatingsystemmajrelease => '6',
:operatingsystemrelease => '7.1',
:operatingsystemmajrelease => '7',
:architecture => 'x86_64',
:lsbdistid => 'RedHat',
:concat_basedir => '/tmp',
Expand All @@ -37,7 +37,7 @@
}
end

it { should contain_class('zabbix::repo').with_zabbix_version('2.4') }
it { should contain_class('zabbix::repo').with_zabbix_version('3.0') }
it { should contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') }
end

Expand Down Expand Up @@ -88,7 +88,7 @@
end

it { should contain_class('zabbix::database::postgresql').with_zabbix_type('proxy')}
it { should contain_class('zabbix::database::postgresql').with_zabbix_version('2.4')}
it { should contain_class('zabbix::database::postgresql').with_zabbix_version('3.0')}
it { should contain_class('zabbix::database::postgresql').with_database_name('zabbix_proxy')}
it { should contain_class('zabbix::database::postgresql').with_database_user('zabbix-proxy')}
it { should contain_class('zabbix::database::postgresql').with_database_password('zabbix-proxy')}
Expand All @@ -108,7 +108,7 @@
end

it { should contain_class('zabbix::database::mysql').with_zabbix_type('proxy')}
it { should contain_class('zabbix::database::mysql').with_zabbix_version('2.4')}
it { should contain_class('zabbix::database::mysql').with_zabbix_version('3.0')}
it { should contain_class('zabbix::database::mysql').with_database_name('zabbix_proxy')}
it { should contain_class('zabbix::database::mysql').with_database_user('zabbix-proxy')}
it { should contain_class('zabbix::database::mysql').with_database_password('zabbix-proxy')}
Expand Down Expand Up @@ -272,7 +272,36 @@
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Include=/etc/zabbix/zabbix_proxy.conf.d$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModule=pizza$}}
end
end

context "with zabbix_proxy.conf and version 3.0" do
let (:params) do
{
:tlsaccept => 'cert',
:tlscafile => '/etc/zabbix/keys/zabbix-server.ca',
:tlscrlfile => '/etc/zabbix/keys/zabbix-server.crl',
:tlscertfile => '/etc/zabbix/keys/zabbix-server.crt',
:tlskeyfile => '/etc/zabbix/keys/zabbix-server.key',
:tlsservercertissuer => 'Zabbix.Com',
:tlsservercertsubject => 'MyZabbix',
:tlspskidentity => '/etc/zabbix/keys/identity.file',
:tlspskfile => '/etc/zabbix/keys/file.key',
:zabbix_version => '3.0',
}
end

it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/zabbix-server.ca$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/zabbix-server.crl$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/zabbix-server.crt$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/zabbix-server.key$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSServerCertIssuer=Zabbix.Com$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSServerCertSubject=MyZabbix$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSPSKIdentity=/etc/zabbix/keys/identity.file$}}
it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSPSKFile=/etc/zabbix/keys/file.key$}}
end


end # END context 'zabbix_proxy.conf configuration'
end

103 changes: 95 additions & 8 deletions spec/classes/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@
it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/debian/') }
end

context "on Debian 8 and Zabbix 3.0" do
let (:params) do
{
:zabbix_version => '3.0',
:manage_repo => true,
}
end

let (:facts) do
{
:operatingsystem => 'Debian',
:operatingsystemrelease => '8',
:lsbdistcodename => 'jessie',
:architecture => 'x86_64',
:lsbdistid => 'Debian',
:osfamily => 'Debian'
}
end

it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/3.0/debian/') }
end

context "on Ubuntu 12.04 and Zabbix 2.0" do
let (:params) do
{
Expand Down Expand Up @@ -155,6 +177,49 @@
it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/ubuntu/') }
end

context "on Ubuntu 14.04 and Zabbix 2.4" do
let (:params) do
{
:zabbix_version => '2.4',
:manage_repo => true,
}
end

let (:facts) do
{
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
:lsbdistcodename => 'Trusty',
:architecture => 'x86_64',
:lsbdistid => 'Ubuntu',
:osfamily => 'Debian'
}
end

it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/ubuntu/') }
end

context "on Ubuntu 14.04 and Zabbix 3.0" do
let (:params) do
{
:zabbix_version => '3.0',
:manage_repo => true,
}
end

let (:facts) do
{
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => '14.04',
:lsbdistcodename => 'Trusty',
:architecture => 'x86_64',
:lsbdistid => 'Ubuntu',
:osfamily => 'Debian'
}
end

it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/3.0/ubuntu/') }
end

context "on RedHat 5 and Zabbix 2.0" do
let (:params) do
Expand All @@ -173,8 +238,8 @@
}
end

it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel//$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel//$basearch/') }
end

context "on RedHat 6 and Zabbix 2.0" do
Expand All @@ -195,8 +260,8 @@
}
end

it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel//$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel//$basearch/') }
end

context "on RedHat 6 and Zabbix 2.2" do
Expand All @@ -217,8 +282,8 @@
}
end

it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.2/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.2/rhel//$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel//$basearch/') }
end

context "on RedHat 6 and Zabbix 2.4" do
Expand All @@ -239,7 +304,29 @@
}
end

it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.4/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/$releasever/$basearch/') }
it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.4/rhel//$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel//$basearch/') }
end

context "on RedHat 7 and Zabbix 3.0" do
let (:params) do
{
:zabbix_version => '3.0',
:manage_repo => true,
}
end

let (:facts) do
{
:operatingsystem => 'RedHat',
:operatingsystemrelease => '7',
:architecture => 'x86_64',
:osfamily => 'RedHat',
:$majorrelease => '7'
}
end

it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.0/rhel//$basearch/') }
it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel//$basearch/') }
end
end
27 changes: 22 additions & 5 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
describe 'zabbix::server' do
let (:params) do
{
:zabbix_version => '2.4',
:zabbix_version => '3.0',
}
end

let (:node) { 'rspec.puppet.com' }

context 'On RedHat 6.5' do
context 'On RedHat 7.1' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.5',
:operatingsystemrelease => '7.1',
:architecture => 'x86_64',
:lsbdistid => 'RedHat',
:concat_basedir => '/tmp'
Expand Down Expand Up @@ -66,7 +66,7 @@
end

it { should contain_class('zabbix::database::postgresql').with_zabbix_type('server')}
it { should contain_class('zabbix::database::postgresql').with_zabbix_version('2.4')}
it { should contain_class('zabbix::database::postgresql').with_zabbix_version('3.0')}
it { should contain_class('zabbix::database::postgresql').with_database_name('zabbix-server')}
it { should contain_class('zabbix::database::postgresql').with_database_user('zabbix-server')}
it { should contain_class('zabbix::database::postgresql').with_database_password('zabbix-server')}
Expand All @@ -85,7 +85,7 @@
end

it { should contain_class('zabbix::database::mysql').with_zabbix_type('server')}
it { should contain_class('zabbix::database::mysql').with_zabbix_version('2.4')}
it { should contain_class('zabbix::database::mysql').with_zabbix_version('3.0')}
it { should contain_class('zabbix::database::mysql').with_database_name('zabbix-server')}
it { should contain_class('zabbix::database::mysql').with_database_user('zabbix-server')}
it { should contain_class('zabbix::database::mysql').with_database_password('zabbix-server')}
Expand Down Expand Up @@ -263,5 +263,22 @@
it { should_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoEvents=0}}
it { should_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoHistory=0}}
end

context "with zabbix_server.conf and version 3.0" do
let (:params) do
{
:tlscafile => '/etc/zabbix/keys/zabbix-server.ca',
:tlscrlfile => '/etc/zabbix/keys/zabbix-server.crl',
:tlscertfile => '/etc/zabbix/keys/zabbix-server.crt',
:tlskeyfile => '/etc/zabbix/keys/zabbix-server.key',
:zabbix_version => '3.0',
}
end

it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/zabbix-server.ca$}}
it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/zabbix-server.crl$}}
it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/zabbix-server.crt$}}
it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/zabbix-server.key$}}
end
end
end

0 comments on commit 1b21cfb

Please sign in to comment.