Skip to content

Commit

Permalink
Merge pull request #337 from johnbellone/integration-docker
Browse files Browse the repository at this point in the history
Add travis and docker integration tests.
  • Loading branch information
johnbellone authored Aug 23, 2016
2 parents 2d4f295 + d67ee7a commit 9ed4022
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 48 deletions.
8 changes: 0 additions & 8 deletions .gitattributes

This file was deleted.

67 changes: 60 additions & 7 deletions .kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,86 @@ transport:
provisioner:
name: dokken

verifier:
root_path: /opt/verifier

platforms:
- name: centos-7
named_run_list: rhel
named_run_list: centos
driver:
image: centos:7
platform: rhel
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN yum clean all
- RUN yum -y install net-tools lsof
- RUN yum -y install lsof which systemd-sysv initscripts sudo
attributes:
poise-service:
consul:
provider: systemd
- name: centos-6
named_run_list: rhel
named_run_list: centos
driver:
image: centos:6
platform: rhel
pid_one_command: /sbin/init
intermediate_instructions:
- RUN yum -y install which initscripts
- RUN yum -y install which initscripts sudo
- name: ubuntu-16.04
named_run_list: debian
driver:
image: ubuntu:16.04
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update -y
- RUN /usr/bin/apt-get install sudo net-tools -y
attributes:
poise-service:
consul:
provider: systemd
- name: ubuntu-14.04
named_run_list: debian
driver:
image: ubuntu-upstart:14.04
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update -y
- RUN /usr/bin/apt-get install sudo net-tools -y
attributes:
poise-service:
consul:
provider: upstart
- name: ubuntu-12.04
named_run_list: debian
driver:
image: ubuntu-upstart:12.04
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update -y
- RUN /usr/bin/apt-get install sudo net-tools -y
attributes:
poise-service:
consul:
provider: upstart
- name: debian-8
named_run_list: debian
driver:
image: debian:8
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install apt-transport-https net-tools -y

- RUN /usr/bin/apt-get install lsb-release sudo net-tools -y
attributes:
poise-service:
consul:
provider: systemd
- name: debian-7
named_run_list: debian
driver:
image: debian:7
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update
- RUN /usr/bin/apt-get install lsb-release sudo net-tools -y
suites:
- name: default
provisioner:
Expand Down
6 changes: 3 additions & 3 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ platforms:
- name: ubuntu-12.04
named_run_list: debian
- name: centos-7.2
named_run_list: rhel
named_run_list: centos
- name: centos-6.7
named_run_list: rhel
named_run_list: centos
- name: centos-5.11
named_run_list: rhel
named_run_list: centos
- name: debian-8.2
named_run_list: debian
- name: debian-7.9
Expand Down
3 changes: 1 addition & 2 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--color
--default-path test/spec
--default-path test/spec --color
6 changes: 4 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
AllCops:
Exclude:
- 'Guardfile'
- 'Rakefile'
- 'Vagrantfile'
- 'Policyfile.rb'
- 'Berksfile'
- 'Thorfile'
- 'Gemfile'
- 'metadata.rb'
- 'test/**/*'
Expand Down Expand Up @@ -44,3 +42,7 @@ Style/PercentLiteralDelimiters:
Enabled: false
Style/ModuleFunction:
Enabled: false
Style/AlignHash:
Enabled: false
Style/SpaceInsideHashLiteralBraces:
Enabled: false
53 changes: 43 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
---
language: ruby
sudo: required
dist: trusty
language: generic
cache: bundler
sudo: false
addons:
apt:
sources:
- chef-current-trusty
packages:
- chefdk
services: docker
env:
matrix:
- INSTANCE=default-centos-7
- INSTANCE=default-centos-6
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-ubuntu-1404
- INSTANCE=default-ubuntu-1204
- INSTANCE=default-debian-8
- INSTANCE=default-debian-7
before_script:
# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142230889
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
- /opt/chefdk/embedded/bin/chef gem install kitchen-dokken
- /opt/chefdk/embedded/bin/chef gem install kitchen-verifier-serverspec
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/cookstyle --version
- /opt/chefdk/embedded/bin/foodcritic --version
script: KITCHEN_LOCAL_YAML=.kitchen.dokken.yml kitchen verify ${INSTANCE}
after_script:
- docker images
- docker ps -a
- cat .kitchen/logs/kitchen.log
matrix:
include:
- script: /opt/chefdk/embedded/bin/cookstyle
env: COOKSTYLE=1
- script: /opt/chefdk/embedded/bin/foodcritic . --exclude spec -f any
env: FOODCRITIC=1
- script:
- bundle install
- /opt/chefdk/embedded/bin/rspec --color --default-path test/spec
env: CHEFSPEC=1
notifications:
slack: bloomberg-rnd:BvYmxrV9xj902XWTRNrkLNkR
script: bundle exec rake travis
rvm:
- 2.2
branches:
only:
- master
matrix:
fast_finish: true
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ end
group :unit, :integration do
gem 'chef-dk'
gem 'chefspec'
gem 'rubyzip'
gem 'serverspec'
end

Expand Down
2 changes: 1 addition & 1 deletion libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#

module ConsulCookbook
module Helpers # rubocop:disable Metrics/ModuleLength
module Helpers
include Chef::Mixin::ShellOut

extend self
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
depends 'golang'
depends 'firewall', '~> 2.0'
depends 'poise', '~> 2.2'
depends 'poise-service', '~> 1.0'
depends 'poise-service', '~> 1.4'
depends 'rubyzip', '~> 1.3'
depends 'yum-epel'

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/policies/_base.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
default_source :community
default_source :chef_repo, '..'
cookbook 'consul', path: '../../..'
run_list 'consul::default', "consul_spec::#{name}"
named_run_list :rhel, 'yum::default', run_list
run_list 'sudo::default', 'consul::default', "consul_spec::#{name}"
named_run_list :centos, 'yum::default', 'yum-centos::default', run_list
named_run_list :debian, 'apt::default', run_list
named_run_list :freebsd, 'freebsd::default', run_list
named_run_list :windows, 'windows::default', run_list
12 changes: 0 additions & 12 deletions test/integration/default/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@
it { should be_mode 750 }
end

if os[:family] == 'ubuntu'
describe file('/etc/init/consul.conf' ) do
its(:content) do
should include(<<-EOT)
post-start script
while ! #{consul_executable} info ; sleep 1; done
end script
EOT
end
end
end

describe file("#{confd_dir}/consul_definition_check.json") do
it { should be_file }
it { should be_owned_by 'root' }
Expand Down
2 changes: 2 additions & 0 deletions test/spec/libraries/consul_installation_webui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
let(:chefspec_options) { {platform: 'ubuntu', version: '14.04'} }

context 'webui installation' do
pending('replace with poise-archive')

recipe do
consul_installation '0.6.4' do
provider :webui
Expand Down

0 comments on commit 9ed4022

Please sign in to comment.