Updating the test kitchen instead of creating it every time

In the test kitchen, is there a way to update the created instance instead of destroying and re-creating the instance each time? Let's say if I change in kitchen.yml and want to see this change, launching the whole destroy / create may take some time.

+7
chef test-kitchen
source share
3 answers

Depending on the provider you use, yes.

Firstly, there are several stages of the life cycle:

  • kitchen create - this will create an instance. This is equivalent to vagrant up --no-provision .
  • kitchen converge - this brings together an instance. This is equivalent to vagrant provision .
  • kitchen verify - any tests will be performed after integration (for example, ServerSpec or bit). There is no equivalent in a tramp.
  • kitchen test - wraps the above three commands in one sequence.

Test Kitchen has no concept of vagrant reload , which you seem to describe in your example. However, you can reboot by doing something like:

 cd .kitchen/suite_name && vagrant reload 

from the command line.

+5
source share

If you are using Vagrant, try running the vagrant global-status command to get the machine ID, and then use it to reboot. Something like that:

 $ vagrant global-status 42c66e1c default virtualbox poweroff /path/to/your/machine/kitchen-vagrant/webserver-ubuntu-1404 1c135a2e default virtualbox running /path/to/other/machine/.kitchen/kitchen-vagrant/kitchen-machines-webserver-ubuntu-1404 $ vagrant reload 1c135ae --provision 
0
source share

As sethvargo pointed out, you can use kitchen create even if your instance already converges and the Vagrantfile will be recreated with the changes made to your .kitchen.yml file.
Then you can:

 cd .kitchen/suite_name && vagrant reload 

and your stray instance will reflect these changes.

But keep in mind that in some cases when you reload your instance, the ssh port number may change. In this case, you can use vagrant port to see the changes and fix the .kitchen / name-of-your-instance.yml file with these changes so that you can kitchen login without any problems.

0
source share

All Articles