From db69ba8917caad74a1f1cbebe046e57f0eb4707f Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 28 Oct 2016 00:21:08 +0200 Subject: [PATCH 1/3] rubocop: fix RSpec/ImplicitExpect --- spec/classes/agent_spec.rb | 96 +++++------ spec/classes/database_mysql_spec.rb | 44 ++--- spec/classes/database_postgresql_spec.rb | 14 +- spec/classes/database_spec.rb | 70 ++++---- spec/classes/javagateway_spec.rb | 20 +-- spec/classes/proxy_spec.rb | 210 +++++++++++------------ spec/classes/repo_spec.rb | 84 ++++----- spec/classes/sender_spec.rb | 14 +- spec/classes/server_spec.rb | 202 +++++++++++----------- spec/classes/userparameter_spec.rb | 4 +- spec/classes/web_spec.rb | 44 ++--- spec/defines/startup_spec.rb | 52 +++--- spec/defines/userparameters_spec.rb | 4 +- 13 files changed, 429 insertions(+), 429 deletions(-) diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index 693664220..bcdcbfeb7 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -39,7 +39,7 @@ end # Make sure package will be installed, service running and ensure of directory. it do - should contain_package(package).with( + is_expected.to contain_package(package).with( ensure: 'present', require: 'Class[Zabbix::Repo]', tag: 'zabbix' @@ -47,7 +47,7 @@ end it do - should contain_service('zabbix-agent').with( + is_expected.to contain_service('zabbix-agent').with( ensure: 'running', enable: true, hasstatus: true, @@ -56,10 +56,10 @@ ) end - it { should contain_file('/etc/zabbix/zabbix_agentd.d').with_ensure('directory') } - it { should contain_zabbix__startup('zabbix-agent').that_requires("Package[#{package}]") } - it { should compile.with_all_deps } - it { should contain_class('zabbix::params') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d').with_ensure('directory') } + it { is_expected.to contain_zabbix__startup('zabbix-agent').that_requires("Package[#{package}]") } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('zabbix::params') } end context 'when declaring manage_repo is true' do @@ -71,10 +71,10 @@ case facts[:osfamily] when 'Archlinux' - it { should raise_error(Puppet::Error, %r{Managing a repo on Archlinux is currently not implemented}) } + it { is_expected.to raise_error(Puppet::Error, %r{Managing a repo on Archlinux is currently not implemented}) } else - it { should contain_class('zabbix::repo').with_zabbix_version('3.0') } - it { should contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('3.0') } + it { is_expected.to contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]') } end end @@ -85,7 +85,7 @@ } end - it { should contain_class('zabbix::resources::agent') } + it { is_expected.to contain_class('zabbix::resources::agent') } end context 'configuration file with hostnameitem' do @@ -95,7 +95,7 @@ } end - it { should contain_file(config_path).with_content %r{^HostnameItem=system.hostname$} } + it { is_expected.to contain_file(config_path).with_content %r{^HostnameItem=system.hostname$} } end context 'ignores hostnameitem if hostname is set' do @@ -106,8 +106,8 @@ } end - it { should contain_file(config_path).without_content %r{^HostnameItem=system.hostname$} } - it { should contain_file(config_path).with_content %r{^Hostname=test$} } + it { is_expected.to contain_file(config_path).without_content %r{^HostnameItem=system.hostname$} } + it { is_expected.to contain_file(config_path).with_content %r{^Hostname=test$} } end context 'when declaring manage_firewall is true' do @@ -117,7 +117,7 @@ } end - it { should contain_firewall('150 zabbix-agent') } + it { is_expected.to contain_firewall('150 zabbix-agent') } end context 'when declaring manage_firewall is false' do @@ -127,17 +127,17 @@ } end - it { should_not contain_firewall('150 zabbix-agent') } + it { is_expected.to_not contain_firewall('150 zabbix-agent') } end context 'it creates a startup script' do case facts[:osfamily] when 'Archlinux', 'Fedora' - it { should contain_file('/etc/init.d/zabbix-agent').with_ensure('absent') } - it { should contain_file('/etc/systemd/system/zabbix-agent.service').with_ensure('file') } + it { is_expected.to contain_file('/etc/init.d/zabbix-agent').with_ensure('absent') } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-agent.service').with_ensure('file') } else - it { should contain_file('/etc/init.d/zabbix-agent').with_ensure('file') } - it { should_not contain_file('/etc/systemd/system/zabbix-agent.service') } + it { is_expected.to contain_file('/etc/init.d/zabbix-agent').with_ensure('file') } + it { is_expected.to_not contain_file('/etc/systemd/system/zabbix-agent.service') } end end context 'configuration file with full options' do @@ -176,35 +176,35 @@ } end - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^AllowRoot=0$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSend=5$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSize=100$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^DebugLevel=4$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^EnableRemoteCommands=1$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Hostname=10050$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Include=/etc/zabbix/zabbix_agentd.d$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ListenPort=10050$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogFileSize=4$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_agentd.log$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogRemoteCommands=0$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^PidFile=/var/run/zabbix/zabbix_agentd.pid$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^RefreshActiveChecks=120$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Server=192.168.1.1$} } - it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ServerActive=192.168.1.1$} } - 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$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^AllowRoot=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSend=5$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSize=100$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^DebugLevel=4$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^EnableRemoteCommands=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Hostname=10050$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Include=/etc/zabbix/zabbix_agentd.d$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ListenPort=10050$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogFileSize=4$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_agentd.log$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogRemoteCommands=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^PidFile=/var/run/zabbix/zabbix_agentd.pid$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^RefreshActiveChecks=120$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Server=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ServerActive=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^StartAgents=3$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Timeout=30$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^UnsafeUserParameters=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSConnect=cert$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSAccept=cert$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/file.ca$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/file.crl$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSServerCertIssuer=Zabbix.Com$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSServerCertSubject=MySubJect$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/tls.crt$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/tls.key$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSPSKIdentity=/etc/zabbix/keys/tlspskidentity.id$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^TLSPSKFile=/etc/zabbix/keys/tlspskfile.key$} } end end end diff --git a/spec/classes/database_mysql_spec.rb b/spec/classes/database_mysql_spec.rb index 527019ee1..42fae5174 100644 --- a/spec/classes/database_mysql_spec.rb +++ b/spec/classes/database_mysql_spec.rb @@ -11,7 +11,7 @@ end context 'with all defaults' do it 'fails' do - should raise_error(Puppet::Error, %r{We do not work.}) + is_expected.to raise_error(Puppet::Error, %r{We do not work.}) end end path2 = if facts[:osfamily] == 'RedHat' @@ -36,11 +36,11 @@ } end - it { should contain_class('zabbix::database::mysql') } - it { should compile.with_all_deps } - it { should contain_exec('zabbix_server_create.sql').with_command("cd #{path2} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < schema.sql && touch /etc/zabbix/.schema.done") } - it { should contain_exec('zabbix_server_images.sql').with_command("cd #{path2} && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < images.sql && touch /etc/zabbix/.images.done") } - it { should contain_exec('zabbix_server_data.sql').with_command("cd #{path2} && if [ -f data.sql.gz ]; then gunzip -f data.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < data.sql && touch /etc/zabbix/.data.done") } + it { is_expected.to contain_class('zabbix::database::mysql') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path2} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_images.sql').with_command("cd #{path2} && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < images.sql && touch /etc/zabbix/.images.done") } + it { is_expected.to contain_exec('zabbix_server_data.sql').with_command("cd #{path2} && if [ -f data.sql.gz ]; then gunzip -f data.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < data.sql && touch /etc/zabbix/.data.done") } end describe 'when zabbix_type is proxy and zabbix version is 2.4' do @@ -54,10 +54,10 @@ zabbix_version: '2.4' } end - it { should contain_class('zabbix::database::mysql') } + it { is_expected.to contain_class('zabbix::database::mysql') } # this doesn't make much sense because the class requires other classes # it { should compile.with_all_deps } - it { should contain_exec('zabbix_proxy_create.sql').with_command("cd #{path2} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path2} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } end context 'when zabbix_type is server and zabbix version is 3.0' do let :params do @@ -70,11 +70,11 @@ zabbix_version: '3.0' } end - it { should contain_class('zabbix::database::mysql') } - it { should compile.with_all_deps } - it { should contain_exec('zabbix_server_create.sql').with_command("cd #{path3} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < create.sql && touch /etc/zabbix/.schema.done") } - it { should contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } - it { should contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } + it { is_expected.to contain_class('zabbix::database::mysql') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path3} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < create.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } + it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } end describe 'when zabbix_type is proxy and zabbix version is 3.0' do @@ -88,10 +88,10 @@ zabbix_version: '3.0' } end - it { should contain_class('zabbix::database::mysql') } + it { is_expected.to contain_class('zabbix::database::mysql') } # this doesn't make much sense because the class requires other classes # it { should compile.with_all_deps } - it { should contain_exec('zabbix_proxy_create.sql').with_command("cd #{path3} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path3} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } end context 'when zabbix_type is server and zabbix version is 3.2' do let :params do @@ -104,11 +104,11 @@ zabbix_version: '3.2' } end - it { should contain_class('zabbix::database::mysql') } - it { should compile.with_all_deps } - it { should contain_exec('zabbix_server_create.sql').with_command("cd #{path3} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < create.sql && touch /etc/zabbix/.schema.done") } - it { should contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } - it { should contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } + it { is_expected.to contain_class('zabbix::database::mysql') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path3} && if [ -f create.sql.gz ]; then gunzip -f create.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < create.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_images.sql').with_command('touch /etc/zabbix/.images.done') } + it { is_expected.to contain_exec('zabbix_server_data.sql').with_command('touch /etc/zabbix/.data.done') } end describe 'when zabbix_type is proxy and zabbix version is 3.2' do @@ -122,10 +122,10 @@ zabbix_version: '3.2' } end - it { should contain_class('zabbix::database::mysql') } + it { is_expected.to contain_class('zabbix::database::mysql') } # this doesn't make much sense because the class requires other classes # it { should compile.with_all_deps } - it { should contain_exec('zabbix_proxy_create.sql').with_command("cd #{path3} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd #{path3} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-proxy' -p'zabbix-proxy' -D 'zabbix-proxy' < schema.sql && touch /etc/zabbix/.schema.done") } end end end diff --git a/spec/classes/database_postgresql_spec.rb b/spec/classes/database_postgresql_spec.rb index 2e89a93ed..1fd2939d4 100644 --- a/spec/classes/database_postgresql_spec.rb +++ b/spec/classes/database_postgresql_spec.rb @@ -42,11 +42,11 @@ } end - it { should contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') } - it { should contain_exec('zabbix_server_create.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f schema.sql && touch /etc/zabbix/.schema.done") } - it { should contain_exec('zabbix_server_images.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f images.sql && touch /etc/zabbix/.images.done") } - it { should contain_exec('zabbix_server_data.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f data.sql.gz ]; then gunzip -f data.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f data.sql && touch /etc/zabbix/.data.done") } - it { should contain_file('/root/.pgpass') } + it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-server:zabbix-server:zabbix-server >> /root/.pgpass') } + it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('zabbix_server_images.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f images.sql && touch /etc/zabbix/.images.done") } + it { is_expected.to contain_exec('zabbix_server_data.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f data.sql.gz ]; then gunzip -f data.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f data.sql && touch /etc/zabbix/.data.done") } + it { is_expected.to contain_file('/root/.pgpass') } end describe 'when zabbix_type is proxy' do @@ -61,8 +61,8 @@ } end - it { should contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-proxy:zabbix-proxy:zabbix-proxy >> /root/.pgpass') } - it { should contain_exec('zabbix_proxy_create.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-proxy:zabbix-proxy:zabbix-proxy >> /root/.pgpass') } + it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } end end end diff --git a/spec/classes/database_spec.rb b/spec/classes/database_spec.rb index 48aa02477..b4f617750 100644 --- a/spec/classes/database_spec.rb +++ b/spec/classes/database_spec.rb @@ -42,16 +42,16 @@ } end - it { should contain_postgresql__server__db('zabbix-server').with_name('zabbix-server') } - it { should contain_postgresql__server__db('zabbix-server').with_user('zabbix-server') } + it { is_expected.to contain_postgresql__server__db('zabbix-server').with_name('zabbix-server') } + it { is_expected.to contain_postgresql__server__db('zabbix-server').with_user('zabbix-server') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_database('zabbix-server') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_user('zabbix-server') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_address('127.0.0.1/32') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_database('zabbix-server') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_user('zabbix-server') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_address('127.0.0.1/32') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } end describe 'database_type is postgresql, zabbix_type is server and is single node setup' do @@ -66,16 +66,16 @@ } end - it { should contain_postgresql__server__db('zabbix-server').with_name('zabbix-server') } - it { should contain_postgresql__server__db('zabbix-server').with_user('zabbix-server') } + it { is_expected.to contain_postgresql__server__db('zabbix-server').with_name('zabbix-server') } + it { is_expected.to contain_postgresql__server__db('zabbix-server').with_user('zabbix-server') } - it { should_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_database('zabbix-server') } - it { should_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_user('zabbix-server') } - it { should_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_address('127.0.0.1/32') } + it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_database('zabbix-server') } + it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_user('zabbix-server') } + it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_address('127.0.0.1/32') } - it { should_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } - it { should_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } - it { should_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } + it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } + it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } + it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } end describe 'database_type is postgresql, zabbix_type is proxy' do @@ -89,9 +89,9 @@ } end - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_database('zabbix-proxy') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_user('zabbix-proxy') } - it { should contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_address('127.0.0.1/32') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_database('zabbix-proxy') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_user('zabbix-proxy') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_address('127.0.0.1/32') } end describe 'database_type is mysql, zabbix_type is server and is multiple host setup' do @@ -106,14 +106,14 @@ } end - it { should contain_mysql__db('zabbix-server').with_name('zabbix-server') } - it { should contain_mysql__db('zabbix-server').with_user('zabbix-server') } - it { should contain_mysql__db('zabbix-server').with_host('node0.example.com') } + it { is_expected.to contain_mysql__db('zabbix-server').with_name('zabbix-server') } + it { is_expected.to contain_mysql__db('zabbix-server').with_user('zabbix-server') } + it { is_expected.to contain_mysql__db('zabbix-server').with_host('node0.example.com') } - it { should contain_mysql_user('zabbix-server@node1.example.com').with_name('zabbix-server@node1.example.com') } - it { should contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } - it { should contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } - it { should contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } + it { is_expected.to contain_mysql_user('zabbix-server@node1.example.com').with_name('zabbix-server@node1.example.com') } + it { is_expected.to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } + it { is_expected.to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } + it { is_expected.to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } end describe 'database_type is mysql, zabbix_type is server and is a single host setup' do @@ -128,14 +128,14 @@ } end - it { should contain_mysql__db('zabbix-server').with_name('zabbix-server') } - it { should contain_mysql__db('zabbix-server').with_user('zabbix-server') } - it { should contain_mysql__db('zabbix-server').with_host('node0.example.com') } + it { is_expected.to contain_mysql__db('zabbix-server').with_name('zabbix-server') } + it { is_expected.to contain_mysql__db('zabbix-server').with_user('zabbix-server') } + it { is_expected.to contain_mysql__db('zabbix-server').with_host('node0.example.com') } - it { should_not contain_mysql_user('zabbix-server@node1.example.com').with_name('zabbix-server@node1.example.com') } - it { should_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } - it { should_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } - it { should_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } + it { is_expected.to_not contain_mysql_user('zabbix-server@node1.example.com').with_name('zabbix-server@node1.example.com') } + it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } + it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } + it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } end describe 'database_type is mysql, zabbix_type is proxy and is a single host setup' do @@ -149,7 +149,7 @@ } end - it { should contain_mysql__db('zabbix-proxy').with_name('zabbix-proxy') } + it { is_expected.to contain_mysql__db('zabbix-proxy').with_name('zabbix-proxy') } end describe 'database_type is sqlite, zabbix_type is proxy and is a multiple host setup' do @@ -164,7 +164,7 @@ } end - it { should contain_class('zabbix::database::sqlite') } + it { is_expected.to contain_class('zabbix::database::sqlite') } end end end diff --git a/spec/classes/javagateway_spec.rb b/spec/classes/javagateway_spec.rb index a158d6885..129fe0216 100644 --- a/spec/classes/javagateway_spec.rb +++ b/spec/classes/javagateway_spec.rb @@ -26,9 +26,9 @@ } end - it { should contain_file('/etc/zabbix/zabbix_java_gateway.conf') } - it { should contain_service('zabbix-java-gateway') } - it { should contain_package('zabbix-java-gateway') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_java_gateway.conf') } + it { is_expected.to contain_service('zabbix-java-gateway') } + it { is_expected.to contain_package('zabbix-java-gateway') } context 'when declaring manage_repo is true' do let :params do @@ -37,7 +37,7 @@ } end - it { should contain_class('Zabbix::Repo') } + it { is_expected.to contain_class('Zabbix::Repo') } end context 'when declaring manage_firewall is true' do @@ -47,7 +47,7 @@ } end - it { should contain_firewall('152 zabbix-javagateway') } + it { is_expected.to contain_firewall('152 zabbix-javagateway') } end context 'when declaring manage_firewall is false' do @@ -57,7 +57,7 @@ } end - it { should_not contain_firewall('152 zabbix-javagateway') } + it { is_expected.to_not contain_firewall('152 zabbix-javagateway') } end context 'with zabbix_java_gateway.conf settings' do @@ -70,10 +70,10 @@ } end - it { should contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^LISTEN_IP=192.168.1.1$} } - it { should contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^LISTEN_PORT=10052$} } - it { should contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^PID_FILE=/var/run/zabbix/zabbix_java.pid$} } - it { should contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^START_POLLERS=5$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^LISTEN_IP=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^LISTEN_PORT=10052$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^PID_FILE=/var/run/zabbix/zabbix_java.pid$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_java_gateway.conf').with_content %r{^START_POLLERS=5$} } end end end diff --git a/spec/classes/proxy_spec.rb b/spec/classes/proxy_spec.rb index 0a6db811b..caa2bfa69 100644 --- a/spec/classes/proxy_spec.rb +++ b/spec/classes/proxy_spec.rb @@ -38,8 +38,8 @@ "class {'postgresql::server':}" end - it { should contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_ensure('directory') } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_require('File[/etc/zabbix/zabbix_proxy.conf]') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_ensure('directory') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_require('File[/etc/zabbix/zabbix_proxy.conf]') } describe 'when manage_repo is true and zabbix version is unset' do let :params do @@ -48,8 +48,8 @@ } end - it { should contain_class('zabbix::repo').with_zabbix_version('3.0') } - it { should contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('3.0') } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } end describe 'when manage_repo is true and zabbix version is 2.4' do @@ -60,16 +60,16 @@ } end - it { should contain_class('zabbix::repo').with_zabbix_version('2.4') } - it { should contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } - it { should contain_package('zabbix-proxy').with_ensure('present') } + it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('2.4') } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_package('zabbix-proxy').with_ensure('present') } end describe 'with enabled selinux' do let :facts do super().merge(selinux_config_mode: 'enforcing') end - it { should contain_selboolean('zabbix_can_network').with('value' => 'on', 'persistent' => true) } + it { is_expected.to contain_selboolean('zabbix_can_network').with('value' => 'on', 'persistent' => true) } end describe 'when database_type is postgresql' do @@ -79,11 +79,11 @@ } end - it { should contain_package('zabbix-proxy-pgsql').with_ensure('present') } - it { should contain_package('zabbix-proxy-pgsql').with_ensure('present') } - it { should contain_package('zabbix-proxy-pgsql').with_name('zabbix-proxy-pgsql') } - it { should contain_service('zabbix-proxy').with_require(['Package[zabbix-proxy-pgsql]', 'File[/etc/zabbix/zabbix_proxy.conf.d]', 'File[/etc/zabbix/zabbix_proxy.conf]']) } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-pgsql]') } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-proxy-pgsql').with_name('zabbix-proxy-pgsql') } + it { is_expected.to contain_service('zabbix-proxy').with_require(['Package[zabbix-proxy-pgsql]', 'File[/etc/zabbix/zabbix_proxy.conf.d]', 'File[/etc/zabbix/zabbix_proxy.conf]']) } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-pgsql]') } end describe 'when database_type is mysql' do @@ -93,11 +93,11 @@ } end - it { should contain_package('zabbix-proxy-mysql').with_ensure('present') } - it { should contain_package('zabbix-proxy-mysql').with_ensure('present') } - it { should contain_package('zabbix-proxy-mysql').with_name('zabbix-proxy-mysql') } - it { should contain_service('zabbix-proxy').with_require(['Package[zabbix-proxy-mysql]', 'File[/etc/zabbix/zabbix_proxy.conf.d]', 'File[/etc/zabbix/zabbix_proxy.conf]']) } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-mysql]') } + it { is_expected.to contain_package('zabbix-proxy-mysql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-proxy-mysql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-proxy-mysql').with_name('zabbix-proxy-mysql') } + it { is_expected.to contain_service('zabbix-proxy').with_require(['Package[zabbix-proxy-mysql]', 'File[/etc/zabbix/zabbix_proxy.conf.d]', 'File[/etc/zabbix/zabbix_proxy.conf]']) } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_require('Package[zabbix-proxy-mysql]') } end describe 'when manage_resources is true' do @@ -108,7 +108,7 @@ } end - it { should contain_class('zabbix::resources::proxy') } + it { is_expected.to contain_class('zabbix::resources::proxy') } end context 'with zabbix::database::postgresql class' do @@ -119,12 +119,12 @@ } end - it { should contain_class('zabbix::database::postgresql').with_zabbix_type('proxy') } - 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') } - it { should contain_class('zabbix::database::postgresql').with_database_host('localhost') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_type('proxy') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_version('3.0') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_name('zabbix_proxy') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_user('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_password('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_host('localhost') } end context 'with zabbix::database::mysql class' do @@ -139,12 +139,12 @@ "include 'mysql::server'" end - it { should contain_class('zabbix::database::mysql').with_zabbix_type('proxy') } - 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') } - it { should contain_class('zabbix::database::mysql').with_database_host('localhost') } + it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_type('proxy') } + it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_version('3.0') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_name('zabbix_proxy') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_user('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_password('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_host('localhost') } end context 'when manage_database is true' do @@ -154,14 +154,14 @@ } end - it { should contain_class('zabbix::database').with_zabbix_type('proxy') } - it { should contain_class('zabbix::database').with_database_type('postgresql') } - it { should contain_class('zabbix::database').with_database_name('zabbix_proxy') } - it { should contain_class('zabbix::database').with_database_user('zabbix-proxy') } - it { should contain_class('zabbix::database').with_database_password('zabbix-proxy') } - it { should contain_class('zabbix::database').with_database_host('localhost') } - it { should contain_class('zabbix::database').with_zabbix_proxy('localhost') } - it { should contain_class('zabbix::database').with_zabbix_proxy_ip('127.0.0.1') } + it { is_expected.to contain_class('zabbix::database').with_zabbix_type('proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_type('postgresql') } + it { is_expected.to contain_class('zabbix::database').with_database_name('zabbix_proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_user('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_password('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::database').with_database_host('localhost') } + it { is_expected.to contain_class('zabbix::database').with_zabbix_proxy('localhost') } + it { is_expected.to contain_class('zabbix::database').with_zabbix_proxy_ip('127.0.0.1') } end context 'when declaring manage_firewall is true' do @@ -171,7 +171,7 @@ } end - it { should contain_firewall('151 zabbix-proxy') } + it { is_expected.to contain_firewall('151 zabbix-proxy') } end context 'when declaring manage_firewall is false' do @@ -181,7 +181,7 @@ } end - it { should_not contain_firewall('151 zabbix-proxy') } + it { is_expected.to_not contain_firewall('151 zabbix-proxy') } end # Make sure we have set some vars in zabbix_proxy.conf file. This is configuration file is the same on all @@ -248,61 +248,61 @@ } end - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyMode=0$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Server=192.168.1.1$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ServerPort=10051$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Hostname=rspec.puppet.com$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenPort=10051$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/proxy_server.log$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DebugLevel=4$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^PidFile=/var/run/zabbix/proxy_server.pid$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBHost=localhost$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBName=zabbix-proxy$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBSchema=zabbix-proxy$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBUser=zabbix-proxy$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBPassword=zabbix-proxy$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyLocalBuffer=0$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyOfflineBuffer=1$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HeartbeatFrequency=60$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ConfigFrequency=3600$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DataSenderFrequency=1$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollers=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartIPMIPollers=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollersUnreachable=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartTrappers=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPingers=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDiscoverers=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartHTTPPollers=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGateway=192.168.1.2$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGatewayPort=10051$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartJavaPollers=5$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartVMwareCollectors=0$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareFrequency=60$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareCacheSize=8M$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SNMPTrapperFile=/tmp/zabbix_traps.tmp$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartSNMPTrapper=0$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenIP=192.168.1.1$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HousekeepingFrequency=1$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^CacheSize=8M$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDBSyncers=4$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HistoryCacheSize=16M$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HistoryTextCacheSize=8M$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Timeout=20$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TrapperTimeout=16$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachablePeriod=45$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnavailableDelay=60$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachableDelay=15$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ExternalScripts=/usr/lib/zabbix/externalscripts$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^FpingLocation=60$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Fping6Location=/usr/sbin/fping6$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSHKeyLocation=/home/zabbix/.ssh/$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogSlowQueries=0$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TmpDir=/tmp$} } - it { should contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^AllowRoot=0$} } - 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$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyMode=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Server=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ServerPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Hostname=rspec.puppet.com$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFile=/var/log/zabbix/proxy_server.log$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogFileSize=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DebugLevel=4$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^PidFile=/var/run/zabbix/proxy_server.pid$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBHost=localhost$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBName=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBSchema=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBUser=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DBPassword=zabbix-proxy$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyLocalBuffer=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ProxyOfflineBuffer=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HeartbeatFrequency=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ConfigFrequency=3600$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^DataSenderFrequency=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartIPMIPollers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPollersUnreachable=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartTrappers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartPingers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDiscoverers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartHTTPPollers=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGateway=192.168.1.2$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^JavaGatewayPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartJavaPollers=5$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartVMwareCollectors=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareFrequency=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^VMwareCacheSize=8M$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SNMPTrapperFile=/tmp/zabbix_traps.tmp$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartSNMPTrapper=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ListenIP=192.168.1.1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HousekeepingFrequency=1$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^CacheSize=8M$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^StartDBSyncers=4$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HistoryCacheSize=16M$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^HistoryTextCacheSize=8M$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Timeout=20$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TrapperTimeout=16$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachablePeriod=45$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnavailableDelay=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^UnreachableDelay=15$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^ExternalScripts=/usr/lib/zabbix/externalscripts$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^FpingLocation=60$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Fping6Location=/usr/sbin/fping6$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^SSHKeyLocation=/home/zabbix/.ssh/$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LogSlowQueries=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TmpDir=/tmp$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^AllowRoot=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^Include=/etc/zabbix/zabbix_proxy.conf.d$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^LoadModule=pizza$} } end context 'with zabbix_proxy.conf and version 3.0' do @@ -321,15 +321,15 @@ } 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$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSAccept=cert$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/zabbix-server.ca$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/zabbix-server.crl$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/zabbix-server.crt$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/zabbix-server.key$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSServerCertIssuer=Zabbix.Com$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSServerCertSubject=MyZabbix$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf').with_content %r{^TLSPSKIdentity=/etc/zabbix/keys/identity.file$} } + it { is_expected.to 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 diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 684b16de9..b80ca319d 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -28,7 +28,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.0/debian/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.0/debian/') } end context 'on Debian 7 and Zabbix 2.0' do @@ -58,7 +58,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.0/debian/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.0/debian/') } end context 'on Debian 7 and Zabbix 2.2' do @@ -88,7 +88,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.2/debian/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.2/debian/') } end context 'on Debian 7 and Zabbix 2.4' do @@ -118,7 +118,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/debian/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/debian/') } end context 'on Debian 8 and Zabbix 3.0' do @@ -148,7 +148,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/3.0/debian/') } + it { is_expected.to 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 @@ -178,7 +178,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.0/ubuntu/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.0/ubuntu/') } end context 'on Ubuntu 12.04 and Zabbix 2.2' do @@ -208,7 +208,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.2/ubuntu/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.2/ubuntu/') } end context 'on Ubuntu 12.04 and Zabbix 2.4' do @@ -238,7 +238,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/ubuntu/') } + it { is_expected.to 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 @@ -269,7 +269,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/2.4/ubuntu/') } + it { is_expected.to 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 @@ -300,7 +300,7 @@ } end - it { should contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/3.0/ubuntu/') } + it { is_expected.to contain_apt__source('zabbix').with_location('http://repo.zabbix.com/zabbix/3.0/ubuntu/') } end context 'on RedHat 5 and Zabbix 2.0' do @@ -329,10 +329,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel/5/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/5/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel/5/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/5/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } end context 'on RedHat 6 and Zabbix 2.0' do @@ -362,10 +362,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.0/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } end context 'on RedHat 6 and Zabbix 2.2' do @@ -395,10 +395,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.2/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.2/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } end context 'on RedHat 6 and Zabbix 2.4' do @@ -428,10 +428,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.4/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/2.4/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } end context 'on RedHat 6 and Zabbix 3.0' do @@ -461,10 +461,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.0/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.0/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } end context 'on RedHat 6 and Zabbix 3.2' do @@ -494,10 +494,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.2/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.2/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/6/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } end context 'on RedHat 7 and Zabbix 3.0' do @@ -527,10 +527,10 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.0/rhel/7/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/7/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.0/rhel/7/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/7/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX') } end context 'on RedHat 7 and Zabbix 3.2' do @@ -560,9 +560,9 @@ } end - it { should contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/') } - it { should contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } - it { should contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/7/$basearch/') } - it { should contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } + it { is_expected.to contain_yumrepo('zabbix').with_baseurl('http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_baseurl('http://repo.zabbix.com/non-supported/rhel/7/$basearch/') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported').with_gpgkey('http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX-A14FE591') } end end diff --git a/spec/classes/sender_spec.rb b/spec/classes/sender_spec.rb index 89643925a..1d47c79cd 100644 --- a/spec/classes/sender_spec.rb +++ b/spec/classes/sender_spec.rb @@ -10,11 +10,11 @@ facts end context 'with all defaults' do - it { should contain_class('zabbix::sender') } - it { should compile.with_all_deps } + it { is_expected.to contain_class('zabbix::sender') } + it { is_expected.to compile.with_all_deps } # Make sure package will be installed, service running and ensure of directory. - it { should contain_package('zabbix-sender').with_ensure('present') } - it { should contain_package('zabbix-sender').with_name('zabbix-sender') } + it { is_expected.to contain_package('zabbix-sender').with_ensure('present') } + it { is_expected.to contain_package('zabbix-sender').with_name('zabbix-sender') } end context 'when declaring manage_repo is true' do let :params do @@ -24,11 +24,11 @@ end if facts[:osfamily] == 'Archlinux' it 'fails' do - should raise_error(Puppet::Error, %r{Managing a repo on Archlinux is currently not implemented}) + is_expected.to raise_error(Puppet::Error, %r{Managing a repo on Archlinux is currently not implemented}) end else - it { should contain_class('zabbix::repo').with_zabbix_version('3.0') } - it { should contain_package('zabbix-sender').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('3.0') } + it { is_expected.to contain_package('zabbix-sender').with_require('Class[Zabbix::Repo]') } end end end diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 896386d27..f3dfeb967 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -24,17 +24,17 @@ end describe 'with default settings' do - it { should contain_class('zabbix::repo') } - it { should contain_service('zabbix-server').with_ensure('running') } - it { should_not contain_selboolean('zabbix_can_network') } - it { should contain_zabbix__startup('zabbix-server') } + it { is_expected.to contain_class('zabbix::repo') } + it { is_expected.to contain_service('zabbix-server').with_ensure('running') } + it { is_expected.to_not contain_selboolean('zabbix_can_network') } + it { is_expected.to contain_zabbix__startup('zabbix-server') } end describe 'with enabled selinux' do let :facts do super().merge(selinux_config_mode: 'enforcing') end - it { should contain_selboolean('zabbix_can_network').with('value' => 'on', 'persistent' => true) } + it { is_expected.to contain_selboolean('zabbix_can_network').with('value' => 'on', 'persistent' => true) } end describe 'with database_type as postgresql' do @@ -46,9 +46,9 @@ } end - it { should contain_package('zabbix-server-pgsql').with_ensure('present') } - it { should contain_package('zabbix-server-pgsql').with_name('zabbix-server-pgsql') } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_require('Package[zabbix-server-pgsql]') } + it { is_expected.to contain_package('zabbix-server-pgsql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-server-pgsql').with_name('zabbix-server-pgsql') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_require('Package[zabbix-server-pgsql]') } end describe 'with database_type as mysql' do @@ -58,14 +58,14 @@ } end - it { should contain_package('zabbix-server-mysql').with_ensure('present') } - it { should contain_package('zabbix-server-mysql').with_name('zabbix-server-mysql') } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_require('Package[zabbix-server-mysql]') } + it { is_expected.to contain_package('zabbix-server-mysql').with_ensure('present') } + it { is_expected.to contain_package('zabbix-server-mysql').with_name('zabbix-server-mysql') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_require('Package[zabbix-server-mysql]') } end # Include directory should be available. - it { should contain_file('/etc/zabbix/zabbix_server.conf.d').with_ensure('directory') } - it { should contain_file('/etc/zabbix/zabbix_server.conf.d').with_require('File[/etc/zabbix/zabbix_server.conf]') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf.d').with_ensure('directory') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf.d').with_require('File[/etc/zabbix/zabbix_server.conf]') } context 'with zabbix::database::postgresql class' do let :params do @@ -78,12 +78,12 @@ } end - it { should contain_class('zabbix::database::postgresql').with_zabbix_type('server') } - 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') } - it { should contain_class('zabbix::database::postgresql').with_database_host('localhost') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_type('server') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_zabbix_version('3.0') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_name('zabbix-server') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_user('zabbix-server') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_password('zabbix-server') } + it { is_expected.to contain_class('zabbix::database::postgresql').with_database_host('localhost') } end context 'with zabbix::database::mysql class' do @@ -97,12 +97,12 @@ } end - it { should contain_class('zabbix::database::mysql').with_zabbix_type('server') } - 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') } - it { should contain_class('zabbix::database::mysql').with_database_host('localhost') } + it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_type('server') } + it { is_expected.to contain_class('zabbix::database::mysql').with_zabbix_version('3.0') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_name('zabbix-server') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_user('zabbix-server') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_password('zabbix-server') } + it { is_expected.to contain_class('zabbix::database::mysql').with_database_host('localhost') } end # So if manage_firewall is set to true, it should install @@ -114,7 +114,7 @@ } end - it { should contain_firewall('151 zabbix-server') } + it { is_expected.to contain_firewall('151 zabbix-server') } end context 'when declaring manage_firewall is false' do @@ -124,7 +124,7 @@ } end - it { should_not contain_firewall('151 zabbix-server') } + it { is_expected.to_not contain_firewall('151 zabbix-server') } end # If manage_service is true (default), it should create a service @@ -136,7 +136,7 @@ } end - it { should contain_service('zabbix-server').with_ensure('running') } + it { is_expected.to contain_service('zabbix-server').with_ensure('running') } end # When the manage_service is false, it may not make the service. @@ -147,7 +147,7 @@ } end - it { should_not contain_service('zabbix-server') } + it { is_expected.to_not contain_service('zabbix-server') } end context 'with all zabbix_server.conf-related parameters' do @@ -218,67 +218,67 @@ } end - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^AlertScriptsPath=\$\{datadir\}/zabbix/alertscripts} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^AllowRoot=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^CacheSize=8M} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^CacheUpdateFrequency=30} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBHost=localhost} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBName=zabbix-server} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBPassword=zabbix-server} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBPort=3306} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBSchema=zabbix-server} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBSocket=/tmp/socket.db} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBUser=zabbix-server} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DebugLevel=3} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ExternalScripts=/usr/lib/zabbix/externalscripts} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^Fping6Location=/usr/sbin/fping6} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^FpingLocation=/usr/sbin/fping} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^HistoryCacheSize=4M} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^HistoryTextCacheSize=4M} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^HousekeepingFrequency=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^Include=/etc/zabbix/zabbix_server.conf.d} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^JavaGateway=192.168.2.2} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^JavaGatewayPort=10052} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ListenIP=192.168.1.1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ListenPort=10051$} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LoadModule = pizza} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogFileSize=10} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_server.log} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogSlowQueries=0} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^MaxHousekeeperDelete=500} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeID=0$} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoEvents=0} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoHistory=0} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^PidFile=/var/run/zabbix/zabbix_server.pid} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ProxyConfigFrequency=3600} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ProxyDataFrequency=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SenderFrequency=30} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SNMPTrapperFile=/tmp/zabbix_traps.tmp} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SourceIP=192.168.1.1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SSHKeyLocation=/home/zabbix} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartDBSyncers=4} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartDiscoverers=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartHTTPPollers=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartIPMIPollers=12} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartPingers=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartPollers=12} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartPollersUnreachable=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartProxyPollers=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartSNMPTrapper=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartTimers=1} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartTrappers=5} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartVMwareCollectors=5} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^Timeout=3} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TmpDir=/tmp} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TrapperTimeout=30} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TrendCacheSize=4M} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^UnavailableDelay=30} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^UnreachableDelay=30} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^UnreachablePeriod=30} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ValueCacheSize=4M} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^VMwareCacheSize=8M} } - it { should contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^VMwareFrequency=60} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^AlertScriptsPath=\$\{datadir\}/zabbix/alertscripts} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^AllowRoot=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^CacheSize=8M} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^CacheUpdateFrequency=30} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBHost=localhost} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBName=zabbix-server} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBPassword=zabbix-server} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBPort=3306} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBSchema=zabbix-server} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBSocket=/tmp/socket.db} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DBUser=zabbix-server} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^DebugLevel=3} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ExternalScripts=/usr/lib/zabbix/externalscripts} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^Fping6Location=/usr/sbin/fping6} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^FpingLocation=/usr/sbin/fping} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^HistoryCacheSize=4M} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^HistoryTextCacheSize=4M} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^HousekeepingFrequency=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^Include=/etc/zabbix/zabbix_server.conf.d} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^JavaGateway=192.168.2.2} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^JavaGatewayPort=10052} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ListenIP=192.168.1.1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ListenPort=10051$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LoadModule = pizza} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogFileSize=10} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_server.log} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^LogSlowQueries=0} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^MaxHousekeeperDelete=500} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeID=0$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoEvents=0} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoHistory=0} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^PidFile=/var/run/zabbix/zabbix_server.pid} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ProxyConfigFrequency=3600} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ProxyDataFrequency=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SenderFrequency=30} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SNMPTrapperFile=/tmp/zabbix_traps.tmp} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SourceIP=192.168.1.1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^SSHKeyLocation=/home/zabbix} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartDBSyncers=4} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartDiscoverers=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartHTTPPollers=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartIPMIPollers=12} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartPingers=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartPollers=12} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartPollersUnreachable=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartProxyPollers=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartSNMPTrapper=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartTimers=1} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartTrappers=5} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^StartVMwareCollectors=5} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^Timeout=3} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TmpDir=/tmp} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TrapperTimeout=30} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TrendCacheSize=4M} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^UnavailableDelay=30} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^UnreachableDelay=30} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^UnreachablePeriod=30} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^ValueCacheSize=4M} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^VMwareCacheSize=8M} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^VMwareFrequency=60} } end context 'with zabbix_server.conf and version 2.4' do @@ -291,9 +291,9 @@ } end - it { should_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeID=0$} } - 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} } + it { is_expected.to_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeID=0$} } + it { is_expected.to_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoEvents=0} } + it { is_expected.to_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoHistory=0} } end context 'with zabbix_server.conf and version 3.0' do @@ -307,10 +307,10 @@ } 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$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/zabbix-server.ca$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/zabbix-server.crl$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/zabbix-server.crt$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/zabbix-server.key$} } end context 'with zabbix_server.conf and version 3.2' do let :params do @@ -323,10 +323,10 @@ } 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$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCAFile=/etc/zabbix/keys/zabbix-server.ca$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCRLFile=/etc/zabbix/keys/zabbix-server.crl$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSCertFile=/etc/zabbix/keys/zabbix-server.crt$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^TLSKeyFile=/etc/zabbix/keys/zabbix-server.key$} } end end end diff --git a/spec/classes/userparameter_spec.rb b/spec/classes/userparameter_spec.rb index 1aab7f7dc..13fde143d 100644 --- a/spec/classes/userparameter_spec.rb +++ b/spec/classes/userparameter_spec.rb @@ -10,8 +10,8 @@ facts end context 'with all defaults' do - it { should contain_class('zabbix::userparameter') } - it { should compile.with_all_deps } + it { is_expected.to contain_class('zabbix::userparameter') } + it { is_expected.to compile.with_all_deps } end end end diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index cf078453d..94cbf7796 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -26,8 +26,8 @@ def package_provider_for_gems end else context 'with all defaults' do - it { should compile.with_all_deps } - it { should contain_file('/etc/zabbix/web').with_ensure('directory') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_file('/etc/zabbix/web').with_ensure('directory') } end describe 'with enforcing selinux' do @@ -35,9 +35,9 @@ def package_provider_for_gems super().merge(selinux_config_mode: 'enforcing') end if facts[:osfamily] == 'RedHat' - it { should contain_selboolean('httpd_can_connect_zabbix').with('value' => 'on', 'persistent' => true) } + it { is_expected.to contain_selboolean('httpd_can_connect_zabbix').with('value' => 'on', 'persistent' => true) } else - it { should_not contain_selboolean('httpd_can_connect_zabbix') } + it { is_expected.to_not contain_selboolean('httpd_can_connect_zabbix') } end end @@ -46,7 +46,7 @@ def package_provider_for_gems let :facts do super().merge(selinux_config_mode: mode) end - it { should_not contain_selboolean('httpd_can_connect_zabbix') } + it { is_expected.to_not contain_selboolean('httpd_can_connect_zabbix') } end end @@ -74,9 +74,9 @@ def package_provider_for_gems packages = facts[:osfamily] == 'RedHat' ? ['zabbix-web-pgsql', 'zabbix-web'] : ['zabbix-frontend-php', pgsqlpackage] packages.each do |package| - it { should contain_package(package) } + it { is_expected.to contain_package(package) } end - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'POSTGRESQL'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'POSTGRESQL'}) } end describe 'with database_type as mysql' do @@ -103,12 +103,12 @@ def package_provider_for_gems packages = facts[:osfamily] == 'RedHat' ? ['zabbix-web-mysql', 'zabbix-web'] : ['zabbix-frontend-php', mysqlpackage] packages.each do |package| - it { should contain_package(package) } + it { is_expected.to contain_package(package) } end - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'MYSQL'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['TYPE'\] = 'MYSQL'}) } end - it { should contain_file('/etc/zabbix/web/zabbix.conf.php') } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php') } describe 'when manage_resources is true' do let :params do @@ -117,10 +117,10 @@ def package_provider_for_gems ) end - it { should contain_class('zabbix::resources::web') } - it { should contain_package('zabbixapi').that_requires('Class[ruby::dev]').with_provider(package_provider_for_gems) } - it { should contain_class('ruby::dev') } - it { should contain_file('/etc/zabbix/imported_templates').with_ensure('directory') } + it { is_expected.to contain_class('zabbix::resources::web') } + it { is_expected.to contain_package('zabbixapi').that_requires('Class[ruby::dev]').with_provider(package_provider_for_gems) } + it { is_expected.to contain_class('ruby::dev') } + it { is_expected.to contain_file('/etc/zabbix/imported_templates').with_ensure('directory') } end describe 'when manage_resources and is_pe are true' do @@ -135,7 +135,7 @@ def package_provider_for_gems super().merge(manage_resources: true) end - it { should contain_package('zabbixapi').with_provider('pe_puppetserver_gem') } + it { is_expected.to contain_package('zabbixapi').with_provider('pe_puppetserver_gem') } end describe 'when manage_resources is false' do @@ -143,10 +143,10 @@ def package_provider_for_gems super().merge(manage_resources: false) end - it { should_not contain_class('zabbix::resources::web') } + it { is_expected.to_not contain_class('zabbix::resources::web') } end - it { should contain_apache__vhost('zabbix.example.com').with_name('zabbix.example.com') } + it { is_expected.to contain_apache__vhost('zabbix.example.com').with_name('zabbix.example.com') } context 'with database_* settings' do let :params do @@ -159,11 +159,11 @@ def package_provider_for_gems ) end - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['SERVER'\] = 'localhost'}) } - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['DATABASE'\] = 'zabbix-server'}) } - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['USER'\] = 'zabbix-server'}) } - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['PASSWORD'\] = 'zabbix-server'}) } - it { should contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$ZBX_SERVER = 'localhost'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['SERVER'\] = 'localhost'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['DATABASE'\] = 'zabbix-server'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['USER'\] = 'zabbix-server'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$DB\['PASSWORD'\] = 'zabbix-server'}) } + it { is_expected.to contain_file('/etc/zabbix/web/zabbix.conf.php').with_content(%r{^\$ZBX_SERVER = 'localhost'}) } end end end diff --git a/spec/defines/startup_spec.rb b/spec/defines/startup_spec.rb index 4bef94d5e..959a09e06 100644 --- a/spec/defines/startup_spec.rb +++ b/spec/defines/startup_spec.rb @@ -22,31 +22,31 @@ end if osfamily == 'Debian' it do - should contain_file('/etc/init.d/zabbix-agent').with( + is_expected.to contain_file('/etc/init.d/zabbix-agent').with( ensure: 'file', content: %r{DAEMON_OPTS="-c /something"} ) end elsif osfamily == 'RedHat' it do - should contain_file('/etc/init.d/zabbix-agent').with( + is_expected.to contain_file('/etc/init.d/zabbix-agent').with( ensure: 'file', content: %r{OPTS="/something"} ) end else - it { should raise_error(Puppet::Error, %r{We currently only support Debian and RedHat osfamily as non-systemd}) } + it { is_expected.to raise_error(Puppet::Error, %r{We currently only support Debian and RedHat osfamily as non-systemd}) } next end - it { should_not contain_class('systemd') } - it { should_not contain_file('/etc/systemd/system/zabbix-agent.service') } + it { is_expected.to_not contain_class('systemd') } + it { is_expected.to_not contain_file('/etc/systemd/system/zabbix-agent.service') } end context 'it fails when agent_configfile_path param is missing' do let :params do {} end - it { should raise_error(Puppet::Error, %r{you have to provide a agent_configfile_path param}) } + it { is_expected.to raise_error(Puppet::Error, %r{you have to provide a agent_configfile_path param}) } end end end @@ -67,16 +67,16 @@ pidfile: '/somethingelse' } end - it { should contain_class('systemd') } - it { should contain_file('/etc/init.d/zabbix-agent').with_ensure('absent') } + it { is_expected.to contain_class('systemd') } + it { is_expected.to contain_file('/etc/init.d/zabbix-agent').with_ensure('absent') } it do - should contain_file('/etc/systemd/system/zabbix-agent.service').with( + is_expected.to contain_file('/etc/systemd/system/zabbix-agent.service').with( ensure: 'file', mode: '0664' ).that_notifies('Exec[systemctl-daemon-reload]') end - it { should contain_file('/etc/systemd/system/zabbix-agent.service').with_content(%r{ExecStart=/usr/sbin/zabbix_agentd -c /something}) } - it { should contain_file('/etc/systemd/system/zabbix-agent.service').with_content(%r{PIDFile=/somethingelse}) } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-agent.service').with_content(%r{ExecStart=/usr/sbin/zabbix_agentd -c /something}) } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-agent.service').with_content(%r{PIDFile=/somethingelse}) } end context 'it fails when pidfile param is missing' do @@ -85,7 +85,7 @@ agent_configfile_path: '/something' } end - it { should raise_error(Puppet::Error, %r{you have to provide a pidfile param}) } + it { is_expected.to raise_error(Puppet::Error, %r{you have to provide a pidfile param}) } end end end @@ -113,31 +113,31 @@ end if osfamily == 'Debian' it do - should contain_file('/etc/init.d/zabbix-server').with( + is_expected.to contain_file('/etc/init.d/zabbix-server').with( ensure: 'file', content: %r{DAEMON_OPTS="-c /something"} ) end elsif osfamily == 'RedHat' it do - should contain_file('/etc/init.d/zabbix-server').with( + is_expected.to contain_file('/etc/init.d/zabbix-server').with( ensure: 'file', content: %r{OPTS="/something"} ) end else - it { should raise_error(Puppet::Error, %r{We currently only support Debian and RedHat osfamily as non-systemd}) } + it { is_expected.to raise_error(Puppet::Error, %r{We currently only support Debian and RedHat osfamily as non-systemd}) } next end - it { should_not contain_class('systemd') } - it { should_not contain_file('/etc/systemd/system/zabbix-server.service') } + it { is_expected.to_not contain_class('systemd') } + it { is_expected.to_not contain_file('/etc/systemd/system/zabbix-server.service') } end context 'it fails when server_configfile_path param is missing' do let :params do {} end - it { should raise_error(Puppet::Error, %r{you have to provide a server_configfile_path param}) } + it { is_expected.to raise_error(Puppet::Error, %r{you have to provide a server_configfile_path param}) } end end end @@ -159,17 +159,17 @@ database_type: 'mysql' } end - it { should contain_class('systemd') } - it { should contain_file('/etc/init.d/zabbix-server').with_ensure('absent') } + it { is_expected.to contain_class('systemd') } + it { is_expected.to contain_file('/etc/init.d/zabbix-server').with_ensure('absent') } it do - should contain_file('/etc/systemd/system/zabbix-server.service').with( + is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with( ensure: 'file', mode: '0664' ).that_notifies('Exec[systemctl-daemon-reload]') end - it { should contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{ExecStart=/usr/sbin/zabbix_server -c /something}) } - it { should contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{PIDFile=/somethingelse}) } - it { should contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{After=syslog.target network.target mysqld.service}) } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{ExecStart=/usr/sbin/zabbix_server -c /something}) } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{PIDFile=/somethingelse}) } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{After=syslog.target network.target mysqld.service}) } context 'and works on postgres' do let :params do @@ -179,7 +179,7 @@ database_type: 'postgres' } end - it { should contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{After=syslog.target network.target postgresql.service}) } + it { is_expected.to contain_file('/etc/systemd/system/zabbix-server.service').with_content(%r{After=syslog.target network.target postgresql.service}) } end end @@ -190,7 +190,7 @@ pidfile: '/somethingelse' } end - it { should raise_error(Puppet::Error, %r{you have to provide a database_type param}) } + it { is_expected.to raise_error(Puppet::Error, %r{you have to provide a database_type param}) } end end end diff --git a/spec/defines/userparameters_spec.rb b/spec/defines/userparameters_spec.rb index 5634649ed..56e87037f 100644 --- a/spec/defines/userparameters_spec.rb +++ b/spec/defines/userparameters_spec.rb @@ -26,7 +26,7 @@ context 'with an content' do let(:params) { { content: 'UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive' } } - it { should contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_ensure('present') } - it { should contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_content %r{^UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive$} } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_ensure('present') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_content %r{^UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive$} } end end From 439c4eb9490c289f810424ab8605956816daaa88 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 28 Oct 2016 01:36:35 +0200 Subject: [PATCH 2/3] increase rspec coverage --- spec/classes/agent_spec.rb | 8 +++++++- spec/classes/database_mysql_spec.rb | 1 + spec/classes/database_postgresql_spec.rb | 2 ++ spec/classes/database_spec.rb | 8 ++++++++ spec/classes/javagateway_spec.rb | 6 +++++- spec/classes/proxy_spec.rb | 11 +++++++++++ spec/defines/userparameters_spec.rb | 11 +++++++++++ 7 files changed, 45 insertions(+), 2 deletions(-) diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index bcdcbfeb7..429fab57e 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -72,9 +72,15 @@ case facts[:osfamily] when 'Archlinux' it { is_expected.to raise_error(Puppet::Error, %r{Managing a repo on Archlinux is currently not implemented}) } - else + when 'Debian' + it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('3.0') } + it { is_expected.to contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_apt__source('zabbix') } + when 'RedHat' it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('3.0') } it { is_expected.to contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported') } + it { is_expected.to contain_yumrepo('zabbix') } end end diff --git a/spec/classes/database_mysql_spec.rb b/spec/classes/database_mysql_spec.rb index 42fae5174..965beead1 100644 --- a/spec/classes/database_mysql_spec.rb +++ b/spec/classes/database_mysql_spec.rb @@ -41,6 +41,7 @@ it { is_expected.to contain_exec('zabbix_server_create.sql').with_command("cd #{path2} && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < schema.sql && touch /etc/zabbix/.schema.done") } it { is_expected.to contain_exec('zabbix_server_images.sql').with_command("cd #{path2} && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < images.sql && touch /etc/zabbix/.images.done") } it { is_expected.to contain_exec('zabbix_server_data.sql').with_command("cd #{path2} && if [ -f data.sql.gz ]; then gunzip -f data.sql.gz ; fi && mysql -h 'rspec.puppet.com' -u 'zabbix-server' -p'zabbix-server' -D 'zabbix-server' < data.sql && touch /etc/zabbix/.data.done") } + it { is_expected.to contain_class('zabbix::params') } end describe 'when zabbix_type is proxy and zabbix version is 2.4' do diff --git a/spec/classes/database_postgresql_spec.rb b/spec/classes/database_postgresql_spec.rb index 1fd2939d4..bcf65b8d2 100644 --- a/spec/classes/database_postgresql_spec.rb +++ b/spec/classes/database_postgresql_spec.rb @@ -47,6 +47,7 @@ it { is_expected.to contain_exec('zabbix_server_images.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f images.sql.gz ]; then gunzip -f images.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f images.sql && touch /etc/zabbix/.images.done") } it { is_expected.to contain_exec('zabbix_server_data.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f data.sql.gz ]; then gunzip -f data.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-server' -d 'zabbix-server' -f data.sql && touch /etc/zabbix/.data.done") } it { is_expected.to contain_file('/root/.pgpass') } + it { is_expected.to contain_class('zabbix::params') } end describe 'when zabbix_type is proxy' do @@ -63,6 +64,7 @@ it { is_expected.to contain_exec('update_pgpass').with_command('echo node01.example.com:5432:zabbix-proxy:zabbix-proxy:zabbix-proxy >> /root/.pgpass') } it { is_expected.to contain_exec('zabbix_proxy_create.sql').with_command("cd /usr/share/doc/zabbix-*-pgsql-2.4*/create && if [ -f schema.sql.gz ]; then gunzip -f schema.sql.gz ; fi && psql -h 'node01.example.com' -U 'zabbix-proxy' -d 'zabbix-proxy' -f schema.sql && touch /etc/zabbix/.schema.done") } + it { is_expected.to contain_class('zabbix::params') } end end end diff --git a/spec/classes/database_spec.rb b/spec/classes/database_spec.rb index b4f617750..825d3b133 100644 --- a/spec/classes/database_spec.rb +++ b/spec/classes/database_spec.rb @@ -52,6 +52,7 @@ it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } + it { is_expected.to contain_class('zabbix::params') } end describe 'database_type is postgresql, zabbix_type is server and is single node setup' do @@ -76,6 +77,7 @@ it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } + it { is_expected.to contain_class('zabbix::params') } end describe 'database_type is postgresql, zabbix_type is proxy' do @@ -92,6 +94,8 @@ it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_database('zabbix-proxy') } it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_user('zabbix-proxy') } it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database').with_address('127.0.0.1/32') } + it { is_expected.to contain_postgresql__server__db('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::params') } end describe 'database_type is mysql, zabbix_type is server and is multiple host setup' do @@ -114,6 +118,7 @@ it { is_expected.to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } it { is_expected.to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } it { is_expected.to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } + it { is_expected.to contain_class('zabbix::params') } end describe 'database_type is mysql, zabbix_type is server and is a single host setup' do @@ -136,6 +141,7 @@ it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } + it { is_expected.to contain_class('zabbix::params') } end describe 'database_type is mysql, zabbix_type is proxy and is a single host setup' do @@ -150,6 +156,7 @@ end it { is_expected.to contain_mysql__db('zabbix-proxy').with_name('zabbix-proxy') } + it { is_expected.to contain_class('zabbix::params') } end describe 'database_type is sqlite, zabbix_type is proxy and is a multiple host setup' do @@ -165,6 +172,7 @@ end it { is_expected.to contain_class('zabbix::database::sqlite') } + it { is_expected.to contain_class('zabbix::params') } end end end diff --git a/spec/classes/javagateway_spec.rb b/spec/classes/javagateway_spec.rb index 129fe0216..8f1f21208 100644 --- a/spec/classes/javagateway_spec.rb +++ b/spec/classes/javagateway_spec.rb @@ -29,7 +29,9 @@ it { is_expected.to contain_file('/etc/zabbix/zabbix_java_gateway.conf') } it { is_expected.to contain_service('zabbix-java-gateway') } it { is_expected.to contain_package('zabbix-java-gateway') } - + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('zabbix::javagateway') } + it { is_expected.to contain_class('zabbix::params') } context 'when declaring manage_repo is true' do let :params do { @@ -38,6 +40,8 @@ end it { is_expected.to contain_class('Zabbix::Repo') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported') } + it { is_expected.to contain_yumrepo('zabbix') } end context 'when declaring manage_firewall is true' do diff --git a/spec/classes/proxy_spec.rb b/spec/classes/proxy_spec.rb index caa2bfa69..3ef658b72 100644 --- a/spec/classes/proxy_spec.rb +++ b/spec/classes/proxy_spec.rb @@ -40,6 +40,12 @@ it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_ensure('directory') } it { is_expected.to contain_file('/etc/zabbix/zabbix_proxy.conf.d').with_require('File[/etc/zabbix/zabbix_proxy.conf]') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_class('zabbix::params') } + it { is_expected.to contain_exec('update_pgpass') } + it { is_expected.to contain_exec('zabbix_proxy_create.sql') } + it { is_expected.to contain_file('/root/.pgpass') } + it { is_expected.to contain_postgresql__server__pg_hba_rule('Allow zabbix-proxy to access database') } describe 'when manage_repo is true and zabbix version is unset' do let :params do @@ -50,6 +56,8 @@ it { is_expected.to contain_class('zabbix::repo').with_zabbix_version('3.0') } it { is_expected.to contain_package('zabbix-proxy-pgsql').with_require('Class[Zabbix::Repo]') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported') } + it { is_expected.to contain_yumrepo('zabbix') } end describe 'when manage_repo is true and zabbix version is 2.4' do @@ -109,6 +117,8 @@ end it { is_expected.to contain_class('zabbix::resources::proxy') } + it { is_expected.to contain_zabbix__userparameters('Zabbix_Proxy') } + it { is_expected.to contain_zabbix__resources__userparameters('rspec_Zabbix_Proxy') } end context 'with zabbix::database::postgresql class' do @@ -145,6 +155,7 @@ it { is_expected.to contain_class('zabbix::database::mysql').with_database_user('zabbix-proxy') } it { is_expected.to contain_class('zabbix::database::mysql').with_database_password('zabbix-proxy') } it { is_expected.to contain_class('zabbix::database::mysql').with_database_host('localhost') } + it { is_expected.to contain_mysql__db('zabbix_proxy') } end context 'when manage_database is true' do diff --git a/spec/defines/userparameters_spec.rb b/spec/defines/userparameters_spec.rb index 56e87037f..2e4a17b16 100644 --- a/spec/defines/userparameters_spec.rb +++ b/spec/defines/userparameters_spec.rb @@ -28,5 +28,16 @@ let(:params) { { content: 'UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive' } } it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_ensure('present') } it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d/mysqld.conf').with_content %r{^UserParameter=mysql.ping,mysqladmin -uroot ping | grep -c alive$} } + it { is_expected.to contain_class('zabbix::params') } + it { is_expected.to contain_class('zabbix::repo') } + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_file('/etc/init.d/zabbix-agent') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.conf') } + it { is_expected.to contain_file('/etc/zabbix/zabbix_agentd.d') } + it { is_expected.to contain_package('zabbix-agent') } + it { is_expected.to contain_service('zabbix-agent') } + it { is_expected.to contain_yumrepo('zabbix-nonsupported') } + it { is_expected.to contain_yumrepo('zabbix') } + it { is_expected.to contain_zabbix__startup('zabbix-agent') } end end From cb6da3816fced4faaac94ce32b11b99738606b15 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 28 Oct 2016 16:46:50 +0200 Subject: [PATCH 3/3] rubocop: fix RSpec/NotToNot --- spec/classes/agent_spec.rb | 4 ++-- spec/classes/database_spec.rb | 20 ++++++++++---------- spec/classes/javagateway_spec.rb | 2 +- spec/classes/proxy_spec.rb | 2 +- spec/classes/server_spec.rb | 12 ++++++------ spec/classes/web_spec.rb | 6 +++--- spec/defines/startup_spec.rb | 8 ++++---- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index 429fab57e..088edcea9 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -133,7 +133,7 @@ } end - it { is_expected.to_not contain_firewall('150 zabbix-agent') } + it { is_expected.not_to contain_firewall('150 zabbix-agent') } end context 'it creates a startup script' do @@ -143,7 +143,7 @@ it { is_expected.to contain_file('/etc/systemd/system/zabbix-agent.service').with_ensure('file') } else it { is_expected.to contain_file('/etc/init.d/zabbix-agent').with_ensure('file') } - it { is_expected.to_not contain_file('/etc/systemd/system/zabbix-agent.service') } + it { is_expected.not_to contain_file('/etc/systemd/system/zabbix-agent.service') } end end context 'configuration file with full options' do diff --git a/spec/classes/database_spec.rb b/spec/classes/database_spec.rb index 825d3b133..9983080cf 100644 --- a/spec/classes/database_spec.rb +++ b/spec/classes/database_spec.rb @@ -70,13 +70,13 @@ it { is_expected.to contain_postgresql__server__db('zabbix-server').with_name('zabbix-server') } it { is_expected.to contain_postgresql__server__db('zabbix-server').with_user('zabbix-server') } - it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_database('zabbix-server') } - it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_user('zabbix-server') } - it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_address('127.0.0.1/32') } + it { is_expected.not_to contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_database('zabbix-server') } + it { is_expected.not_to contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_user('zabbix-server') } + it { is_expected.not_to contain_postgresql__server__pg_hba_rule('Allow zabbix-server to access database').with_address('127.0.0.1/32') } - it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } - it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } - it { is_expected.to_not contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } + it { is_expected.not_to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_database('zabbix-server') } + it { is_expected.not_to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_user('zabbix-server') } + it { is_expected.not_to contain_postgresql__server__pg_hba_rule('Allow zabbix-web to access database').with_address('127.0.0.2/32') } it { is_expected.to contain_class('zabbix::params') } end @@ -137,10 +137,10 @@ it { is_expected.to contain_mysql__db('zabbix-server').with_user('zabbix-server') } it { is_expected.to contain_mysql__db('zabbix-server').with_host('node0.example.com') } - it { is_expected.to_not contain_mysql_user('zabbix-server@node1.example.com').with_name('zabbix-server@node1.example.com') } - it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } - it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } - it { is_expected.to_not contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } + it { is_expected.not_to contain_mysql_user('zabbix-server@node1.example.com').with_name('zabbix-server@node1.example.com') } + it { is_expected.not_to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_name('zabbix-server@node1.example.com/zabbix-server.*') } + it { is_expected.not_to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_table('zabbix-server.*') } + it { is_expected.not_to contain_mysql_grant('zabbix-server@node1.example.com/zabbix-server.*').with_user('zabbix-server@node1.example.com') } it { is_expected.to contain_class('zabbix::params') } end diff --git a/spec/classes/javagateway_spec.rb b/spec/classes/javagateway_spec.rb index 8f1f21208..25f3d3666 100644 --- a/spec/classes/javagateway_spec.rb +++ b/spec/classes/javagateway_spec.rb @@ -61,7 +61,7 @@ } end - it { is_expected.to_not contain_firewall('152 zabbix-javagateway') } + it { is_expected.not_to contain_firewall('152 zabbix-javagateway') } end context 'with zabbix_java_gateway.conf settings' do diff --git a/spec/classes/proxy_spec.rb b/spec/classes/proxy_spec.rb index 3ef658b72..d531dfc6c 100644 --- a/spec/classes/proxy_spec.rb +++ b/spec/classes/proxy_spec.rb @@ -192,7 +192,7 @@ } end - it { is_expected.to_not contain_firewall('151 zabbix-proxy') } + it { is_expected.not_to contain_firewall('151 zabbix-proxy') } end # Make sure we have set some vars in zabbix_proxy.conf file. This is configuration file is the same on all diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index f3dfeb967..b3d41d029 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -26,7 +26,7 @@ describe 'with default settings' do it { is_expected.to contain_class('zabbix::repo') } it { is_expected.to contain_service('zabbix-server').with_ensure('running') } - it { is_expected.to_not contain_selboolean('zabbix_can_network') } + it { is_expected.not_to contain_selboolean('zabbix_can_network') } it { is_expected.to contain_zabbix__startup('zabbix-server') } end @@ -124,7 +124,7 @@ } end - it { is_expected.to_not contain_firewall('151 zabbix-server') } + it { is_expected.not_to contain_firewall('151 zabbix-server') } end # If manage_service is true (default), it should create a service @@ -147,7 +147,7 @@ } end - it { is_expected.to_not contain_service('zabbix-server') } + it { is_expected.not_to contain_service('zabbix-server') } end context 'with all zabbix_server.conf-related parameters' do @@ -291,9 +291,9 @@ } end - it { is_expected.to_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeID=0$} } - it { is_expected.to_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoEvents=0} } - it { is_expected.to_not contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoHistory=0} } + it { is_expected.not_to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeID=0$} } + it { is_expected.not_to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoEvents=0} } + it { is_expected.not_to contain_file('/etc/zabbix/zabbix_server.conf').with_content %r{^NodeNoHistory=0} } end context 'with zabbix_server.conf and version 3.0' do diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index 94cbf7796..f4f9c3388 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -37,7 +37,7 @@ def package_provider_for_gems if facts[:osfamily] == 'RedHat' it { is_expected.to contain_selboolean('httpd_can_connect_zabbix').with('value' => 'on', 'persistent' => true) } else - it { is_expected.to_not contain_selboolean('httpd_can_connect_zabbix') } + it { is_expected.not_to contain_selboolean('httpd_can_connect_zabbix') } end end @@ -46,7 +46,7 @@ def package_provider_for_gems let :facts do super().merge(selinux_config_mode: mode) end - it { is_expected.to_not contain_selboolean('httpd_can_connect_zabbix') } + it { is_expected.not_to contain_selboolean('httpd_can_connect_zabbix') } end end @@ -143,7 +143,7 @@ def package_provider_for_gems super().merge(manage_resources: false) end - it { is_expected.to_not contain_class('zabbix::resources::web') } + it { is_expected.not_to contain_class('zabbix::resources::web') } end it { is_expected.to contain_apache__vhost('zabbix.example.com').with_name('zabbix.example.com') } diff --git a/spec/defines/startup_spec.rb b/spec/defines/startup_spec.rb index 959a09e06..28f11ac46 100644 --- a/spec/defines/startup_spec.rb +++ b/spec/defines/startup_spec.rb @@ -38,8 +38,8 @@ it { is_expected.to raise_error(Puppet::Error, %r{We currently only support Debian and RedHat osfamily as non-systemd}) } next end - it { is_expected.to_not contain_class('systemd') } - it { is_expected.to_not contain_file('/etc/systemd/system/zabbix-agent.service') } + it { is_expected.not_to contain_class('systemd') } + it { is_expected.not_to contain_file('/etc/systemd/system/zabbix-agent.service') } end context 'it fails when agent_configfile_path param is missing' do @@ -129,8 +129,8 @@ it { is_expected.to raise_error(Puppet::Error, %r{We currently only support Debian and RedHat osfamily as non-systemd}) } next end - it { is_expected.to_not contain_class('systemd') } - it { is_expected.to_not contain_file('/etc/systemd/system/zabbix-server.service') } + it { is_expected.not_to contain_class('systemd') } + it { is_expected.not_to contain_file('/etc/systemd/system/zabbix-server.service') } end context 'it fails when server_configfile_path param is missing' do