manish.rajkarnikar
manish.rajkarnikar

Reputation: 105

test-kitchen update instead of create every time

In test-kitchen, is there a way to update the instance created instead of destroying and recreating the instance every time? Say if I change in kitchen.yml and want to see that change, running the whole destroy/create can take a while.

Upvotes: 8

Views: 1907

Answers (3)

Alexandro de Oliveira
Alexandro de Oliveira

Reputation: 1359

As pointed by sethvargo you can use kitchen create even if your instance is already converged and the Vagrantfile would be recreated with changes made to your .kitchen.yml file.
Then you can:

cd .kitchen/suite_name && vagrant reload

and your vagrant instance would reflect those changes.

But be aware 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 your .kitchen/name-of-your-instance.yml file with those changes so you can kitchen login without problems.

Upvotes: 0

jlucasps
jlucasps

Reputation: 940

If you are using Vagrant, try the command vagrant global-status to get the machine id, then use it to reload. Something like this:

$ 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

Upvotes: 0

sethvargo
sethvargo

Reputation: 26997

Depending on the provider you are using - yes.

First, there are a few lifecycle steps:

  1. kitchen create - this will create the instance. It's the equivalent of vagrant up --no-provision.
  2. kitchen converge - this will converge (provision) the instance. It's the equivalent of vagrant provision.
  3. kitchen verify - this will run any post-integration tests (like ServerSpec or bats). There is no equivalent in vagrant.
  4. kitchen test - wraps the above three commands in a single sequence.

Test Kitchen does not have a notion of vagrant reload, which is what you seem to describe by your example. However, you can accomplish a reload by doing something like:

cd .kitchen/suite_name && vagrant reload

from the command line.

Upvotes: 8

Related Questions