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

Commit

Permalink
(FM-5091) Implement docker-based full-system tests
Browse files Browse the repository at this point in the history
This uses travis to run a preliminary evaluation of PRs using the
spec/acceptance test suites running in a docker container on a VM-based
travis runner. This allows us to evaluate the effects of a change before
merging it.
  • Loading branch information
DavidS committed Apr 18, 2016
1 parent 32e1b9e commit 8c461c4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ config_defaults.yml might look like:
You can add additional environments for a specific module to test by adding an
extras: section with the same format to the module's .sync.yml.

By setting the `docker_sets`, the .travis.yml file sets up full-system tests running in a docker container. `docker_defaults` allows you to specify or replace global defaults. Use the `options` entry on a docker set, to override individual options.

**`moduleroot/.rspec`**

Flat file containing recommended default rspec options.
Expand Down
11 changes: 11 additions & 0 deletions config_defaults.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
---
.travis.yml:
script: "\"bundle exec rake validate lint spec\""
docker_sets:
- set: docker/ubuntu-14.04
- set: docker/centos-7
docker_defaults:
# values will replace @@SET@@ with the docker_sets' value
rvm: 2.1.6
sudo: required
dist: trusty
services: docker
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=@@SET@@
script: bundle exec rake beaker
includes:
- rvm: 2.1.6
env: PUPPET_GEM_VERSION="~> 4.0" STRICT_VARIABLES="yes"
Expand Down
38 changes: 28 additions & 10 deletions moduleroot/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,44 @@
sudo: false
language: ruby
cache: bundler
bundler_args: --without system_tests
script: <%= @configs['script'] %>
matrix:
fast_finish: true
include:
<% @configs['includes'].each do |include| -%>
- rvm: <%= include['rvm'] %>
env: <%= include['env'] %>
<% if @configs['docker_sets'] -%>
<% @configs['docker_sets'].each do |set| -%>
<% job = @configs['docker_defaults'].merge(set['options'] || {}) -%>
- rvm: <%= job['rvm'] %>
<% job.keys.sort.each do |k| -%>
<% next if k == 'rvm' -%>
<%= k %>: <%= job[k].gsub(/@@SET@@/, set['set']) %>
<% end -%>
<% end -%>
<% end -%>
<% @configs['includes'].each do |job| -%>
- rvm: <%= job['rvm'] %>
<% job.keys.sort.each do |k| -%>
<% next if k == 'rvm' -%>
<%= k %>: <%= job[k] %>
<% end -%>
<% end -%>
<% if @configs['extras'] -%>
<% @configs['extras'].each do |extra| -%>
- rvm: <%= extra['rvm'] %>
env: <%= extra['env'] %>
<% @configs['extras'].each do |job| -%>
- rvm: <%= job['rvm'] %>
<% job.keys.sort.each do |k| -%>
<% next if k == 'rvm' -%>
<%= k %>: <%= job[k] %>
<% end -%>
<% end -%>
<% end -%>
<% if @configs['allow_failures'] -%>
<% @configs['allow_failures'].each do |allow_failures| -%>
allow_failures:
- rvm: <%= allow_failures['rvm'] %>
env: <%= allow_failures['env'] %>
<% @configs['allow_failures'].each do |job| -%>
- rvm: <%= job['rvm'] %>
<% job.keys.sort.each do |k| -%>
<% next if k == 'rvm' -%>
<%= k %>: <%= job[k] %>
<% end -%>
<% end -%>
<% end -%>
notifications:
Expand Down
12 changes: 12 additions & 0 deletions moduleroot/spec/acceptance/nodesets/docker/centos-7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HOSTS:
centos-7-x64:
platform: el-7-x86_64
hypervisor: docker
image: centos:7
docker_preserve_image: true
docker_cmd: '["/usr/sbin/init"]'
# install various tools required to get the image up to usable levels
docker_image_commands:
- 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts'
CONFIG:
trace_limit: 200
11 changes: 11 additions & 0 deletions moduleroot/spec/acceptance/nodesets/docker/debian-8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
HOSTS:
debian-8-x64:
platform: debian-8-amd64
hypervisor: docker
image: debian:8
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
- 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen'
CONFIG:
trace_limit: 200
12 changes: 12 additions & 0 deletions moduleroot/spec/acceptance/nodesets/docker/ubuntu-14.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
HOSTS:
ubuntu-1404-x64:
platform: ubuntu-14.04-amd64
hypervisor: docker
image: ubuntu:14.04
docker_preserve_image: true
docker_cmd: '["/sbin/init"]'
docker_image_commands:
# ensure that upstart is booting correctly in the container
- 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8'
CONFIG:
trace_limit: 200

0 comments on commit 8c461c4

Please sign in to comment.