Skip to content

Commit

Permalink
Merge pull request #18 from TD-4242/build_testing
Browse files Browse the repository at this point in the history
port from old chefspec to new inspec integration tests
  • Loading branch information
TD-4242 authored Apr 25, 2017
2 parents e6ed825 + db6bd2e commit 72b885d
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _yardoc
/doc/
/pkg
/spec/reports
/Berksfile*
Berksfile.lock
tmp
*~
*.tar*
Expand Down
50 changes: 30 additions & 20 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
---
driver:
name: 'vagrant'
name: 'docker'
disable_upstart: false
image: ubuntu-upstart:14.04
run_command: /sbin/init

driver_config:
provision_command:
- curl -L https://www.opscode.com/chef/install.sh | bash -s -- -v 12.19.36
require_chef_omnibus: true

platforms:
- name: ubuntu-10.04
- name: ubuntu-12.04
#- name: ubuntu-10.04
#- name: ubuntu-12.04
- name: ubuntu-14.04
- name: centos-6.7
#- name: centos-6.7
#- name: centos-7.2 # needs systemd support?
- name: debian-6.0.10
- name: debian-7.8
#- name: debian-6.0.10
#- name: debian-7.8
# planned for future tested support
#- name: freebsd-9.3
#- name: freebsd-10.1
#- name: fedora-20
#- name: fedora-21
#- name: opensuse-13.1
- name: windows-2012r2
driver_config:
communicator: winrm
box_url: https://wrock.blob.core.windows.net/vhds/vbox2012r2.box
customize:
usbehci: "off"
#- name: windows-2012r2
# driver_config:
# communicator: winrm
# box_url: https://wrock.blob.core.windows.net/vhds/vbox2012r2.box
# customize:
# usbehci: "off"

verifier:
name: inspec
format: documentation

provisioner:
name: chef_zero
Expand All @@ -35,14 +44,14 @@ suites:
run_list:
- "recipe[zabbix-agent]"
attributes:
- name: default_win
includes: windows-2012r2
run_list:
- "recipe[zabbix-agent]"
attributes:
zabbix:
agent:
user: vagrant
#- name: default_win
# includes: windows-2012r2
# run_list:
# - "recipe[zabbix-agent]"
# attributes:
# zabbix:
# agent:
# user: vagrant
- name: source
excludes: windows-2012r2
run_list:
Expand All @@ -59,3 +68,4 @@ suites:
zabbix:
agent:
install_method: "prebuild"
version: "3.0.4"
17 changes: 3 additions & 14 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,8 @@ AllCops:
Exclude:
- vendor/**/*

ClassLength:
Enabled: false
Documentation:
Enabled: false
Encoding:
Enabled: false
HashSyntax:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Enabled: false
SignalException:
Enabled: false
WordArray:
Enabled: false

Metrics/BlockLength:
Max: 200
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ addons:
packages:
- chefdk

install: echo "skip bundle install"

services: docker

before_script:
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- chef gem install kitchen-docker

script:
- ls
- pwd
- chef exec rake travis
- chef exec rake
17 changes: 0 additions & 17 deletions Gemfile

This file was deleted.

4 changes: 2 additions & 2 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'
scope :group => :unit
scope group: :unit

group :unit do
guard :rubocop do
watch(%r{/.+\.rb$/})
watch(%r{/(?:.+\/)?\.rubocop\.yml$/}) { |m| File.dirname(m[0]) }
end

guard :rspec, :cmd => 'chef exec rspec --fail-fast', :all_on_start => false do
guard :rspec, cmd: 'chef exec rspec --fail-fast', all_on_start: false do
watch(%r{/^libraries\/(.+)\.rb$/})
watch(%r{/^spec\/(.+)_spec\.rb$/}) { 'spec' }
watch(%r{/^(attributes)\/(.+)\.rb$/}) { 'spec' }
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Install Method options are:

Version

node['zabbix']['agent']['version'] # Default 2.4.4
node['zabbix']['agent']['version'] # Default 3.0.9

Servers

