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 Kitchen tests to use Docker #126

Open
wants to merge 6 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
56 changes: 48 additions & 8 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,65 @@
---
driver:
name: vagrant
name: docker
use_sudo: false

transport:
name: ssh
max_ssh_sessions: 5

provisioner:
name: ansible_playbook
ansible_verbose: true
ansible_verbosity: 2
require_ruby_for_busser: false
require_chef_for_busser: true
ansible_version: <%= ENV["ANSIBLE_VERSION"] || "latest" %>
require_ruby_for_busser: true
require_chef_for_busser: false
hosts: all
role_name: ansible-redis

busser:
ruby_bindir: /usr/bin

platforms:
- name: ubuntu-14.04
- name: centos-6.7
driver_config:
box: wittman/centos-6.7-ansible
- name: centos-7.2
driver_config:
box: wittman/centos-7.2-ansible
image: williamyeh/ansible:ubuntu14.04

- name: ubuntu-16.04
driver_config: &systemd_driver_config
disable_upstart: no
provision_command:
- &provision_cmd_1
find /lib/systemd/system/sysinit.target.wants -xtype f -printf '%f\n' |
grep -v -E '(journal|machine-id|random-seed|tmpfiles|ldconfig)' |
xargs -d'\n' --no-run-if-empty systemctl mask
- &provision_cmd_2
find /lib/systemd/system -xtype f -printf '%f\n' |
grep -E '(udev|dracut|getty)' |
xargs -d'\n' --no-run-if-empty systemctl mask
- &provision_cmd_3
systemctl mask systemd-remount-fs systemd-timesyncd systemd-networkd
run_command: /sbin/init
volume:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
run_options:
stop-signal: SIGRTMIN+3
security_opt: seccomp=unconfined
cap_add: SYS_ADMIN

- name: centos-6
driver_config:
image: williamyeh/ansible:centos6

- name: centos-7
driver_config:
<<: *systemd_driver_config
image: centos:7
provision_command:
- *provision_cmd_1
- *provision_cmd_2
- *provision_cmd_3
- yum install -y iproute
suites:
- name: default
- name: logfile
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ source "https://rubygems.org"
gem "test-kitchen"
gem "kitchen-ansible"
gem "kitchen-vagrant"
gem "kitchen-docker"
22 changes: 16 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
GEM
remote: https://rubygems.org/
specs:
artifactory (2.3.3)
kitchen-ansible (0.44.6)
artifactory (2.5.1)
kitchen-ansible (0.45.5)
net-ssh (~> 3.0)
test-kitchen (~> 1.4)
kitchen-docker (2.6.0)
test-kitchen (>= 1.0.0)
kitchen-vagrant (0.20.0)
test-kitchen (~> 1.4)
mixlib-install (1.1.0)
mixlib-install (2.1.6)
artifactory
mixlib-shellout
mixlib-versioning
mixlib-shellout (2.2.6)
thor
mixlib-shellout (2.2.7)
mixlib-versioning (1.1.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.2.0)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
safe_yaml (1.0.4)
test-kitchen (1.10.2)
mixlib-install (~> 1.0, >= 1.0.4)
test-kitchen (1.13.2)
mixlib-install (>= 1.2, < 3.0)
mixlib-shellout (>= 1.2, < 3.0)
net-scp (~> 1.1)
net-ssh (>= 2.9, < 4.0)
net-ssh-gateway (~> 1.2.0)
safe_yaml (~> 1.0)
thor (~> 0.18)
thor (0.19.1)
Expand All @@ -31,5 +37,9 @@ PLATFORMS

DEPENDENCIES
kitchen-ansible
kitchen-docker
kitchen-vagrant
test-kitchen

BUNDLED WITH
1.13.6
1 change: 1 addition & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
state: present
reload: yes
ignoreerrors: yes
failed_when: False
when: redis_travis_ci is not defined

# get_url on Ansible 1.x only supports sha256 checksumming, so we're only
Expand Down
14 changes: 11 additions & 3 deletions test/integration/default/serverspec/redis_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
require 'spec_helper'

is_systemd_init = File.realpath('/proc/1/exe').include?('systemd')
is_sysctl_writable = test('w', '/proc/sys')

describe 'Redis' do
describe service('redis_6379') do
describe service('redis_6379'), if: !is_systemd_init do
it { should be_enabled }
it { should be_running }
end

describe service('redis_6379'), if: is_systemd_init do
#it { should be_enabled.under('systemd') }
it { should be_running.under('systemd') }
end

describe port(6379) do
it { should be_listening.on('0.0.0.0').with('tcp') }
end
Expand All @@ -16,13 +24,13 @@
its(:content) { should match /port 6379/ }
end

describe file('/var/run/redis/6379.pid') do
describe file('/var/run/redis/6379.pid'), if: !is_systemd_init do
it { should be_file }
it { should be_owned_by 'redis' }
its(:size) { should > 0 }
end

describe file('/proc/sys/vm/overcommit_memory') do
describe file('/proc/sys/vm/overcommit_memory'), if: is_sysctl_writable do
it { should be_file }
it { should contain '1' }
end
Expand Down
11 changes: 9 additions & 2 deletions test/integration/sentinel/serverspec/sentinel_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
require 'spec_helper'

is_systemd_init = File.realpath('/proc/1/exe').include?('systemd')

describe 'Redis' do
describe service('sentinel_26379') do
describe service('sentinel_26379'), if: !is_systemd_init do
it { should be_enabled }
it { should be_running }
end

describe service('sentinel_26379'), if: is_systemd_init do
#it { should be_enabled }.under('systemd')
it { should be_running }.under('systemd')
end

describe port(26379) do
it { should be_listening.on('0.0.0.0').with('tcp') }
end
Expand All @@ -16,7 +23,7 @@
its(:content) { should match /port 26379/ }
end

describe file('/var/run/redis/sentinel_26379.pid') do
describe file('/var/run/redis/sentinel_26379.pid'), if: !is_systemd_init do
it { should be_file }
it { should be_owned_by 'redis' }
its(:size) { should > 0 }
Expand Down
14 changes: 11 additions & 3 deletions test/integration/service-name/serverspec/redis_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
require 'spec_helper'

is_systemd_init = File.realpath('/proc/1/exe').include?('systemd')
is_sysctl_writable = test('w', '/proc/sys')

describe 'Redis' do
describe service('redis') do
describe service('redis'), if: !is_systemd_init do
it { should be_enabled }
it { should be_running }
end

describe service('redis'), if: is_systemd_init do
#it { should be_enabled.under('systemd') }
it { should be_running.under('systemd') }
end

describe port(6379) do
it { should be_listening.on('0.0.0.0').with('tcp') }
end
Expand All @@ -16,13 +24,13 @@
its(:content) { should match /port 6379/ }
end

describe file('/var/run/redis/6379.pid') do
describe file('/var/run/redis/6379.pid'), if: !systemd_init do
it { should be_file }
it { should be_owned_by 'redis' }
its(:size) { should > 0 }
end

describe file('/proc/sys/vm/overcommit_memory') do
describe file('/proc/sys/vm/overcommit_memory'), if: is_sysctl_writable do
it { should be_file }
it { should contain '1' }
end
Expand Down