Pergunta

I saw most of the community cookbooks have tests. As I read some articles those tests can be, simply put, described as unit tests (does the cookbook does what it says?) and integration tests (does it work on the OS?).

I setup a LAMP virtual environment using Vagrant and Chef community cookbooks. Now I would like to test it.

First I thought I am gonna run all the community's integration tests using Kitchen CI on my provisioned system. I thought that's one of the reasons the creators write those integration tests, so admins can put all the tests together and test their system. However after a small research I found out the ways the cookbooks are tested differ, so it doesn't seem easy to simply run all of them at once on my system.

Does that mean I should write tests on my own? For example using Kitchen CI and serverspec. I guess they doesn't need to be very fancy, because the community cookbooks are tested, but I still feel it would be a good idea to check if services are running and configuration files present.

What is the common workflow? Write a few tests on your own? Or just "believe" in the community cookbooks? Or there is a way to run the community's tests all together after the OS is provisioned?

Foi útil?

Solução

One way is to use the minitest-handler cookbook. If this cookbook is included in your run, then all minitest tests present in files/default/tests/ are executed at the end of your run, and the Chef run either fails if tests fail, or succeeds if all tests passed.

Then on top of the community tests, you add some specific tests to your service in your application-cookbook.

However, I have been noticing a lack of minitest tests, and more and more people using ServerSpec. From my brief investigation, running tests on your machine during a chef run is not something that you do using ServerSpec.

Outras dicas

You could write tests just for your cookbook and to ensure the services are running correctly that your application requires.

For example, if you are using Apache you could use ServerSpec to ensure that the Apache server is running and serving content.

This would test that your application/wrapper cookbook installed all of the resources along with the resources you expect the community cookbooks to install.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top