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

Clone aws codecommit repo using chef

How can i clone aws codecommit repo with chef recipe? I tried installing AWS CLI and added credentials with codecommit access, then use chef’s git resource to clone the repo. but it fails with could not read Username for…
Vishnu Prassad
  • 333
  • 1
  • 3
  • 12
0
votes
1 answer

How to read test data when running test-kitchen during Chef converge

I have a recipe that updates the Splunk /opt/splunkforwarder/etc/system/local/inputs.conf file with single entry for meta data that needs to be added to the events that are being forwarded to the indexers. This meta data entry is a nine character…
user3481957
  • 151
  • 1
  • 1
  • 10
0
votes
1 answer

Error while loading modules in test-kitchen

I am new to test kitchen and i am trying to use the existing vpc modules i have created earlier using terraform. I am having problems on loading the modules to test kitchen. My folder structure looks like tf_aws_cluster ├── .kitchen.yml ├──…
user6826691
  • 1,813
  • 9
  • 37
  • 74
0
votes
1 answer

chef recipe - replace text in Linux file with sed command (receiving errors)

I am using the following code in a chef recipe: bash 'replace_text' do cwd ::File.dirname('/data01/nodemanager/bin') code <<-EOH sed 's/NODEMGR_HOME=.*/NODEMGR_HOME="\/data01\/nodemanager"/g' startNodeManager.sh EOH end The…
aphexlog
  • 1,503
  • 3
  • 16
  • 43
0
votes
1 answer

InSpec + TestKitchen: How to execute command on behalf of specific user?

My Chef cookbook installs Ruby locally for specific user. I want to write an InSpec test that checks if specific version of Ruby is available and if gems are installed without documentation. So obviously I somehow need to run commands on behalf of…
Kirill
  • 6,762
  • 4
  • 51
  • 81
0
votes
1 answer

What is the purpose of .kitchen.yml file in the root of project generated by 'chef generate app'?

I have an old single repo of cookbooks intended for creating a complete development environment with Vagrant. I want to "refactor" it according to best practices. I want to split big cookbooks, make proper wrapper cookbooks of community cookbooks…
Kirill
  • 6,762
  • 4
  • 51
  • 81
0
votes
1 answer

Integration Testing with Kitchen CI

I have cookbooks to deploy infrastructure to azure cloud. My cookbooks create required VMs, setup SQL Servers, attach disks to VM and some software installation. I want that Kitchen CI itself: Verify that my resources have spawned correctly or…
0
votes
1 answer

Is there a better way to update my guest port number without recreating kitchen instance?

Below is my kitchen.yml --- driver: name: vagrant provisioner: name: chef_zero # You may wish to disable always updating cookbooks in CI or other testing environments. # For example: # always_update_cookbooks: <%= !ENV['CI'] %> …
shalamus
  • 2,192
  • 1
  • 12
  • 8
0
votes
0 answers

Chef fails to install Microsoft Office when I run Kitchen converge but completes without any errors

I have a MSOffice 2016 pro plus setup.exe in the chef node. I am trying to install it via PowerShell in my recipe. The kitchen converge succeeds but fails to install office. The test kitchen instance is windows2012. The install resource I used in…
0
votes
1 answer

Access JSON values using Chef and test-kitchen

I'm new to Chef and Test-kitchen and I'm trying to use random JSON file as attribute or environment (preferably attribute), but unfortunately I can't access the JSON values from the recipes. I'm using the following directory structure: uat ├──…
user3283749
  • 21
  • 1
  • 5
0
votes
1 answer

Chef Kitchen Converge: Installing apache2 on Ubuntu fails

Setup I face some strange problems with chef test-kitchen. I use a very basic case, where I try to install and run Apache on 2 platforms. driver: name: vagrant provisioner: name: chef_zero always_update_cookbooks: true verifier: name:…
tstuber
  • 352
  • 2
  • 14
0
votes
1 answer

Chef Verify Error windows

i am trying to kitchen test C:/opscode/chefdk/embedded/lib/ruby/gems/2.4.0/gems/chef-provisioning-aws-2.2.2/lib/chef/resource/aws_route53_record_set.rb:48: warning: constant ::Fixnum is deprecated
0
votes
1 answer

Kitchen .kitchen.yml multiple-line environment variable

With Kitchen I am trying to define an attribute with a multiple-line environment variable using .kitchen.yml such as : attributes: foo: ssh: key_private: <%= ENV['CHEF_SSH_KEY_PRIVATE'] %> The multi-line CHEF_SSH_KEY_PRIVATE variable…
Pierre B.
  • 11,612
  • 1
  • 37
  • 58
0
votes
1 answer

Test Kitchen struck on the SSH loop while using docker driver on a centos machine

I am writing a cookbook for installing a lamp stack with docker as driver for the test kitchen. when i use kitchen create command, it is getting stuck on SSH loop. --- driver: name: docker privileged: true use_sudo: false provisioner: name:…
0
votes
1 answer

Unable to execute kitchen create on vagrant(Centos7)

I am trying to execute kitchen create command on Centos7 but below is the message shown, updated the virtual box location on environment variables but still I have seen the below error, can someone please advise. Thank you. Creating... The Provider…
sam
  • 77
  • 2
  • 11