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

Update testing #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .delivery/project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
remote_file = "https://raw.githubusercontent.com/chef-cookbooks/community_cookbook_tools/master/delivery/project.toml"
65 changes: 65 additions & 0 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
driver:
name: dokken
chef_version: latest

transport:
name: dokken

provisioner:
name: dokken
always_update_cookbooks: true

platforms:
- name: debian-8
driver:
image: dokken/debian-8
privileged: true
pid_one_command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd
- name: debian-9
driver:
image: dokken/debian-9
privileged: true
pid_one_command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd
- name: ubuntu-14
driver:
image: dokken/ubuntu-14.04
privileged: true
- name: ubuntu-16
driver:
image: dokken/ubuntu-16.04
privileged: true
pid_one_command: /lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd
- name: centos-6
driver:
image: dokken/centos-6
privileged: true
- name: centos-7
driver:
image: dokken/centos-7
privileged: true
pid_one_command: /usr/lib/systemd/systemd
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro # required by systemd

verifier:
name: inspec

suites:
- name: default
run_list:
- recipe[collectd::default]
- name: userchange
run_list:
- recipe[collectd::default]
- recipe[collectd-test::_test_plugin]
attributes:
collectd:
service_user: 'root'
service_group: 'root'
17 changes: 5 additions & 12 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,16 @@ provisioner:
name: chef_zero

platforms:
- name: ubuntu-14.04
run_list:
- recipe[apt::default]
- name: ubuntu-12.04
- name: ubuntu-16.04
run_list:
- recipe[apt::default]
- name: ubuntu-10.04
- name: ubuntu-14.04
run_list:
- recipe[apt::default]
- name: centos-7.2
- name: centos-7.5
run_list:
- recipe[yum-epel::default]
- name: centos-6.7
run_list:
- recipe[yum-epel::default]
- name: centos-5.11
- name: centos-6.8
run_list:
- recipe[yum-epel::default]

Expand All @@ -32,9 +26,8 @@ suites:
- name: userchange
run_list:
- recipe[collectd::default]
- recipe[collectd::_test_plugin]
- recipe[collectd-test::_test_plugin]
attributes:
collectd:
service_user: 'root'
service_group: 'root'

32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0-1
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-json
- id: check-vcs-permalinks
- id: mixed-line-ending
- id: pretty-format-json
args:
- --autofix
- --top-keys=id
- id: sort-simple-yaml
files: '.yaml$'
- id: check-symlinks
- id: check-yaml
- id: detect-private-key
- repo: git://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.6
hooks:
- id: remove-crlf
- id: remove-tabs
- repo: git://github.com/EMSL-MSC/pre-commit-hooks-chef
rev: 8e9ad15ee7430c7a52d5527d6b9cc5d0a158c974
hooks:
- id: check-cookstyle
- id: check-foodcritic
#- id: check-rspec
2 changes: 0 additions & 2 deletions .rspec

This file was deleted.

44 changes: 0 additions & 44 deletions .rubocop.yml

This file was deleted.

63 changes: 50 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
---
language: ruby
cache: bundler
sudo: false
notifications:
slack: bloomberg-rnd:BvYmxrV9xj902XWTRNrkLNkR
script: bundle exec rake travis
rvm:
- 2.2
branches:
only:
- master
matrix:
fast_finish: true
dist: trusty
sudo: required
group: edge
services: docker
addons:
apt:
sources:
- chef-stable-trusty
packages:
- chefdk

stages:
- lint
- test

install: "chef exec bundle install --with deps"

before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- chef --version

env:
- T=server-debian-8
- T=server-debian-9
- T=server-ubuntu-14
- T=server-ubuntu-16
- T=server-centos-6
- T=server-centos-7

script:
- chef gem install kitchen-dokken
- KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen test $T -d always

jobs:
include:
- stage: lint
env:
services:
sudo:
language: python
python: 3.6
script:
- cookstyle --version
- foodcritic --version
- rspec --version
- delivery --version
- pip install pre-commit
- pre-commit run -a
- chef exec delivery local all
2 changes: 1 addition & 1 deletion Berksfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source 'https://supermarket.chef.io'
metadata

