0

When using vagrant machines with test-kitchen the pre_create_command allows you to specify a command which is run locally before the vagrant machine is being created. With kitchen-docker no such configuration option seems to exist, and bending chef_omnibus_url as suggested here isn't an option.

The script specified as pre_create_command for the testing vagrants generates a local chef data bag.

Is there a solution around which I've overlooked?

trish
  • 1
  • 3

3 Answers3

0

Best practices include Rakefile and Thor.

In essence you control your tests from a Rakefile. For example:

rake style

This will run all commands under your style task (maybe lint/syntax/unit and kitchen tests). Of course you can modify your tasks to perform whatever you like. Here are some good resources:

https://blog.chef.io/2015/04/21/overview-of-test-driven-infrastructure-with-chef/

See the Supporting Tools and Dependencies section.

Here is an example Rakefile:

https://github.com/chef-cookbooks/chef-server/blob/master/Rakefile

thun
  • 478
  • 3
  • 12
  • This isn't really related. – coderanger Dec 21 '16 at 02:10
  • Thanks for answering, but I don't think the answer fits my problem since I am talking of a singular kitchen test, not a complete test chain. – trish Dec 21 '16 at 10:14
  • I do not know what your use case is, however, if you are trying to do some sort of logic PRIOR to the kitchen converge run a Rakefile works great. You do not need to run a 'suite' of tests. It can be simple a call to the shell script you described and a call to kitchen converge. Since it's just ruby/rake it's 100% flexible. – thun Dec 21 '16 at 17:53
0

I sketched a patch for kitchen-docker here. However, as the discussion on this pull request shows, there are arguments against an appropriate functionality in kitchen-docker, namely the one that such functionality (if ever) should go in the kitchen core.

So for the time being we have to live with this inconsistency between docker and vagrant, and this is where thun's answer comes into play.

trish
  • 1
  • 3
0

This can be done using

driver_config:
  provision_command: <command>

in kitchen.yml

Check more here

Kr,

Rshad

Rshad Zhran
  • 496
  • 4
  • 17