cookbook-openstack-integrat.../TESTING.md
Jan Klare 38d3b8808e move from bundle to chefdk and add bootstrap.sh
bootstrap script installs testing dependencies on trusty and relies on
common bootstrap.sh in stackforge/cookbook-openstack-common
- fixed mixup in dependency for knife task in Rakefile
- deprecated Gemfile
- updated TESTING.md

blueprint: bootstrap-infra-test-nodes

Change-Id: Ia6e457570fc585874dbf56751c2f8388eb637bbc
2015-04-27 22:07:39 +02:00

2.4 KiB

Testing the Cookbook

This cookbook uses chefdk and berkshelf to isolate dependencies. Make sure you have chefdk and the header files for gecode installed before continuing. Make sure that you're using gecode version 3. More info here. For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the openstack-chef-repo.

We have four test suites which you can run either, individually (there are three rake tasks):

$ chef exec rake lint
$ chef exec rake style
$ chef exec rake knife
$ chef exec rake unit

or altogether:

$ chef exec rake

The rake tasks will take care of installing the needed cookbooks with berkshelf.

Rubocop

Rubocop is a static Ruby code analyzer, based on the community Ruby style guide. We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.

Attribute Rules

Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific .rubocop.yml files for each of:

Gemfile and metadata.rb attributes/*.rb recipes/.rubocop.yml spec/.rubocop.yml

Knife

knife cookbook test is used to check the cookbook's Ruby and ERB files for basic syntax errors.

Foodcritic

Foodcritic is a lint tool for Chef cookbooks. We ignore the following rules:

FC003 these cookbooks are not intended for Chef Solo.

Chefspec

ChefSpec is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.