Expand All @@ -116,7 +116,7 @@ Servers
node['zabbix']['agent']['conf']['ServerActive'] = ["Your_zabbix_active_server.com"]

#### Package install
If you do not set any attributes you will get an install of zabbix agent version 2.4.4 with
If you do not set any attributes you will get an install of zabbix agent version 3.0.9 with
what should be a working configuration if your DNS has aliases for zabbix.yourdomain.com and
your hosts search yourdomain.com.

Expand Down Expand Up @@ -209,6 +209,11 @@ To run the tests, insure you meet the below dependancies, then just run rake in
* Add cookbook_file install method

# CHANGELOG
### 0.14.0
* upgrade to default client version 3.0.9
* move kitchen to docker so it can be run in travisci

### 0.13.0
### 0.12.0
* include kitchen tests for all supported OS types
* upgrade to default client version 2.4.4
Expand Down
32 changes: 0 additions & 32 deletions Vagrantfile

This file was deleted.

12 changes: 7 additions & 5 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
default['zabbix']['agent']['include_dir'] = ::File.join(node['zabbix']['etc_dir'], 'zabbix_agentd.d')
default['zabbix']['agent']['config_file'] = ::File.join(node['zabbix']['etc_dir'], 'zabbix_agentd.conf')
default['zabbix']['agent']['userparams_config_file'] = ::File.join(node['zabbix']['agent']['include_dir'], 'user_params.conf')
default['zabbix']['agent']['pid_file'] = '/var/run/zabbix/zabbix_agentd.pid'

if node['platform'] == 'windows'
default['zabbix']['install_dir'] = node['zabbix']['etc_dir']
Expand All @@ -25,7 +26,7 @@
default['zabbix']['agent']['scripts'] = '/etc/zabbix/scripts'
end

default['zabbix']['agent']['version'] = '2.4.6'
default['zabbix']['agent']['version'] = '3.0.9'
default['zabbix']['agent']['servers'] = ['zabbix']
default['zabbix']['agent']['servers_active'] = ['zabbix']

