在测试厨房中,有没有办法更新创建的实例,而不是每次都销毁和重新创建实例?假设我在 kitchen.yml 中进行了更改并希望看到该更改,运行整个销毁/创建可能需要一段时间。
3 回答
Depending on the provider you are using - yes.
First, there are a few lifecycle steps:
kitchen create
- this will create the instance. It's the equivalent ofvagrant up --no-provision
.kitchen converge
- this will converge (provision) the instance. It's the equivalent ofvagrant provision
.kitchen verify
- this will run any post-integration tests (like ServerSpec or bats). There is no equivalent in vagrant.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.
如果您正在使用 Vagrant,请尝试使用该命令vagrant global-status
获取机器 ID,然后使用它重新加载。像这样的东西:
$ 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
正如 sethvargo 所指出的,kitchen create
即使您的实例已经融合,并且 Vagrantfile 将通过对 .kitchen.yml 文件的更改重新创建,您也可以使用。
那么你也能:
cd .kitchen/suite_name && vagrant reload
并且您的 vagrant 实例将反映这些更改。
但请注意,在某些情况下,当您重新加载实例时,ssh 端口号可能会更改。在这种情况下,您可以使用vagrant port
这些更改来查看更改并修复 .kitchen/name-of-your-instance.yml 文件,这样您就可以kitchen login
毫无问题地进行操作。