Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting Nagios part of this library to make it useful for development mode #39

Open
jeroenvandijk opened this issue Feb 1, 2011 · 7 comments

Comments

@jeroenvandijk
Copy link

Hi,

I have been in search for a library that can help me with the (behaviour driven) development of a system setup with Chef cookbooks. So far this library has been the best I have come accross, but it is not exactly what I want.

What I would like to do is test my Chef Recipes by describing the expected outcome in Cucumber features (like with Cucumber-Nagios), but instead of having to use a remote server and having integration with Nagios I would like to use Vagrant and just see whether my test pass or not. Later I would like to plug these tests into Cucumber-Nagios to reuse them for monitoring.

I'm guessing that we are almost there. I think it is just a matter of extracting the server connecting part (not remote, but localhost) and the output part (no Nagios but just plain Cucumber output). The step definitions and such are probably already in the form they should be.

In the near future I would like to work on this if you also agree that this would be a worthwhile expansion of the current library. WDYT?

Regards,

Jeroen

@auxesis
Copy link
Owner

auxesis commented Feb 1, 2011

Hoi,
Dat belooft wat! cucumber-nagios almost does exactly what you want out of the box right now.

I've been using cucumber-nagios for a few projects in the way you've described and it's worked out really well. It would be good to formalise this with some documentation and examples.

Currently you can run cucumber-nagios with the --pretty flag to get the nice output:

bin/cucumber-nagios features/site/blah.feature --pretty

I use this frequently when writing my scenarios.

You can skip over removing the server connecting part by just writing steps that can be executed locally. Adam Jacob from Opscode actually contributed a bunch of step definitions from Chef's test suite to cucumber-nagios a while back.

They should give you a good starting point for writing your own step definitions that can be run locally.

That said, I'm sure there a few rough edges and things that I've missed. Any contributions to cucumber-nagios you want to make would be really worthwhile.

How does that sound?

@jeroenvandijk
Copy link
Author

(Dutch, really? haha. Klinkt goed :) )

I'll look into the --pretty option. That might be good enough. I'll just start working with it and comment here as soon as I have something (re)usable :)

@auxesis
Copy link
Owner

auxesis commented Feb 1, 2011

(Mijn schoonvader komt uit Nijmegen :-) )

Sounds awesome. Let me know how you go!

@josephholsten
Copy link
Contributor

I'm adding tests to my chef/vagrant setup right now, I'm not sure I understand what features would make this more awesome.

I'm just running cucumber -r features features/vagrancy.feature and it works great.

I would totally love a good set of vagrant steps though.

@auxesis
Copy link
Owner

auxesis commented Feb 27, 2011

@josephholsten: is it possible to extract any of the Vagrant features/scenarios/steps out into re-usable bits for cucumber-nagios?

@josephholsten
Copy link
Contributor

I'm building my vagrant steps around aruba because it has better isolation than the file system steps from chef. But I certainly hope so. At the moment I'm making due with these steps:

Given /^a freshly built package "([^"]*)"/ do |package|
  When %{I run "vagrant destroy"}
  Given %{a Vagrantfile from package #{package}"}
  When %{I run "vagrant up"}
  Then %{the exit status should be 0}
  Then %{the output should contain "Chef Run complete"}
end

Given /^a provisioned package "([^"]*)"$/ do |package|
  Given %{a Vagrantfile from package "#{package}"}
  When %{I run "vagrant up"}
  When %{I run "vagrant provision"}
  Then %{the exit status should be 0}
  Then %{the output should contain "Chef Run complete"}
end

Given /^a Vagrantfile from package "([^"]*)"$/ do |package|
  use_vagrantfile(package)
end

def use_vagrantfile(package)
  run_simple("cp ../../packages/#{package}/Vagrantfile ./")
end

and I extend my timeouts and make sure to teardown in my env.rb:

[...]
require 'aruba/cucumber'

Before do
  @aruba_timeout_seconds = 750
end

at_exit do
  include Aruba::Api
  run_simple('vagrant destroy')
end

The best extraction would probably migrating to aruba for command line steps. Unfortunately, they collide with the ssh steps (which so useful!) at the moment, so there isn't a straightforward migration path.

@hedgehog
Copy link
Collaborator

Auxesis asked me to take over CN.
I've refacored CN to use Aruba:
https://github.com/hedgehog/cucumber-nagios
and also started extracting steps to an Aruba style gem for CN, the a cuken gem:
https://github.com/hedgehog/cuken

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants