如何才能使测试厨房多次运行相同的厨师食谱? [英] How can I get test kitchen run same chef recipe multiple times?
问题描述
我有一个用于部署应用程序的厨师食谱。每次运行配方时,它都会创建一个新的 release目录(带有当前时间戳),并删除较旧的 release目录,仅保留5个最新的 release目录。 (类似于Capistrano的keep_releases的工作原理。)
I have a chef recipe that I'm using for deploying an application. Each time the recipe runs it creates a new "release" (with the current timestamp) directory and deletes older "release" directories leaving only the 5 most recent "release" directories. (similar to how Capistrano's keep_releases works).
要测试该功能,我需要运行部署配方6次并验证是否只有5个 release目录。似乎我不能多次在run_list中使用相同的配方。
To test that functionality I need to run my "deploy" recipe 6 times and verify that there are only 5 "release" directories. It seems that I am not able to have the same recipe in the run_list more than once.
任何想法吗?
谢谢!
推荐答案
2019年更新:使用 multiple_converge
如 https://docs.chef.io/config_yml_kitchen.html 中所述
Update 2019: use multiple_converge
as described in https://docs.chef.io/config_yml_kitchen.html
旧解决方案:
您可以使用重复的套件名称来收敛节点两次(或更多次)。
You can use duplicate suite names to converge a node twice (or more times).
例如在您的.kitchen.yml中运行两次默认套件:
e.g. in your .kitchen.yml to run the "default" suite twice:
suites:
- name: default
run_list:
- recipe[your-cookbook::recipe]
attributes:
- name: default
run_list:
- recipe[your-cookbook::recipe]
attributes:
但是也许您想使用 ChefSpec 对其进行测试,而不必每次都收敛一个节点。
However maybe you want to use ChefSpec to test it without having to converge a node each time.
这篇关于如何才能使测试厨房多次运行相同的厨师食谱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!