Wednesday, January 4, 2017

Test Kitchen: Driver caching mechanism [feedly]

Test Kitchen: Driver caching mechanism

-- via my feedly newsfeed

I'm happy to announce a new driver caching mechanism for Test Kitchen. You can use it with provisioners to cache downloads and other files between provisions.

For people who use the kitchen-vagrant driver to run Chef, we've introduced local caching of the chef-client packages. As a result, this change cuts as much as 3 minutes per VM from the typical Kitchen run!

In Test Kitchen 1.14.0, test-kitchen will automatically cache downloaded chef-client packages for use between provisions. By using the new cache directory, the kitchen-vagrant driver will automatically share those client packages to the guest VM, meaning that you no longer have to wait for the client to download on every guest provision.

In addition, if the chef-client packages are already cached, it is now possible to use test-kitchen completely off-line.

This improvement is available on the latest ChefDK release version 1.1.16 – you can download it from

How can I enable the caching functionality in my driver?

We have introduced a new interface called cache_directory that any driver can implement to inform the Provisioner abstractions that it can leverage it. The only driver that is taking advantage of this functionality at the moment is kitchen-vagrant, but we would like others to implement it as well.

The idea behind this cache directory is that the driver will have to take care of making it accessible to the Guest VMs, whether it is a shared folder, a S3 bucket, SMB volume or any other mechanism and then indicate what is the path of the directory by implementing the interface as follows:

def cache_directory    windows_os? ? "C:\\cache" : "/tmp/cache"  end

You can see an example of this implementation in Pull Request #248.

If you have any questions or problems with this new functionality please reach out to us on Chef Community Slack.

The post Test Kitchen: Driver caching mechanism appeared first on Chef Blog.