From bb731fdbc96ca2fd18b5711d59a9f520691cf039 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Wed, 15 May 2019 15:30:26 -0700 Subject: [PATCH] Add kitchen rake testing I'd suggest starting to structure kitchen testing like this with a directory and subdirs to keep the kitchen testing gems out of the root Gemfile entirely. This still mounts the root dir in /inspec so the root Gemfile is still what you're running the rake tests against. By having an extra layer of subdirs, then you can split up different use cases like the rake-testing vs. the audit cookbook testing. Otherwise it'll be a mess of having to manage different kitchen.yml files that require way too many different drivers/provisioners/verifiers --- kitchen/rake-tests/Gemfile | 4 ++++ kitchen/rake-tests/bootstrap.sh | 12 ++++++++++++ kitchen/rake-tests/kitchen.yml | 24 ++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 kitchen/rake-tests/Gemfile create mode 100644 kitchen/rake-tests/bootstrap.sh create mode 100644 kitchen/rake-tests/kitchen.yml diff --git a/kitchen/rake-tests/Gemfile b/kitchen/rake-tests/Gemfile new file mode 100644 index 000000000..c3b8cd5b5 --- /dev/null +++ b/kitchen/rake-tests/Gemfile @@ -0,0 +1,4 @@ +source "https://www.rubygems.org" + +gem "test-kitchen" +gem "kitchen-docker" diff --git a/kitchen/rake-tests/bootstrap.sh b/kitchen/rake-tests/bootstrap.sh new file mode 100644 index 000000000..20225017b --- /dev/null +++ b/kitchen/rake-tests/bootstrap.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +echo "STARTING PROVISIONER" + +export PATH=/opt/inspec/embedded/bin:$PATH +cd /inspec +gem install bundler +bundle install +gem build inspec +gem install ./inspec-*.gem + +echo "ENDING PROVISIONER" diff --git a/kitchen/rake-tests/kitchen.yml b/kitchen/rake-tests/kitchen.yml new file mode 100644 index 000000000..27c9d2827 --- /dev/null +++ b/kitchen/rake-tests/kitchen.yml @@ -0,0 +1,24 @@ +driver: + name: docker + +platforms: +- name: ubuntu-18.04 + driver_config: + image: ubuntu:18.04 + platform: ubuntu + provision_command: + - curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -P inspec + - apt-get -y install build-essential + require_chef_omnibus: false + volume: <%= File.expand_path("../..", File.dirname(__FILE__)) %>:/inspec + +provisioner: + name: shell + +verifier: + name: shell + remote_exec: true + command: cd /inspec && PATH=/opt/inspec/embedded/bin:$PATH bundle exec rake test + +suites: +- name: default