Skip to content

Commit

Permalink
Initial configuration of automated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amontalban committed Oct 29, 2016
1 parent 5a50911 commit e29b770
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.pyc
*~
Gemfile.lock
.kitchen/
6 changes: 6 additions & 0 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
driver:
name: docker
hostname: salt-formula.ci.local
use_sudo: true
require_chef_omnibus: false
32 changes: 32 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<%
require 'yaml'
formula = YAML.load_file('FORMULA')
formula_name = formula['name']
%>
---
verifier:
name: inspec

platforms:
- name: ubuntu-12.04
- name: ubuntu-14.04
- name: ubuntu-16.04
- name: debian-7
- name: debian-8

provisioner:
name: salt_solo
salt_install: bootstrap
salt_bootstrap_url: https://bootstrap.saltstack.com
salt_version: latest
salt_pillar_root: pillar.example
log_level: <%= ENV['SALT_DEBUG_LEVEL'] || 'info' %>
formula: <%= formula_name %>
state_top:
base:
'*':
- <%= formula_name %>

suites:
- name: default
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: ruby

rvm:
- 2.2.5

sudo: required
services: docker

env:
matrix:
- INSTANCE=default-ubuntu-1204
- INSTANCE=default-ubuntu-1404
- INSTANCE=default-ubuntu-1604
- INSTANCE=default-debian-7
- INSTANCE=default-debian-8

# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142455888
before_script: sudo iptables -L DOCKER || sudo iptables -N DOCKER

install:
# setup ci for test formula
- export BUNDLE_GEMFILE=$PWD/Gemfile
- bundle install

script:
# Run unit tests
- KITCHEN_LOCAL_YAML=.kitchen.docker.yml bundle exec kitchen verify ${INSTANCE}
18 changes: 18 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
source 'https://rubygems.org'

gem 'codeclimate-test-reporter', group: :test, require: nil
gem 'rake'
gem 'berkshelf', '~> 4.0'

group :integration do
gem 'test-kitchen'
gem 'kitchen-salt'
gem 'kitchen-inspec'
end

group :docker do
gem 'kitchen-docker'
end

# vi: set ft=ruby :
gem "kitchen-vagrant"
31 changes: 31 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'rake'
require 'rake/testtask'
require 'bundler/setup'

Rake::TestTask.new do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end

desc 'Run Test Kitchen integration tests'
namespace :integration do
desc 'Run integration tests with kitchen-docker'
task :docker do
require 'kitchen'
Kitchen.logger = Kitchen.default_file_logger
@loader = Kitchen::Loader::YAML.new(local_config: '.kitchen.docker.yml')
Kitchen::Config.new(loader: @loader).instances.each do |instance|
instance.test(:always)
end
end
end

task default: :test

begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new
rescue LoadError
puts '>>>>> Kitchen gem not loaded, omitting tasks' unless ENV['CI']
end
10 changes: 5 additions & 5 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ mysql:
grants: ['select', 'insert', 'update']

# Override any names defined in map.jinja
lookup:
server: mysql-server
client: mysql-client
service: mysql-service
python: python-mysqldb
# lookup:
# server: mysql-server
# client: mysql-client
# service: mysql-service
# python: python-mysqldb

# Install MySQL headers
dev:
Expand Down

0 comments on commit e29b770

Please sign in to comment.