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
1
vote
1 answer

Temporary name resolution error with Test Kitchen EC2

When I run kitchen create with the config below I get an error: "[getaddrinfo: Temporary failure in name resolution] on default-centos-7". This system can resolve dns no issues so I'm not sure what the issue is... --- driver: name: ec2 …
TyMac
  • 783
  • 2
  • 9
  • 32
1
vote
1 answer

How check the httpd is enabled and running using InSpec with Kitchen-docker on CentOS?

Running my test with InSpec I am unable to test if the httpd is enabled and running. InSpec test describe package 'httpd' do it { should be_installed } end describe service 'httpd' do it { should be_enabled } it { should be_running…
Robert
  • 10,403
  • 14
  • 67
  • 117
1
vote
1 answer

Chef Test Kitchen Timeout during vagrant up

While working with Chef, Kitchen, Vagrant and Virtual Box today... I encountered a bizarre issue when attempting to use the bento boxes hosted by Hashicorp (https://atlas.hashicorp.com/bento/) to do some Chef cookbook development/testing. While…
KnownTraveler
  • 349
  • 2
  • 12
1
vote
1 answer

Chef test kitchen and policyfiles

This is my current situation, I have a single cookbook in an internal git repo. In that cookbook I have to keep several policy files and test them, for that I created a directory called policyfiles inside the cookbook, being something like…
Navarro
  • 1,284
  • 2
  • 17
  • 40
1
vote
0 answers

Fedora Chef Yum Issues

I am using Chef's Test Kitchen setup tools to test deploying onto a Fedora23 OS, and I am running into some frustrating issues with the build essentials and more specifically the python version on the system. I am trying to do basic operations like…
schriste92
  • 212
  • 1
  • 3
  • 13
1
vote
1 answer

Kitchen attributes only working on one platform

I am having a problem with my .kitchen.yml file. I want my attributes to be loaded for all my platforms but instead it is only being loaded for one of my platforms. This is what my .kitchen.yml file contents look like: .kitchen.yml --- driver: …
Matthew
  • 146
  • 2
  • 9
1
vote
1 answer

Setting up extra context with kitchen-terraform

I'm trying to use kitchen-terraform to verify a terraform module I'm building. This particular module is a small piece in a larger infrastructure. It depends on some pieces of the network being available and will then be used later to spin up…
dustyburwell
  • 5,755
  • 2
  • 27
  • 34
1
vote
1 answer

Chef serverspec `describe command` using an or statement

I would like to use a serverspec check and run it against two acceptable outcomes, so that if either passes then the check passes. I want my check to pass if the exit status of the command is either 0 or 1. Here is my check: describe command("rm…
Alex Cohen
  • 5,596
  • 16
  • 54
  • 104
1
vote
1 answer

Kitchen test failed: Sudo requires a password, please configure it on default-centos-67

This is content of default.rb recipe of my cookbook. include_recipe 'sudo' include_recipe 'chef-vault' group "#{node['cookbook']['group']}" do action :create append true system false end user 'user' do supports :manage_home…
1
vote
1 answer

What is the best way to run test in docker before deploying

My current settings is that I have set my git bare repository in my VPS call it staging. So, when I do: git push staging staging I rerun my docker with mounted directory refer to the git-workdirs. Now, I'd like to also add running the test inside…
Ramadoka
  • 352
  • 3
  • 25
1
vote
3 answers

How do I get log output in test kitchen?

I have this in my recipe: log mylog1 do level :info message 'WHY I NO SEE THIS?' end log mylog2 do level :info message 'WHY I NO SEE THIS?' end This is what I see when doing kitchen converge -l debug: ... Converging 3 resources Recipe:…
red888
  • 27,709
  • 55
  • 204
  • 392
1
vote
2 answers

How do I test cookbooks in test kitchen that depend on tags?

I have a cookbook that depends on a tag. It searches for nodes with a given tag and gets their names and IPs using search(:node, 'tag:MyTag'). How would I mock this up in test kitchen? Is there mock node objects I can use? It doesn't have to…
red888
  • 27,709
  • 55
  • 204
  • 392
1
vote
1 answer

kitchen.yml attributes not override default values - Chef 12.12 - Kitchen 1.10

I have a simple attributes file: attributes/default.rb. default['simpleattr'] = 'file value' And inside kitchen.yml, I do suites: - name: default run_list: - recipe[simple::default] attributes: simpleattr: 'value from…
OBender
  • 2,492
  • 2
  • 20
  • 33
1
vote
2 answers

test kitchen stuck on "creating virtual machine"

Running chefdk on Windows 10 with hyperv. I can use kitchen create to create Windows VMs and it works fine but I just tried a Linux VM and I'm getting this errror: PS> kitchen create -----> Starting Kitchen (v1.10.0) -----> Creating…
red888
  • 27,709
  • 55
  • 204
  • 392
1
vote
2 answers

How to provide a condition within Chef recipe to see if it running under test kitchen?

I am using encrypted data bags within Chef and I want to add a condition within my Chef recipe as follows: If (test kitchen) then encryptkey = data_bag_item("tokens", "encryptkey") If ( not test kitchen ) then secret =…
meallhour
  • 13,921
  • 21
  • 60
  • 117