Skip to content

Latest commit

 

History

History
122 lines (80 loc) · 2.68 KB

TESTING.md

File metadata and controls

122 lines (80 loc) · 2.68 KB

Testing

Required Gems

  • yard
  • vagrant
  • foodcritic
  • rubocop
  • berkshelf
  • should_not
  • chefspec
  • test-kitchen
  • kitchen-vagrant

Required Gems for Guard

  • guard
  • guard-foodcritic
  • guard-rubocop
  • guard-rspec
  • guard-kitchen

More info at Guard Readme.

Installing the Requirements

You must have VirtualBox and Vagrant installed.

You can install gem dependencies with bundler:

$ gem install bundler
$ bundle install --without travis

Generating the Documentation

$ bundle exec rake doc

Running the Syntax Style Tests

$ bundle exec rake style

Running the Unit Tests

$ bundle exec rake unit

Running the Integration Tests

$ bundle exec rake integration:vagrant

Or:

$ bundle exec kitchen list
$ bundle exec kitchen test
[...]

Running Integration Tests in Docker

You need to have Docker installed.

$ wget -qO- https://get.docker.com/ | sh

Then use the integration:docker rake task to run the tests:

$ bundle exec rake integration:docker

Running Integration Tests in the Cloud

Requirements

  • kitchen-digitalocean
  • kitchen-ec2

You can run the tests in the cloud instead of using vagrant. First, you must set the following environment variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_KEYPAIR_NAME: EC2 SSH public key name. This is the name used in Amazon EC2 Console's Key Pars section.
  • EC2_SSH_KEY_PATH: EC2 SSH private key local full path. Only when you are not using an SSH Agent.
  • DIGITALOCEAN_ACCESS_TOKEN
  • DIGITALOCEAN_SSH_KEY_IDS: DigitalOcean SSH numeric key IDs.
  • DIGITALOCEAN_SSH_KEY_PATH: DigitalOcean SSH private key local full path. Only when you are not using an SSH Agent.

Then use the integration:cloud rake task to run the tests:

$ bundle exec rake integration:cloud

Using Vagrant with the Vagrantfile

Vagrantfile Requirements

$ vagrant plugin install vagrant-berkshelf vagrant-omnibus
  • The path correctly set for ChefDK:
$ export PATH="/opt/chefdk/bin:${PATH}"
  • Set your license key in the BB_LICENSE enviroment variable:
$ export BB_LICENSE='PRO-1234'

Vagrantfile Usage

$ vagrant up

To run Chef again on the same machine:

$ vagrant provision

The default login credentials are:

To destroy the machine:

$ vagrant destroy