Yet another one approach to test infrastructure with chef and cucumber

107 views
Skip to first unread message

Igor Afonov

unread,
Mar 21, 2012, 12:05:24 PM3/21/12
to chef-t...@googlegroups.com
Hi all,

I've reinvented the wheel again and created the cookbook that provides ability to verify and test infrastructure setup using cucumber and aruba. You can find more or less complete description in the cookbook readme file here - https://github.com/iafonov/simple_cuke. It could be used as a tool to support BDD style in development of your infrastructure and as a regression testing tool.

This is very young project (it was created yesterday:) so you can consider it as early preview but I already use it in production system. 

The main idea behind this project - is to keep things it as simple as possible. Main problem that I see in projects like cucumber-chef/cuken etc. is their sometimes overkill complexity and limitations. Chef itself is quite complex thing but this things as for me make things even more complex. (At the same time I understand that they do a little bit different thing and they are still could be perfect choice under some circumstances)

I'd be glad to get any feedback on it from you.

Thanks!

Stephen Nelson-Smith

unread,
Mar 22, 2012, 5:40:26 AM3/22/12
to chef-t...@googlegroups.com
Hi Igor,


On Wednesday, 21 March 2012 16:05:24 UTC, Igor Afonov wrote:
Hi all,

I've reinvented the wheel again and created the cookbook that provides ability to verify and test infrastructure setup using cucumber and aruba. You can find more or less complete description in the cookbook readme file here - https://github.com/iafonov/simple_cuke. It could be used as a tool to support BDD style in development of your infrastructure and as a regression testing tool.

That looks interesting.  I'll definitely have a play with it.  Thanks for sharing!

S.

Igor Afonov

unread,
Mar 23, 2012, 6:58:56 AM3/23/12
to chef-t...@googlegroups.com
I wrote a blog post with more or less complete description of my approach to testing - http://iafonov.github.com/blog/pragmatic-infrastructure-testing-with-cucumber.html

Comments are welcome

Thanks 

Bryan Berry

unread,
Mar 23, 2012, 8:40:48 AM3/23/12
to Igor Afonov, chef-t...@googlegroups.com
Zdracte Igor!

I am looking through your excellent docs and have a few questions

simple_cuke  runs the step definitions in the following path
files/default/suite/features 

However, it isn't clear to me if all my step definitions go into the `simple_cuke` cookbook or if I put my step_definitions into the cookbook I am trying to test. For example if I want to test my apache cookbook, do the tests go into cookbooks/apache/files/default/suite/features or cookbooks/simple_cuke/files/default/suite/features?

I assume they go into the apache cookbook but I don't see any code in simple_cuke that would collect the step_definitions from other cookbooks besides simple_cuke. Perhaps I am missing something.

Perhaps this code collects the step definitions?
` bundle exec cucumber --tags #{roles_tags}"`

Next, do you happen to have any public cookbooks that use simple_cuke that we can reference as examples? 

Also, if you ever want to rename simple_cuke, I think that yabloko (яблоко) would be an awesome name ;)

--
You received this message because you are subscribed to the Google Groups "chef-testing" group.
To view this discussion on the web visit https://groups.google.com/d/msg/chef-testing/-/uEh4x35_NqoJ.

To post to this group, send email to chef-t...@googlegroups.com.
To unsubscribe from this group, send email to chef-testing...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/chef-testing?hl=en.

Igor Afonov

unread,
Mar 26, 2012, 8:41:33 AM3/26/12
to chef-t...@googlegroups.com, Igor Afonov
Hi Bryan,

I've never thought of this tool as a tool for testing separate cookbooks, but it doesn't mean that it is impossible.

For now I use this cookbook as a centralized set of features that describe the whole infrastructure and not specifics of a separate cookbook.

I thought about how you can use this cookbook to store and test separate features - and I think that potentially this cookbook could expose LWRP that would copy features from cookbook under test to features folder which would be executed after chef-client run. But I don't know whether it could be a good solution.

P.S: I'll definitely pick yabloko as a name for my next open source project:)

--
Igor
To unsubscribe from this group, send email to chef-testing+unsubscribe@​googlegroups.com.

Bryan Berry

unread,
Mar 30, 2012, 3:04:29 AM3/30/12
to Igor Afonov, chef-t...@googlegroups.com
This cookbook from btm appears to collect minitest  tests and run them at them at then end of a successful chef run

the code btm uses to collect the tests is ridiculously simple

# Search through all cookbooks in the run list for tests
node[:recipes].each do |recipe|
  # recipes is actually a list of cookbooks and recipes with :: as a delimiter
  cookbook_name = recipe.split('::').first
  remote_directory "tests-#{cookbook_name}" do
    source "tests/minitest"
    cookbook cookbook_name
    path "#{node[:minitest][:path]}/#{cookbook_name}"
    purge true
    ignore_failure true
  end
end


Conceivably it could be used to collect simple_cuke tests from multiple cookbooks and then process them at the end of the chef run.

This would be extremely useful as a `smoketest` to run after provisioning a bunch of new servers

To view this discussion on the web visit https://groups.google.com/d/msg/chef-testing/-/YHfdwil64g4J.

To post to this group, send email to chef-t...@googlegroups.com.
To unsubscribe from this group, send email to chef-testing...@googlegroups.com.

Igor Afonov

unread,
Mar 30, 2012, 5:03:16 AM3/30/12
to chef-t...@googlegroups.com, Igor Afonov
Hi Bryan,

Thanks for your feedback!

At first sight the idea of collecting features from cookbooks seemed for me too complex and not so useful (as I stated before I've created this cookbook to be a central repository + runner of features that describe the whole infrastructure setup) - but after your email I decided to give it a try again and it worked very well! :)

Today I've spent some time and added ability to collect features from cookbooks (they are copied from [cookbook]/files/features folder) and cleaned-up the code using foodcritic. I've bumped version of cookbook - so I think today I'd have a release party:)

By the way Bryan - if you'd have any ideas you can fork repo (https://github.com/iafonov/simple_cuke) and issue pull request or just send me a PM and I would fetch your changes. I really interested in further development of this project. 

Thanks again,
Igor

Bryan Berry

unread,
Mar 30, 2012, 5:11:56 AM3/30/12
to Igor Afonov, chef-t...@googlegroups.com
tks igor,

i fully intend to try it out. I fear that once I get started I will disregard all my other work for several days ;)

just curious how is simple_cuke different from cuken? 

To view this discussion on the web visit https://groups.google.com/d/msg/chef-testing/-/ti1Vhup1TbgJ.

To post to this group, send email to chef-t...@googlegroups.com.
To unsubscribe from this group, send email to chef-testing...@googlegroups.com.

Igor Afonov

unread,
Mar 30, 2012, 6:16:19 AM3/30/12
to chef-t...@googlegroups.com, Igor Afonov
The main difference is its simplicity. Simple_cuke is just a drop-in chef cookbook with minimal dependencies. You just add it to your chef repo and you're ready to start writing tests. The thing that pushed me to creating a new tool from scratch was obscure documentation of projects like cuken/cucumber-chef etc. when I started to research them I understood that they are too complex for me and they don't fit into my brain.

By the way - if I understand correctly (I haven't tried it) if you want to use cuken you can add it to Gemfile and require it in simple_cuke/files/suite/features/env.rb - and you would be able to use steps from it. For now I didn't have any need in steps beyond provided by aruba and a small set of my own custom steps.

--
Igor
Reply all
Reply to author
Forward
0 new messages