How can I get test kitchen run same chef recipe multiple times?

北城以北 提交于 2019-12-10 21:16:17

问题


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).

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.

Any ideas?

Thanks!


回答1:


Update 2019: use multiple_converge as described in https://docs.chef.io/config_yml_kitchen.html

Old solution:

You can use duplicate suite names to converge a node twice (or more times).

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:

However maybe you want to use ChefSpec to test it without having to converge a node each time.

Tested with test-kitchen 1.4.0 + kitchen-vagrant 0.18.0




回答2:


There is an option within the provisioner in Test Kitchen now which allows you to run multiple converges.

The provisioner configuration below will tell Chef to converge 3 times:

provisioner:
  name: chef_zero
  product_name: chef
  deprecations_as_errors: true
  multiple_converge: 3



回答3:


If you use kitchen dokken to test your cookbook, you can simply do 'kitchen converge' again once the node is converged. It is simillar to running chef-client again on converged node.



来源:https://stackoverflow.com/questions/30386630/how-can-i-get-test-kitchen-run-same-chef-recipe-multiple-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!