4

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!

Matthew J Morrison
  • 4,343
  • 3
  • 28
  • 45
  • Did you find out how to do it ? I tried answer below (nothing), I tried special recipe that includes default twice (nothing). In both case run_list is merge or resources are merge. – Lukino Jun 17 '15 at 16:39
  • I found workaround for my case. I am using 'special script' where I am running specific kitchen job in sequence. So in my case, script will: `destroy`, `create`, `converge`, `converge`, `verify` and `destroy` - destroy – Lukino Jun 17 '15 at 16:44
  • @Lukino I was able to get the suggested solution to work. – Matthew J Morrison Jun 17 '15 at 21:16
  • unfortunately I wasn't (see comments below). Maybe it is weird setup (too much gems around this) Anyway, [TestKitchen 2.0](https://github.com/test-kitchen/test-kitchen/issues/162) should have this be default without any dirty hacks – Lukino Jun 18 '15 at 11:55

3 Answers3

4

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

Roland
  • 1,426
  • 9
  • 9
  • Your complain neither provided a version number of test-kitchen nor the driver you were using. – Roland Jun 17 '15 at 20:29
  • well, you added version just now. i am not complaining just trying to figure out why it is not working as I remember that it was. I will update version tomorrow. – Lukino Jun 17 '15 at 23:08
  • You claimed my solution was not working. It's your turn to deliver information/proof… – Roland Jun 18 '15 at 09:41
  • I had version TK 1.3.1 and KV 0.16.0. After updating to version edited 13h ago, Following `- name: SSHAccess-2x-run data_bags_path: "test/integration/SSHAccess/data_bags" run_list: - recipe[ssh_access::default] attributes: {} - name: SSHAccess-2x-run data_bags_path: "test/integration/SSHAccess/data_bags" run_list: - recipe[ssh_access::default] attributes: {}` won't run converging twice when running `kitchen test SSHAccess-2x-run`. Driver=Vagrant, Provider=libvirt. I can't do more thorough check why right now. I will return to this later – Lukino Jun 18 '15 at 10:00
3

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
Jeff Coe
  • 482
  • 3
  • 18
1

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.

RajaV
  • 11
  • 2