[chef-dev] Re: Guidance on Ohai Plugin Test

Chronological Thread 
  • From: Ranjib Dey < >
  • To: David Petzel < >
  • Cc: Chef Dev < >
  • Subject: [chef-dev] Re: Guidance on Ohai Plugin Test
  • Date: Tue, 6 May 2014 13:12:26 -0700

do you want to test only the plugin ? or the plugin as part of the whole chef run?

You can tell chefspec to execute a  provider body (i.e. step_into => ['ohai_plugin']), but this can be risky if you dont know what the provider does (i have not used ohai_plugin, i only used step_into with our own lwrps.
you can also use test-kitchen (or even chef metal and serverspec)  to do this safely ,

i run linux and i test all such scenarios using raw lxc. if i want to test an individual plugin i would do this:
1. spawn an lxc container
2. load ohai on host (including your plugin.. ohai 7 simplifies this) 
3, fork inside lxc,  and run pluguin, return the ohai data as json (IPC)
4. assert against the return data on host

as you can see, this wont let you test cross platform stuff.

On Tue, May 6, 2014 at 12:30 PM, David Petzel < " target="_blank"> > wrote:
Hey Folks,
I have a cookbook which contains an Ohai plugin. In a nutshell the plugin leverages some Ohai attributes related to networking to make some decisions about its locations in our environment. From those decisions it populates some additional attributes. (pretty simple).

The plugin works, however I need to make some adjustments so I am attempting to back fill some testing before I get started. I'm a little stumped on how to do this, and I can find any test examples outside of the Ohai project itself.

I was hoping to leverage Chefspec to do the testing, however I can't figure out how to tell Chefspec to "go run this ohai plugin". I had thought I could just add the plugin call somehow in my before block, but I can't seem to figure out the right syntax.

Does anyone have an example, or guidance on how I can/should add these types of tests?

Archive powered by MHonArc 2.6.16.