Expand Down Expand Up @@ -69,6 +70,7 @@
unless node['platform'] == 'windows'
default['zabbix']['agent']['conf']['LoadModule'] = nil
end
default['zabbix']['agent']['conf']['LogType'] = 'system'
default['zabbix']['agent']['conf']['LogFile'] = nil
default['zabbix']['agent']['conf']['LogFileSize'] = '1'
default['zabbix']['agent']['conf']['LogRemoteCommands'] = '0'
Expand Down Expand Up @@ -108,17 +110,17 @@
# package install
case node['platform']
when 'ubuntu', 'debian'
default['zabbix']['agent']['package']['repo_uri'] = "http://repo.zabbix.com/zabbix/2.4/#{node['platform']}/"
default['zabbix']['agent']['package']['repo_uri'] = "http://repo.zabbix.com/zabbix/3.0/#{node['platform']}/"
default['zabbix']['agent']['package']['repo_key'] = 'http://repo.zabbix.com/zabbix-official-repo.key'
when 'redhat', 'centos', 'scientific', 'oracle'
default['zabbix']['agent']['package']['repo_uri'] = 'http://repo.zabbix.com/zabbix/2.4/rhel/$releasever/$basearch/'
default['zabbix']['agent']['package']['repo_uri'] = 'http://repo.zabbix.com/zabbix/3.0/rhel/$releasever/$basearch/'
default['zabbix']['agent']['package']['repo_key'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
when 'amazon'
# current Amazon AMI based on RHEL6 at the moment
default['zabbix']['agent']['package']['repo_uri'] = 'http://repo.zabbix.com/zabbix/2.4/rhel/6/$basearch/'
default['zabbix']['agent']['package']['repo_uri'] = 'http://repo.zabbix.com/zabbix/3.0/rhel/6/$basearch/'
default['zabbix']['agent']['package']['repo_key'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
when 'fedora'
default['zabbix']['agent']['package']['repo_uri'] = 'http://repo.zabbix.com/zabbix/2.4/rhel/7/$basearch/'
default['zabbix']['agent']['package']['repo_uri'] = 'http://repo.zabbix.com/zabbix/3.0/rhel/7/$basearch/'
default['zabbix']['agent']['package']['repo_key'] = 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX'
end

Expand Down
4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
source_url 'https://github.com/TD-4242/zabbix-agent'
issues_url 'https://github.com/TD-4242/zabbix-agent/issues'
version '0.13.3'
version '0.14.0'

# tested on ubuntu 10.04 12.04 and 14.04
supports 'ubuntu', '>= 10.04'
Expand All @@ -20,4 +20,4 @@
depends 'yum' # For Redhat family OSs
depends 'build-essential' # for source build/install
depends 'chocolatey' # For Windows family OSs
recommends 'libzabbix' # LWRPs to connect to zabbix server
# recommends 'libzabbix' # LWRPs to connect to zabbix server
4 changes: 2 additions & 2 deletions recipes/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
supports status: true, start: true, stop: true, restart: true
action [:enable, :start]
end
when 'upstart'
# upstart.conf
# when 'upstart'
# upstart.conf
when 'windows'
service 'zabbix-agent' do
service_name 'Zabbix Agent'
Expand Down
10 changes: 6 additions & 4 deletions spec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

describe 'zabbix-agent::default' do
context 'with default settings' do
cached(:chef_run) { ChefSpec::ServerRunner.converge(described_recipe) }
cached(:chef_run) do
ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04').converge(described_recipe)
end

it 'includes zabbix-agent::service to insure the zabbix agent will run' do
expect(chef_run).to include_recipe('zabbix-agent::service')
Expand Down Expand Up @@ -118,7 +120,7 @@

it 'adds the apt repository for zabbix' do
expect(chef_run).to add_apt_repository('zabbix').with(
uri: 'http://repo.zabbix.com/zabbix/2.4/ubuntu/',
uri: 'http://repo.zabbix.com/zabbix/3.0/ubuntu/',
components: ['main'],
key: 'http://repo.zabbix.com/zabbix-official-repo.key'
)
Expand All @@ -140,7 +142,7 @@
expect(chef_run).to create_yum_repository('zabbix').with(
repositoryid: 'zabbix',
description: 'Zabbix Official Repository',
baseurl: 'http://repo.zabbix.com/zabbix/2.4/rhel/$releasever/$basearch/',
baseurl: 'http://repo.zabbix.com/zabbix/3.0/rhel/$releasever/$basearch/',
gpgkey: 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX',
sslverify: false
)
Expand All @@ -150,7 +152,7 @@
expect(chef_run).to create_yum_repository('zabbix-non-supported').with(
repositoryid: 'zabbix-non-supported',
description: 'Zabbix Official Repository non-supported - $basearch',
baseurl: 'http://repo.zabbix.com/zabbix/2.4/rhel/$releasever/$basearch/',
baseurl: 'http://repo.zabbix.com/zabbix/3.0/rhel/$releasever/$basearch/',
gpgkey: 'http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX',
sslverify: false
)
Expand Down
26 changes: 13 additions & 13 deletions spec/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'zabbix-agent install method tests' do
context 'with install_method=prebuild it' do
cached(:chef_prebuild) do
ChefSpec::ServerRunner.new do |node|
ChefSpec::ServerRunner.new(platform: 'ubuntu', version: '14.04') do |node|
node.override['zabbix']['agent']['install_method'] = 'prebuild'
node.override['zabbix']['agent']['init_style'] = 'sysvinit'
end.converge('zabbix-agent::default')
Expand All @@ -13,14 +13,14 @@
expect(chef_prebuild).to include_recipe('zabbix-agent::install_prebuild')
end

it "gets the zabbix binary prebuild archive from 'http://www.zabbix.com/downloads/ and puts it #{Chef::Config[:file_cache_path]}/zabbix_agents_2.4.6.linux2_6.i386.tar.gz" do
expect(chef_prebuild).to create_remote_file("#{Chef::Config[:file_cache_path]}/zabbix_agents_2.4.6.linux2_6.i386.tar.gz").with(
source: 'http://www.zabbix.com/downloads/2.4.6/zabbix_agents_2.4.6.linux2_6.i386.tar.gz'
it "gets the zabbix binary prebuild archive from 'http://www.zabbix.com/downloads/ and puts it #{Chef::Config[:file_cache_path]}/zabbix_agents_3.0.9.linux2_6.amd64.tar.gz" do
expect(chef_prebuild).to create_remote_file("#{Chef::Config[:file_cache_path]}/zabbix_agents_3.0.9.linux2_6.amd64.tar.gz").with(
source: 'http://www.zabbix.com/downloads/3.0.9/zabbix_agents_3.0.9.linux2_6.amd64.tar.gz'
)
end

it 'notifies the bash install_program when the archive is downloaded' do
get_file = chef_prebuild.remote_file("#{Chef::Config[:file_cache_path]}/zabbix_agents_2.4.6.linux2_6.i386.tar.gz")
get_file = chef_prebuild.remote_file("#{Chef::Config[:file_cache_path]}/zabbix_agents_3.0.9.linux2_6.amd64.tar.gz")
expect(get_file).to notify('bash[install_program]').to(:run).immediately
end

Expand Down Expand Up @@ -54,14 +54,14 @@
expect(chef_source).to include_recipe('build-essential')
end

it "gets the zabbix source archive from http://downloads.sourceforge.net and puts it in #{Chef::Config[:file_cache_path]}/zabbix-2.4.6.tar.gz" do
expect(chef_source).to create_remote_file("#{Chef::Config[:file_cache_path]}/zabbix-2.4.6.tar.gz").with(
source: 'http://downloads.sourceforge.net/project/zabbix//ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz'
it "gets the zabbix source archive from http://downloads.sourceforge.net and puts it in #{Chef::Config[:file_cache_path]}/zabbix-3.0.9.tar.gz" do
expect(chef_source).to create_remote_file("#{Chef::Config[:file_cache_path]}/zabbix-3.0.9.tar.gz").with(
source: 'http://downloads.sourceforge.net/project/zabbix//ZABBIX%20Latest%20Stable/3.0.9/zabbix-3.0.9.tar.gz'
)
end

it 'the download of the zabbix source archive zabbix-2.4.6.tar.gz notifies the bash install_program' do
get_file = chef_source.remote_file("#{Chef::Config[:file_cache_path]}/zabbix-2.4.6.tar.gz")
it 'the download of the zabbix source archive zabbix-3.0.9.tar.gz notifies the bash install_program' do
get_file = chef_source.remote_file("#{Chef::Config[:file_cache_path]}/zabbix-3.0.9.tar.gz")
expect(get_file).to notify('bash[install_program]').to(:run).immediately
end

Expand Down Expand Up @@ -94,9 +94,9 @@
expect(chef_source).to install_package('redhat-lsb')
end

it "gets the zabbix source archive from http://downloads.sourceforge.net and puts it in #{Chef::Config[:file_cache_path]}/zabbix-2.4.6.tar.gz" do
expect(chef_source).to create_remote_file("#{Chef::Config[:file_cache_path]}/zabbix-2.4.6.tar.gz").with(
source: 'http://downloads.sourceforge.net/project/zabbix//ZABBIX%20Latest%20Stable/2.4.6/zabbix-2.4.6.tar.gz'
it "gets the zabbix source archive from http://downloads.sourceforge.net and puts it in #{Chef::Config[:file_cache_path]}/zabbix-3.0.9.tar.gz" do
expect(chef_source).to create_remote_file("#{Chef::Config[:file_cache_path]}/zabbix-3.0.9.tar.gz").with(
source: 'http://downloads.sourceforge.net/project/zabbix//ZABBIX%20Latest%20Stable/3.0.9/zabbix-3.0.9.tar.gz'
)
end
end
Expand Down
Loading

0 comments on commit 72b885d

Please sign in to comment.