Questions tagged [test-kitchen]

Test Kitchen is an integration tool for developing and testing infrastructure code and software on isolated target platforms.

What is Test Kitchen?

Test Kitchen is a test harness tool to execute your configured code on one or more platforms in isolation. A driver plugin architecture is used which lets you run your code on various cloud providers and virtualization technologies such as Amazon EC2, Blue Box, CloudStack, Digital Ocean, Rackspace, OpenStack, Vagrant, Docker, LXC containers, and more. Many testing frameworks are already supported out of the box including Bats, shUnit2, RSpec, Serverspec, with others being created weekly.

For Chef workflows, cookbook dependency resolver tools such as Berkshelf and Librarian-Chef are supported or you can simply have a cookbooks/ directory and Test Kitchen will know what to do. Support for Test Kitchen is already included in many Chef community cookbooks such as the MySQL, nginx, Chef Server, and runit cookbooks.

What does it give me?

Test Kitchen has a simple workflow that stresses speed but optimizes for the freshness of your code executing on the remote systems between tests. It has a static, declarative configuration in a .kitchen.yml file at the root of your project. It is designed to execute isolated code run in pristine environments ensuring that no prior state exists. A plugin architecture gives you the freedom to run your code on any cloud, virtualization, or bare metal resources and allows you to write acceptance criteria in whatever framework you desire.

How do I get started?

Adding testing support to your Chef cookbook or project is easy. Assuming you have Ruby 1.9 or higher and Vagrant installed, open a terminal session and type:

$ gem install test-kitchen
$ kitchen init
$ kitchen test

For more comprehensive instructions, check out the Getting Started guide.

358 questions
23
votes
4 answers

Alternate drivers with test-kitchen

Many cookbooks, such as the mysql cookbook have multiple .kitchen.yml files. For example, mysql has a .kitchen.yml and a .kitchen-cloud.yml. Looking at documentation and code for test-kitchen, I can't see any way to use config files other than…
Tejay Cardon
  • 4,193
  • 2
  • 16
  • 31
17
votes
3 answers

How to specify cookbook path in .kitchen.yml file?

I have my Chef cookbooks stored in chef/cookbooks/ folder. When running kitchen converge I am still getting notice Berksfile, Cheffile, cookbooks/, or metadata.rb not found so Chef will run with effectively no cookbooks. Is this intended? I tried…
tsusanka
  • 4,801
  • 7
  • 36
  • 42
12
votes
2 answers

ChefSpec and Test Kitchen

I am investigating if ChefSpec report (with coverage) and Test Kitchen report can be generated as junit format so they can be parsed then by Jenkins to publish results. Or if there is some other friendly way those results could be published by…
user2620348
  • 309
  • 4
  • 15
11
votes
1 answer

Adding Attributes to Test Kitchen

I'm trying to override attributes in the java cookbook with test-kitchen. When I try run kitchen converge default-centos-64, a bad YAML error shows up. --- driver: name: vagrant customize: memory: 1024 cpuexecutioncap: 50 provisioner: …
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
9
votes
6 answers

Cannot Login Into Vagrant boxes managed via Test Kitchen

I have a very boiler plate .kitchen.yml with the following: --- driver: name: vagrant platforms: - name: ubuntu-14.04 suites: - name: default run_list: - recipe[webserver::default] when I run kitchen converge I get the following: ==>…
Sam Hammamy
  • 10,819
  • 10
  • 56
  • 94
8
votes
2 answers

How to pass environment variables to test kitchen in .kitchen.yml

I am trying develop a cookbook to make a flask app work with gunicorn and nginx. I have been successful to the point that the app is running very well with a local sqlite database, see my cookbook at https://github.com/harrywang/flasky-cookbook. The…
dami.max
  • 377
  • 3
  • 17
8
votes
2 answers

How to capture Chef::Log.info in kitchen test

When I run kitchen test or kitchen test --log-level info No logs that I have in my recipe under test ie. Chef::Log.info("How to make appear in kitchen output?") are displayed in kitchen's output to console. Anyway to make this…
MikeW
  • 4,749
  • 9
  • 42
  • 83
8
votes
3 answers

Testing Chef roles and environments

I'm new to Chef and have been using Test Kitchen to test the validity of my cookbooks, which works great. Now I'm trying to ensure that environment-specific attributes are correct on production nodes prior to running Chef initially. These would be…
Dan Stark
  • 808
  • 1
  • 9
  • 23
8
votes
3 answers

test-kitchen update instead of create every time

In test-kitchen, is there a way to update the instance created instead of destroying and recreating the instance every time? Say if I change in kitchen.yml and want to see that change, running the whole destroy/create can take a while.
8
votes
2 answers

How to specify the version of Chef Solo in Test Kitchen .kitchen.yml file?

I am using Test Kitchen to test a cookbook. I would like to specify the version number of chef solo that will be installed. How can I specify a version number?
Andrew
  • 227,796
  • 193
  • 515
  • 708
8
votes
2 answers

Virtualbox is locked when I try to destroy a kitchen instance

I ran a test-kitchen instance and all was fine, but at the end when I did try to destroy it kitchen with: roberto@pc:~$ kitchen destroy Virtualbox gave me this error. -----> Starting Kitchen (v1.1.1) -----> Destroying ... …
Robert
  • 10,403
  • 14
  • 67
  • 117
6
votes
2 answers

How do I access Chef data_bags in InSpec

I am writing InSpec tests for some new Chef recipes I am working on. I would like to utilise the data_bags used by the cookbooks to iterate through the data bag items. I can't figure out how to access them in my InSpec tests! The recipes are using…
5
votes
2 answers

How do you mock OpsWorks specific services/dependencies when developing locally with Kitchen and Chef?

I'm writing Chef wrappers around some of the built in OpsWorks cookbooks. I'm using Berkshelf to clone the OpsWorks cookbooks from their github repo. This is my Berksfile: source 'https://supermarket.getchef.com' metadata def…
5
votes
1 answer

test-kitchen won't reference local cookbooks

I'm trying to test a cookbook that depends on three other local cookbooks. My directory structure looks like this: /cookbooks/ cookbook_test/ recipes templates metadata.rb cookbook_dep1/ cookbook_dep2/ cookbook_dep3/ My…
5
votes
4 answers

Kitchen test how to use local vm.box

Every time I run kitchen test it downloads a new vm box. Is there a way to make it re-use a locally downloaded box? Here is my .kitchen.yml file. --- driver_plugin: vagrant driver_config: require_chef_omnibus: true platforms: - name:…
markhorrocks
  • 1,199
  • 19
  • 82
  • 151
1
2 3
23 24