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
4
votes
1 answer

Port forwarding not working with Test-Kitchen and Vagrant

I'm on Ubuntu Linux 14.04 and I'm trying to create a Centos VM using kitchen-vagrant. I want port forwarding so that I can forward apache tomcat on my local machine. It's not working though I've specified the port number and private network IPs like…
user3505901
  • 408
  • 1
  • 6
  • 19
4
votes
2 answers

How to run idempotence test for ansible role via Test-Kitchen?

It is pretty easy with Travis-CI: # Run the role/playbook again, checking to make sure it's idempotent. - > ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo --extra-vars "take_ownership_of_tmp=$OWN_TMP" | grep…
strangeman
  • 519
  • 1
  • 5
  • 19
4
votes
1 answer

Test-Kitchen serverspec testing exception on windows

When using chef generate cookbook hello command, the serverspec spec_helper.rb file generated will not work with Test-Kitchen 1.4.1 and windows. kitchen verify command will throw the following on windows…
Dennis Hoer
  • 3,039
  • 2
  • 23
  • 34
4
votes
3 answers

How can I get test kitchen run same chef recipe multiple times?

I have a chef recipe that I'm using for deploying an application. Each time the recipe runs it creates a new "release" (with the current timestamp) directory and deletes older "release" directories leaving only the 5 most recent "release"…
Matthew J Morrison
  • 4,343
  • 3
  • 28
  • 45
4
votes
1 answer

Changing where kitchen-vagrant downloads chef from

I'm doing some Chef recipe testing using test-kitchen on vagrant virtuals. Each time I run kitchen test, it is downloading a copy of the chef omnibus installer from the standard place (Amazon). The problem is that I'm at home, and each of those…
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
3
votes
1 answer

Getting System.IO.IOException on File.Encrypt with an impersonated user

I am trying to encrypt a folder (with windows EFS) in a programmatic manner. The following powershell code works just fine when ran via ISE powershell console. $obj = New-Object -TypeName System.IO.FileInfo 'D:\Temp' $obj.Encrypt() However…
ostap36
  • 33
  • 6
3
votes
1 answer

is it possible to restart or reset a vagrant instance created by test-kitchen?

Sometimes I have to reboot or end my session mid testing on a machine. As it can take ages to do a full converge it would be great to just be able to start or stop a machine like I would using vagrant commands. Is this possible with machines created…
Josh Beauregard
  • 2,498
  • 2
  • 20
  • 37
3
votes
2 answers

Berks install SSL_Connect Certification Verify failed (Faraday:SSLError)

As part of a cookbook(newbie) i am trying to write, i was using berks to install the dependencies from other cookbooks and eventually when i am running berks install, i am encountering certificate verification errors. Can any one help me to know…
bablu
  • 75
  • 4
  • 11
3
votes
2 answers

In chef, is it possible to include serverspec tests of one cookbook into another cookbook?

Consider this, I have two cookbooks A and B with each having their own integration testing using serverspec tests and kitchen. Everything works fine if I want to test just one cookbook against its own test suites. Now, if I create a cookbook C that…
Magnus
  • 73
  • 8
3
votes
4 answers

Chef doesn't create home directory for user

I have a chef recipe to create a deploy user. The user is being created when running kitchen converge. When trying to create the .ssh folder for the user it fails with because the home directory for the user does not exists. Parent directory…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
3
votes
2 answers

How do I get Test Kitchen to cache the chef-client RPM?

Every time I run kitchen verify for the first time after creating a box, it needs to download the chef-client. E.g: downloaded metadata file looks valid... downloading…
rouan
  • 5,339
  • 6
  • 22
  • 36
3
votes
1 answer

Serverspec: Check if directory is empty

I want to check, if an existing directory is empty (does not contain any files or sub-directories). I tried the following: describe file('/path/to/file') do it { should be_empty } end But this doesn't work. (Of course, as it is not mentioned…
René Schubert
  • 1,302
  • 2
  • 13
  • 31
3
votes
1 answer

test-kitchen: how to read platform specific attributes in kitchen.yml

In my .kitchen.yml config I am trying apply attributes depending on platform version. My kitchen config looks like that: platforms: - name: centos-6.3 driver_plugin: ec2 driver: image_id: ami-xxxxxxxx attributes: …
Dmitry S
  • 4,990
  • 2
  • 24
  • 32
3
votes
3 answers

Test Kitchen login command failing

I'm following this getting-started guide for test kitchen and made some initial good progress. However when trying to use kitchen login command mentioned on this page , it fails with 'No such file or directory - ssh' My local system is Windows7,…
ss3065
  • 41
  • 5
3
votes
3 answers

How to specify cookbook path in .kitchen.yml file for chef_solo provisioner?

I want to specify cookbook paths using chef_solo as a provisioner in Test Kitchen. We are not using Berkshelf or chef_zero at this time. I set cookbooks_path in my .kitchen.yml file, but it seems like the chef_solo provisioner ignores that flag. …
invict_us
  • 103
  • 3
  • 8
1
2
3
23 24