Skip to content

Commit

Permalink
Run integration tests on Docker (.kitchen.docker.yml)
Browse files Browse the repository at this point in the history
  • Loading branch information
zuazo committed Sep 30, 2015
1 parent 5e446b4 commit da0d9bb
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 3 deletions.
56 changes: 56 additions & 0 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
driver:
name: docker
use_sudo: false

# If you add new platforms below, include them in the .travis.yml file matrix
platforms:
- name: centos-6
run_list: recipe[selinux::disabled]
# error: unpacking of archive failed on file /usr/sbin/suexec:
# cpio: cap_set_file failed - Operation not supportederror: unpacking of
# archive failed on file /usr/sbin/suexec: cpio: cap_set_file failed -
# Operation not supported:
# - name: centos-7
# run_list: recipe[selinux::disabled]
# No PHP 5.4 support:
# - name: debian-6
- name: debian-7
- name: debian-8
- name: ubuntu-12.04
- name: ubuntu-14.04
- name: ubuntu-15.04

# Non-official images
- name: scientific-6.6
driver_config:
image: ringo/scientific:6.6
platform: rhel

suites:
- name: mysql
run_list: recipe[owncloud_test::mysql]
excludes:
# Can't connect to MySQL server on '127.0.0.1' (111):
- ubuntu-12.04
- ubuntu-14.04
# bash[default :create initial records] timeout:
- ubuntu-15.04
- name: sqlite
run_list: recipe[owncloud_test::sqlite]
excludes:
# Error: mysql55w-libs conflicts with mysql-libs-5.1.73-5.el6_6.x86_64:
- centos-6
- scientific-6.6
- name: nginx
run_list: recipe[owncloud_test::nginx]
excludes:
# php54w-common conflicts with php-common-5.3.3-46.el6_6.x86_64:
- centos-6
# Can't connect to MySQL server on '127.0.0.1' (111):
- ubuntu-12.04
- ubuntu-14.04
# Errno::ENOENT: No such file or directory - /sbin/insserv:
- ubuntu-15.04
# /etc/sysconfig/network: No such file or directory:
- scientific-6.6
4 changes: 2 additions & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ suites:
# PostgreSQL >= 9 required
- centos-5.11
- name: sqlite
run_list: recipe[owncloud_test::sqlite]
excludes:
# execute[run owncloud setup]: Writing to database failed
- centos-5.11
run_list: recipe[owncloud_test::sqlite]
- name: nginx
run_list: recipe[owncloud_test::nginx]
excludes:
# Error: Missing Dependency: php54w-cli >= 5.1.0-1 is needed by package
# 1:php54w-pear-1.9.4-7.w5.noarch (installed)
- centos-5.11
run_list: recipe[owncloud_test::nginx]
4 changes: 4 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ def mysql_password(user)
basename = ::File.basename(download_url)
local_file = ::File.join(Chef::Config[:file_cache_path], basename)

# Required on Docker:
package 'tar'
package 'bzip2'

# Prior to Chef 11.6, remote_file does not support conditional get
# so we do a HEAD http_request to mimic it
http_request 'HEAD owncloud' do
Expand Down
1 change: 1 addition & 0 deletions test/cookbooks/owncloud_test/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
version '0.1.0'

depends 'locale', '~> 1.0'
depends 'netstat', '~> 0.1.0' # Required to run integration tests with Docker
depends 'nokogiri', '~> 0.1.4'
depends 'owncloud'
1 change: 1 addition & 0 deletions test/cookbooks/owncloud_test/recipes/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
end

# Required for integration tests:
include_recipe 'netstat'
include_recipe 'nokogiri'
5 changes: 4 additions & 1 deletion test/cookbooks/owncloud_test/recipes/postgresql_memory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def getconf(var)
cmd.stdout.split("\n")[-1]
end

if node['postgresql']['version'].to_f <= 9.3
if node['postgresql']['version'].to_f <= 9.3 &&
# sysctl: setting key "kernel.shmmax": Read-only file system
!::File.exist?('/.dockerinit')

page_size = getconf('PAGE_SIZE').to_i
phys_pages = getconf('_PHYS_PAGES').to_i

Expand Down
30 changes: 30 additions & 0 deletions test/unit/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,28 @@
allow(file_time).to receive(:httpdate).and_return(http_date)
end

it 'installs tar' do
expect(chef_run).to install_package('tar')
end

it 'installs bzip2' do
expect(chef_run).to install_package('bzip2')
end

context 'on CentOS' do
let(:chef_runner) do
ChefSpec::SoloRunner.new(platform: 'centos', version: '6.0')
end

it 'installs tar' do
expect(chef_run).to install_package('tar')
end

it 'installs bzip2' do
expect(chef_run).to install_package('bzip2')
end
end # context on CentOS

context 'with Chef 11.6' do
before { stub_const('Chef::VERSION', '11.6.0') }

Expand Down Expand Up @@ -599,6 +621,14 @@
context 'with deploying from git' do
before { node.set['owncloud']['deploy_from_git'] = true }

it 'does not install tar' do
expect(chef_run).to_not install_package('tar')
end

it 'does not install bzip2' do
expect(chef_run).to_not install_package('bzip2')
end

it 'clones git repository' do
expect(chef_run).to sync_git('clone owncloud')
.with_destination('/var/www/owncloud')
Expand Down

0 comments on commit da0d9bb

Please sign in to comment.