Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Travis CI setup: ensure all rspec tests pass #162

Merged
merged 1 commit into from
Feb 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
language: ruby
sudo: false
cache: bundler

notifications:
email: false
branches:
only:
- master
bundler_args: --without development system_tests
before_install: rm Gemfile.lock || true
rvm:
- 2.0.0

- 1.9.3
- 2.1.0
script: "bundle exec rake test"

env:
matrix:
- PUPPET_GEM_VERSION="~> 2.7.0"
- PUPPET_GEM_VERSION="~> 3.0"
- PUPPET_GEM_VERSION="~> 4.0"

notifications:
email:
on_failure: change
on_success: never
- PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES=yes
- PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES=yes FUTURE_PARSER=yes
- PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES=yes
9 changes: 7 additions & 2 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,17 @@
if ($listenip =~ /^(eth|bond|lxc|eno|tap|tun).*/) {
$int_name = "ipaddress_${listenip}"
$listen_ip = inline_template('<%= scope.lookupvar(int_name) %>')
} elsif is_ip_address($listenip) or $listenip == '*' {
}
elsif is_ip_address($listenip) or $listenip == '*' {
$listen_ip = $listenip
} else {
}
else {
$listen_ip = $::ipaddress
}
}
else {
$listen_ip = $::ipaddress
}

