From dbfd95bae48caae8a6d10a1bd4e54aaf44d1ff40 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 10:48:57 +0000 Subject: [PATCH 1/7] Switching to docker for testing. --- .kitchen.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index 6386c82..b9b9135 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,18 +1,24 @@ --- driver: - name: vagrant - # name: docker - # binary: /usr/bin/docker - # use_sudo: false - # remove_images: true - # build_context: '.' + name: docker + hostname: salt-formula.ci.local + use_sudo: false + require_chef_omnibus: false + +driver_config: + cap_add: + - SYS_PTRACE + +# verifier: +# name: inspec platforms: - - name: debian-jessie64 - # - name: ubuntu-14.04-minimal - driver_config: - box: ssplatt/salt-deb-8 - # box: saltstack/ubuntu-14.04-minimal + - name: ubuntu-14.04 + - name: ubuntu-16.04 + - name: debian-7 + - name: debian-8 + - name: centos-6 + - name: centos-7 provisioner: name: salt_solo From e9c8b65c4245ce5ae37c74436906b4428702b305 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 10:54:42 +0000 Subject: [PATCH 2/7] Adding travis file. --- .travis.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..daca1a3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +language: php + +rvm: + - 2.2.5 + +sudo: required +services: + - docker + - mysql + - apache + +env: + matrix: + - INSTANCE: high-ubuntu-1404 + - INSTANCE: high-ubuntu-1604 + - INSTANCE: high-debian-7 + - INSTANCE: high-debian-8 + - INSTANCE: high-centos-6 + - INSTANCE: cli-ubuntu-1404 + - INSTANCE: cli-ubuntu-1604 + - INSTANCE: cli-debian-7 + - INSTANCE: cli-debian-8 + - INSTANCE: cli-centos-6 + - INSTANCE: config-ubuntu-1404 + - INSTANCE: config-ubuntu-1604 + - INSTANCE: config-debian-7 + - INSTANCE: config-debian-8 + - INSTANCE: config-centos-6 + +# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142455888 +before_script: + - sudo iptables -L DOCKER || sudo iptables -N DOCKER + - sudo apt-get install php5-mysql + - mysql -e 'CREATE DATABASE IF NOT EXISTS siteAdb;' + - mysql -e 'CREATE DATABASE IF NOT EXISTS siteBdb;' + +install: + # setup ci for test formula + - export BUNDLE_GEMFILE=$PWD/Gemfile + - bundle install + +script: bundle exec kitchen verify ${INSTANCE} From 7d4e2f01761d84f3ec42300a35467b87d397de26 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 11:21:58 +0000 Subject: [PATCH 3/7] Clone dependancies --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index daca1a3..790af4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,10 @@ env: # https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142455888 before_script: - sudo iptables -L DOCKER || sudo iptables -N DOCKER - - sudo apt-get install php5-mysql - - mysql -e 'CREATE DATABASE IF NOT EXISTS siteAdb;' - - mysql -e 'CREATE DATABASE IF NOT EXISTS siteBdb;' + - sudo apt-get install git + - git clone https://github.com/saltstack-formulas/apache-formula.git /tmp/kitchen/srv/salt/apache + - git clone https://github.com/saltstack-formulas/php-formula.git /tmp/kitchen/srv/salt/php + - git clone https://github.com/saltstack-formulas/mysql-formula.git /tmp/kitchen/srv/salt/mysql install: # setup ci for test formula From cc821f609a92018f62c54a2668db9079243381d0 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 11:22:22 +0000 Subject: [PATCH 4/7] Fix dependancy paths. --- .kitchen.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.kitchen.yml b/.kitchen.yml index b9b9135..8f69921 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -27,9 +27,9 @@ provisioner: is_file_root: false formula: wordpress dependencies: - - {name: php, path: ../php-formula} - - {name: apache, path: ../apache-formula} - - {name: mysql, path: ../mysql-formula} + - {name: php, path: ../php} + - {name: apache, path: ../apache} + - {name: mysql, path: ../mysql} pillars: top.sls: base: From f85053b57e9a9b6387308dbc2ee21d7c0e084514 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 11:22:55 +0000 Subject: [PATCH 5/7] Adding Gemfile --- Gemfile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Gemfile diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..30fbf14 --- /dev/null +++ b/Gemfile @@ -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" \ No newline at end of file From ae3e11fba576a770fedf0c4d5b10d70d8d4c63d8 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 11:23:32 +0000 Subject: [PATCH 6/7] Adding Rakefile --- Rakefile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Rakefile diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..340c55e --- /dev/null +++ b/Rakefile @@ -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 \ No newline at end of file From 8e9dc56fcbab4498c889d7522eceb9dd0c1f7b90 Mon Sep 17 00:00:00 2001 From: Fintan MacMahon Date: Thu, 19 Jan 2017 11:25:09 +0000 Subject: [PATCH 7/7] Adding spec helper --- test/shared/spec_helper.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/shared/spec_helper.rb diff --git a/test/shared/spec_helper.rb b/test/shared/spec_helper.rb new file mode 100644 index 0000000..d62fc6d --- /dev/null +++ b/test/shared/spec_helper.rb @@ -0,0 +1,9 @@ +require "serverspec" +require "pathname" + +# Set backend type +set :backend, :exec + +RSpec.configure do |c| + c.path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" +end