Test-kitchen: how to test data driven recipes with databags?


#1

Ohai again!

is there currently a way to test recipes that are configured via databags?

There’s no chef.data_bags_path in the Vagrantfile:
https://github.com/opscode/test-kitchen/blob/master/config/Vagrantfile#L97-102

So I assume it’s not supported so far, unless someone can prove me wrong.

An easy solution would be to hava a databags dir alongside with the
cookbooks dir in the test kitchen and reference that in the
Vagrantfile, i.e.:
/test/kitchen/cookbooks
/test/kitchen/databags

It would get more tricky if you want to “override” a databag for a
specific configuration. Not sure how to handle this best, but
something like prefixing the databag with the configuration name or
having a subdirectory with configuration name come to my mind.

What do you think?

Cheers,
Torben

P.S.: will create a JIRA ticket for this, but want to discuss it here first


#2

Vagrant supports Data Bags, like so:

Vagrant::Config.run do |config|
config.vm.provision :chef_solo do |chef|
chef.data_bags_path = "data_bags"
end
end

I suspect since a lot of Opscode testing is done against chef-client
(and therefore server), this might have been overlooked for chef-solo.

-Mike

On Mon, Aug 20, 2012 at 4:21 AM, Torben Knerr ukio@gmx.de wrote:

Ohai again!

is there currently a way to test recipes that are configured via databags?

There’s no chef.data_bags_path in the Vagrantfile:
https://github.com/opscode/test-kitchen/blob/master/config/Vagrantfile#L97-102

So I assume it’s not supported so far, unless someone can prove me wrong.

An easy solution would be to hava a databags dir alongside with the
cookbooks dir in the test kitchen and reference that in the
Vagrantfile, i.e.:
/test/kitchen/cookbooks
/test/kitchen/databags

It would get more tricky if you want to “override” a databag for a
specific configuration. Not sure how to handle this best, but
something like prefixing the databag with the configuration name or
having a subdirectory with configuration name come to my mind.

What do you think?

Cheers,
Torben

P.S.: will create a JIRA ticket for this, but want to discuss it here first


#3

Hi Mike,

yes, that’s how it should look like.

Have created http://tickets.opscode.com/browse/KITCHEN-22 for this.

Cheers,
Torben

On Mon, Aug 20, 2012 at 12:44 PM, Mike miketheman@gmail.com wrote:

Vagrant supports Data Bags, like so:

Vagrant::Config.run do |config|
config.vm.provision :chef_solo do |chef|
chef.data_bags_path = "data_bags"
end
end

I suspect since a lot of Opscode testing is done against chef-client
(and therefore server), this might have been overlooked for chef-solo.

-Mike

On Mon, Aug 20, 2012 at 4:21 AM, Torben Knerr ukio@gmx.de wrote:

Ohai again!

is there currently a way to test recipes that are configured via databags?

There’s no chef.data_bags_path in the Vagrantfile:
https://github.com/opscode/test-kitchen/blob/master/config/Vagrantfile#L97-102

So I assume it’s not supported so far, unless someone can prove me wrong.

An easy solution would be to hava a databags dir alongside with the
cookbooks dir in the test kitchen and reference that in the
Vagrantfile, i.e.:
/test/kitchen/cookbooks
/test/kitchen/databags

It would get more tricky if you want to “override” a databag for a
specific configuration. Not sure how to handle this best, but
something like prefixing the databag with the configuration name or
having a subdirectory with configuration name come to my mind.

What do you think?

Cheers,
Torben

P.S.: will create a JIRA ticket for this, but want to discuss it here first