# So if manage_resources is set to true, we can send some data
# to the puppetdb. We will include an class, otherwise when it
Expand Down
20 changes: 11 additions & 9 deletions manifests/database/mysql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,21 @@
$database_host = '',
$database_path = $zabbix::params::database_path,
) {
# Allow to customize the path to the Database Schema,
if ! $database_schema_path {
# Allow to customize the path to the Database Schema,
if ($database_schema_path == false) or ($database_schema_path == '') {
case $::operatingsystem {
'centos','redhat','oraclelinux' : {
$schema_path = "/usr/share/doc/zabbix-*-mysql-${zabbix_version}*/create"
}
default : {
$schema_path = '/usr/share/zabbix-*-mysql'
'CentOS','RedHat','OracleLinux' : {
$schema_path = "/usr/share/doc/zabbix-*-mysql-${zabbix_version}*/create"
}
default : {
$schema_path = '/usr/share/zabbix-*-mysql'
}
}
}else {
$schema_path = $database_schema_path
}
else {
$schema_path = $database_schema_path
}

# Loading the sql files.
case $zabbix_type {
'proxy': {
Expand Down
19 changes: 10 additions & 9 deletions manifests/database/postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@
$database_host = '',
$database_path = $zabbix::params::database_path,
) {
# Allow to customize the path to the Database Schema,
if ! $database_schema_path {
# Allow to customize the path to the Database Schema,
if ($database_schema_path == false) or ($database_schema_path == '') {
case $::operatingsystem {
'centos','redhat','oraclelinux' : {
$schema_path = "/usr/share/doc/zabbix-*-pgsql-${zabbix_version}*/create"
}
default : {
$schema_path = '/usr/share/zabbix-*-pgsql'
'CentOS', 'RedHat', 'OracleLinux': {
$schema_path = "/usr/share/doc/zabbix-*-pgsql-${zabbix_version}*/create"
}
default : {
$schema_path = '/usr/share/zabbix-*-pgsql'
}
}
}else {
$schema_path = $database_schema_path
}
else {
$schema_path = $database_schema_path
}


Expand Down
3 changes: 3 additions & 0 deletions manifests/proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,9 @@
'sqlite': {
$db = 'sqlite3'
}
default: {
fail("Unrecognized database type for proxy: ${database_type}")
}
}

if $manage_database == true {
Expand Down
229 changes: 104 additions & 125 deletions spec/classes/agent_spec.rb
Original file line number Diff line number Diff line change
@@ -1,153 +1,132 @@
require 'spec_helper'

describe 'zabbix::agent' do
let(:node) { 'agent.example.com' }
let(:params) { {:server => '192.168.1.1', :serveractive => '192.168.1.1', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
let (:node) { 'agent.example.com' }
let (:params) do
{
:server => '192.168.1.1',
:serveractive => '192.168.1.1',
:agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf',
}
end

# Running an RedHat OS.
context 'On a RedHat OS' do
let :facts do
context 'On RedHat 6.5' do
let (:facts) do
{
:osfamily => 'RedHat',
:operatingsystem => 'RedHat',
:operatingsystemrelease => '6.5',
:architecture => 'x86_64',
:lsbdistid => 'RedHat',
:concat_basedir => '/tmp'
:concat_basedir => '/tmp',
}
end

# Need the zabbix::repo?
context "when declaring manage_repo is true" do
let(:params) {{ :manage_repo => true }}
it { should contain_class('zabbix::repo').with_zabbix_version('2.4') }
it { should contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]')}
end
# Make sure package will be installed, service running and ensure of directory.
it { should contain_package('zabbix-agent').with_ensure('present') }
it { should contain_package('zabbix-agent').with_name('zabbix-agent') }

it { should contain_service('zabbix-agent').with_ensure('running') }
it { should contain_service('zabbix-agent').with_name('zabbix-agent') }

it { should contain_file('/etc/zabbix/zabbix_agentd.d').with_ensure('directory') }

context "when declaring manage_resources is true" do
let(:params) {{ :manage_resources => true }}
it { should contain_class('zabbix::resources::agent') }
end
context "when declaring manage_repo is true" do
let (:params) do
{
:manage_repo => true,
}
end

# Make sure package will be installed, service running and ensure of directory.
it { should contain_package('zabbix-agent').with_ensure('present') }
it { should contain_package('zabbix-agent').with_name('zabbix-agent') }
it { should contain_class('zabbix::repo').with_zabbix_version('2.4') }
it { should contain_package('zabbix-agent').with_require('Class[Zabbix::Repo]')}
end

context "when declaring manage_resources is true" do
let (:params) do
{
:manage_resources => true,
}
end

it { should contain_class('zabbix::resources::agent') }
end

it { should contain_service('zabbix-agent').with_ensure('running') }
it { should contain_service('zabbix-agent').with_name('zabbix-agent') }
context "configuration file with hostnameitem" do
let (:params) do
{
:hostnameitem => 'system.hostname',
}
end

it { should contain_file('/etc/zabbix/zabbix_agentd.d').with_ensure('directory') }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^HostnameItem=system.hostname$}}
end

# Configuration file
context 'with pidfile => /var/run/zabbix/zabbix_agentd.pid' do
let(:params) { {:pidfile => '/var/run/zabbix/zabbix_agentd.pid', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^PidFile=/var/run/zabbix/zabbix_agentd.pid$}}
end
context "when declaring manage_firewall is true" do
let (:params) do
{
:manage_firewall => true,
}
end

context 'with logfile => /var/run/zabbix/zabbix_agentd.pid' do
let(:params) { {:logfile => '/var/log/zabbix/zabbix_agentd.log', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogFile=/var/log/zabbix/zabbix_agentd.log$}}
end
it { should contain_firewall('150 zabbix-agent') }
end

context "when declaring manage_firewall is false" do
let (:params) do
{
:manage_firewall => false,
}
end

it { should_not contain_firewall('150 zabbix-agent') }
end

context 'with DebugLevel => 4' do
let(:params) { {:debuglevel => '4', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^DebugLevel=4$}}
end
context "configuration file with full options" do
let (:params) do
{
:allowroot => '0',
:agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf',
:buffersend => '5',
:buffersize => '100',
:debuglevel => '4',
:enableremotecommands => '1',
:hostname => '10050',
:include_dir => '/etc/zabbix/zabbix_agentd.d',
:listenport => '10050',
:loadmodulepath => '${libdir}/modules',
:logfilesize => '4',
:logfile => '/var/log/zabbix/zabbix_agentd.log',
:logremotecommands => '0',
:pidfile => '/var/run/zabbix/zabbix_agentd.pid',
:refreshactivechecks => '120',
:server => '192.168.1.1',
:serveractive => '192.168.1.1',
:startagents => '3',
:timeout => '30',
:unsafeuserparameters => '0',
}
end

context 'with logfilesize => 4' do
let(:params) { {:logfilesize => '4', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogFileSize=4$}}
end

context 'with EnableRemoteCommands => 1' do
let(:params) { {:enableremotecommands => '1', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
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$}}
end

context 'with LogRemoteCommands => 0' do
let(:params) { {:logremotecommands => '0', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it { should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LogRemoteCommands=0$}}
end

context 'with server => 192.168.1.1' do
let(:params) { {:server => '192.168.1.1', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Server=192.168.1.1$}}
end

context 'with ListenPort => 10050' do
let(:params) { {:listenport => '10050', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ListenPort=10050$}}
end

context 'with StartAgents => 3' do
let(:params) { {:startagents => '3', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^StartAgents=3$}}
end

context 'with ServerActive => 192.168.1.1' do
let(:params) { {:serveractive => '192.168.1.1', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^ServerActive=192.168.1.1$}}
end

context 'with Hostname => 192.168.1.1' do
let(:params) { {:hostname => '10050', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Hostname=10050$}}
end

context 'with HostnameItem => system.hostname' do
let(:params) { {:hostnameitem => 'system.hostname', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^HostnameItem=system.hostname$}}
end

context 'with RefreshActiveChecks => 120' do
let(:params) { {:refreshactivechecks => '120', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
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$}}
end

context 'with BufferSend => 5' do
let(:params) { {:buffersend => '5', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSend=5$}}
end

context 'with BufferSize => 100' do
let(:params) { {:buffersize => '100', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^BufferSize=100$}}
end

context 'with Timeout => 30' do
let(:params) { {:timeout => '30', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
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$}}
end

context 'with AllowRoot => 0' do
let(:params) { {:allowroot => '0', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^AllowRoot=0$}}
end

context 'with Include => /etc/zabbix/zabbix_agentd.d' do
let(:params) { {:include_dir => '/etc/zabbix/zabbix_agentd.d', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^Include=/etc/zabbix/zabbix_agentd.d$}}
end

context 'with UnsafeUserParameters => 0' do
let(:params) { {:unsafeuserparameters => '0', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^UnsafeUserParameters=0$}}
end

context 'with LoadModulePath => ${libdir}/modules' do
let(:params) { {:loadmodulepath => '${libdir}/modules', :agent_configfile_path => '/etc/zabbix/zabbix_agentd.conf'} }
it {should contain_file('/etc/zabbix/zabbix_agentd.conf').with_content %r{^LoadModulePath=\$\{libdir\}/modules$}}
end

# Firewall
context "when declaring manage_firewall is true" do
let(:params) {{ :manage_firewall => true }}
it { should contain_firewall('150 zabbix-agent') }
end

context "when declaring manage_firewall is false" do
let(:params) {{ :manage_firewall => false }}
it { should_not contain_firewall('150 zabbix-agent') }
end
end
end
end
Loading