solver :ruby, :required
group :test, :integration do
cookbook 'apt'
cookbook 'yum-epel'
Expand Down
10 changes: 7 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
source 'https://rubygems.org'
gem 'poise', '~> 2.2'
gem 'poise-service', '~> 1.0'
gem 'poise-boiler'

group :deps do
gem 'poise', '~> 2.8'
gem 'poise-service', '~> 1.5'
gem 'poise-boiler', '~> 1.18'
end

group :lint do
gem 'rubocop'
Expand All @@ -12,6 +15,7 @@ group :unit, :integration do
gem 'berkshelf'
gem 'chefspec'
gem 'serverspec'
gem 'inspec'
end

group :development do
Expand Down
2 changes: 1 addition & 1 deletion libraries/collectd_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def write_elements(directives, indent = 0)
next if id.nil?
[%(#{tabs}<#{key} "#{id}">),
write_elements(value, indent.next),
%(#{tabs}</#{key}>)
%(#{tabs}</#{key}>),
].join("\n")
elsif value.is_a?(String)
%(#{tabs}#{key} "#{value}")
Expand Down
2 changes: 1 addition & 1 deletion libraries/collectd_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def config_filename
configuration(
'load_plugin' => new_resource.plugin_name,
'plugin' => {
'id' => new_resource.plugin_name
'id' => new_resource.plugin_name,
}.merge(new_resource.options)
)
end
Expand Down
39 changes: 31 additions & 8 deletions libraries/collectd_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,46 @@ def action_enable
# TODO: (jbellone) Fix the package resource for AIX so that
# it is able to install from a URL.
package_path = if new_resource.package_source
url = new_resource.package_source % { version: new_resource.package_version }
url = format(new_resource.package_source, version: new_resource.package_version)
basename = ::File.basename(url)
remote_file ::File.join(Chef::Config[:file_cache_path], basename) do
source url
backup false
end.path
end

package new_resource.package_name do
provider Chef::Provider::Package::Solaris if platform?('solaris2')
provider Chef::Provider::Package::Dpkg if platform?('ubuntu') && new_resource.package_source
action :upgrade
version new_resource.package_version
source package_path
notifies :restart, new_resource, :delayed
if platform?('solaris2')
solaris_package new_resource.package_name do
action :upgrade
version new_resource.package_version
source package_path
notifies :restart, new_resource, :delayed
end
elsif platform_family?('debian')
dpkg_package new_resource.package_name do
action :upgrade
version new_resource.package_version
source package_path
notifies :restart, new_resource, :delayed
end
elsif platform_family?('rhel')
yum_package new_resource.package_name do
action :upgrade
version new_resource.package_version
source package_path
notifies :restart, new_resource, :delayed
end
end

# package_provider new_resource.package_name do
# # provider Chef::Provider::Package::Solaris if platform?('solaris2')
# # provider Chef::Provider::Package::Dpkg if platform?('ubuntu') && new_resource.package_source
# action :upgrade
# version new_resource.package_version
# source package_path
# notifies :restart, new_resource, :delayed
# end

# Installing package starts collectd service automatically
# Disable this so that collectd can be managed through poise-service
service new_resource.package_name do
Expand Down
21 changes: 12 additions & 9 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
name 'collectd'
maintainer 'John Bellone'
maintainer_email '[email protected]'
license 'Apache 2.0'
license 'Apache-2.0'
description 'Installs and configures the collectd monitoring daemon.'
long_description 'Installs and configures the collectd monitoring daemon.'
version '2.2.4'
version '2.2.5'
source_url 'https://github.com/bloomberg/collectd-cookbook'
issues_url 'https://github.com/bloomberg/collectd-cookbook/issues'

supports 'ubuntu', '>= 10.04'
supports 'centos', '>= 5.8'
supports 'redhat', '>= 5.8'
supports 'aix'
supports 'solaris2'
chef_version '~> 14'

depends 'poise', '~> 2.2'
depends 'poise-service', '~> 1.0'
supports 'ubuntu', '>= 14.04'
# supports 'debian', '>= 8.0'
supports 'centos', '>= 6.8'
# supports 'redhat', '>= 6.0' # need to add actual rhel to testing infra
# supports 'aix' # need to add actual testing for aix
# supports 'solaris2' # need to add actual testing for solaris2

depends 'poise', '~> 2.8'
depends 'poise-service', '~> 1.5'
Loading