Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

Commit

Permalink
testing with dokken (#43)
Browse files Browse the repository at this point in the history
* Testing with dokken
* Fixing nil property
* Adding privileged for swap
* Removes ubuntu-12.04
* Adding logging for virtualization
* Adding /mnt as volume
* Use sudo
* Upgrading kitchen-dokken
* removing docker-engine in favour of services docker
* fixing persist test
* removes fedora core
  • Loading branch information
rshade authored and damacus committed Feb 27, 2017
1 parent 28b6e7e commit 60cc941
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .kitchen.dokken.yml
Expand Up @@ -2,6 +2,7 @@ driver:
name: dokken
privileged: true # because Docker and SystemD/Upstart
chef_version: current
volumes: [ '/mnt' ]

transport:
name: dokken
Expand All @@ -17,6 +18,7 @@ platforms:
- name: centos-6
driver:
image: centos:6
privileged: true
platform: rhel
pid_one_command: /sbin/init
intermediate_instructions:
Expand All @@ -25,6 +27,7 @@ platforms:
- name: centos-7
driver:
image: centos:7
privileged: true
platform: rhel
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
Expand All @@ -33,6 +36,7 @@ platforms:
- name: debian-7
driver:
image: debian:7
privileged: true
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update
Expand All @@ -41,6 +45,7 @@ platforms:
- name: debian-8
driver:
image: debian:8
privileged: true
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
Expand All @@ -49,13 +54,15 @@ platforms:
- name: fedora-25
driver:
image: fedora:25
privileged: true
pid_one_command: /usr/lib/systemd/systemd
intermediate_instructions:
- RUN dnf -y install yum which systemd-sysv initscripts wget net-tools

- name: ubuntu-14.04
driver:
image: ubuntu-upstart:14.04
privileged: true
pid_one_command: /sbin/init
intermediate_instructions:
- RUN /usr/bin/apt-get update
Expand All @@ -64,6 +71,7 @@ platforms:
- name: ubuntu-16.04
driver:
image: ubuntu:16.04
privileged: true
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN /usr/bin/apt-get update
Expand All @@ -72,6 +80,7 @@ platforms:
- name: opensuse-leap
driver:
image: opensuse:leap
privileged: true
pid_one_command: /bin/systemd
intermediate_instructions:
- RUN zypper --non-interactive install aaa_base perl-Getopt-Long-Descriptive which hostname
52 changes: 45 additions & 7 deletions .travis.yml
@@ -1,5 +1,5 @@
# Use Travis's cointainer based infrastructure
sudo: false
sudo: required
dist: trusty

addons:
apt:
Expand All @@ -8,19 +8,57 @@ addons:
packages:
- chefdk

before_install:
- sudo chef gem install kitchen-dokken
# Don't `bundle install` which takes about 1.5 mins
install: echo "skip bundle install"

branches:
only:
- master

services: docker

env:
matrix:
- INSTANCE=create-centos-6
- INSTANCE=create-centos-7
- INSTANCE=create-debian-8
- INSTANCE=create-ubuntu-1404
- INSTANCE=create-ubuntu-1604
- INSTANCE=create-fedora-25
- INSTANCE=create-opensuse-leap
- INSTANCE=create-swappiness-centos-6
- INSTANCE=create-swappiness-centos-7
- INSTANCE=create-swappiness-debian-8
- INSTANCE=create-swappiness-ubuntu-1404
- INSTANCE=create-swappiness-ubuntu-1604
- INSTANCE=create-swappiness-fedora-25
- INSTANCE=persist-centos-6
- INSTANCE=persist-centos-7
- INSTANCE=persist-debian-8
- INSTANCE=persist-ubuntu-1404
- INSTANCE=persist-ubuntu-1604
- INSTANCE=persist-opensuse-leap
- INSTANCE=remove-centos-6
- INSTANCE=remove-centos-7
- INSTANCE=remove-debian-8
- INSTANCE=remove-ubuntu-1404
- INSTANCE=remove-ubuntu-1604
- INSTANCE=remove-fedora-25
- INSTANCE=remove-opensuse-leap
# Ensure we make ChefDK's Ruby the default
before_script:
- sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER )
- eval "$(/opt/chefdk/bin/chef shell-init bash)"

script:
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/cookstyle --version
- /opt/chefdk/embedded/bin/foodcritic --version
- /opt/chefdk/bin/chef exec rake
script: sudo KITCHEN_LOCAL_YAML=.kitchen.dokken.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE}

matrix:
include:
script:
- /opt/chefdk/embedded/bin/chef --version
- /opt/chefdk/embedded/bin/cookstyle --version
- /opt/chefdk/embedded/bin/foodcritic --version
- /opt/chefdk/bin/chef exec rake
env: UNIT_AND_LINT=1
11 changes: 5 additions & 6 deletions resources/file.rb
Expand Up @@ -22,17 +22,16 @@
property :swappiness, Integer

action :create do
command = swap_creation_command
fallback_command = fallback_swap_creation_command
if swap_enabled?
Chef::Log.debug("#{new_resource} already created - nothing to do")
else
begin
do_create(command)
Chef::Log.info "starting first create: #{node['virtualization']['system']}"
do_create(swap_creation_command)
rescue Mixlib::ShellOut::ShellCommandFailed => e
Chef::Log.info("#{new_resource} Rescuing failed swapfile creation for #{new_resource.path}")
Chef::Log.warn("#{new_resource} Rescuing failed swapfile creation for #{new_resource.path}")
Chef::Log.debug("#{new_resource} Exception when creating swapfile #{new_resource.path}: #{e}")
do_create(fallback_command)
do_create(dd_command)
end
end
if new_resource.swappiness
Expand Down Expand Up @@ -106,7 +105,7 @@ def swap_enabled?
end

def swap_creation_command
command = if compatible_filesystem? && compatible_kernel
command = if compatible_filesystem? && compatible_kernel && !docker?
fallocate_command
else
dd_command
Expand Down
Expand Up @@ -7,5 +7,5 @@
end

describe bash('grep 10 /proc/sys/vm/swappiness') do
its('stdout') { should match %r{\/proc\/sys\/vm\/swappiness} }
its('stdout') { should match /10/ }
end
4 changes: 2 additions & 2 deletions test/integration/persist/persist_spec.rb
@@ -1,3 +1,3 @@
describe bash('cat /etc/fstab') do
its('stdout') { should match %r{\/mnt\/swap/} }
describe bash('grep /mnt/swap /etc/fstab | awk \'{ print $1 }\' | tr -d \'\n\'') do
its('stdout') { should match %r{/mnt/swap} }
end

0 comments on commit 60cc941

Please sign in to comment.