Test Kitchen: Driver caching mechanism

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 downloads.chef.io.

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.

Posted in:

Salim Afiune

Salim is a Software Engineer at Chef based in New York City that have always been passionate about automation since his early years working for financial companies as a SysAdmin in México. He started as a Solutions Engineer helping many customers like Facebook, Bloomberg and GE among others. Nowadays you will find him coding with classical music in the background for inspiration. When he is not at his keyboard, you could find him in the kitchen cooking, playing ping pong or walking through the streets of Manhattan. He also enjoys outdoor activities like backpacking trips and snowboarding but what he can't live without is to travel all over the world.