Giter Site home page Giter Site logo

simple_cuke's Introduction

simple_cuke

Description

This chef cookbook provides dead simple way to test and verify node's setup after chef run using cucumber and aruba. Unlike similar tools it's designed to be fully understood and ready to use in less then 5 minutes by the average developer.

It could be used as a tool to support BDD style in development of your infrastructure and as a regression testing tool.

Requirements

Cookbook depends on Opscode's chef_handler cookbook. (Run knife cookbook site install chef_handler to install it)

There are no additional limitations on environment. You can use it with any kind of chef (hosted/private/solo).

Attributes

  • node["simple_cuke"]["suite_path"] - Location for the test suite on the target node (/var/chef/handlers/suite by default)

Usage

  1. Install this cookbook to your chef repo. (git clone git://github.com/iafonov/simple_cuke.git cookbooks/simple_cuke)
  2. Add recipe[simple_cuke] to run_list
  3. Start writing cucumber features and place them in files/default/suite/features folder
  4. Run chef-client and enjoy

How it works

After each chef-client run a set of cucumber features is executed on a target node. As simple as it is. No black magic involved*.

Running role specific features

Add role name as tag to the scenario or feature and it would be run only on nodes that have this role. Features/scenarios without tags would be run always.

Aruba

The cookbook will automatically install and link aruba gem for you. Aruba is a set of handy cucumber steps that are intended to test command line applications and test manipulation with file system - this is exactly what is needed during verification of infrastructure setup. I recommend you to quickly go through provided steps definitions to prevent reintroducing already available steps. You can see the complete definitions list here.

Custom steps

There are no restrictions - you can use your own defined steps. Put the step definitions into features/step_definitions/[younameit]_steps.rb file and they would be loaded automatically.

Examples

Simple example - check that Apache is running:

@appserver
Feature: Application server

Scenario: Apache configuration check
  When I successfully run `ps aux`
  Then the output should contain "apache"

Slightly more advanced example: check services are running, bind to their ports and aren't blocked by firewall:

@base
Feature: Services

Scenario Outline: Service should be running and bind to port
  When I run `lsof -i :<port>`
  Then the output should match /<service>.*<user>/

  Examples:
    | service | user     | port |
    | master  | root     |   25 |
    | apache2 | www-data |   80 |
    | dovecot | root     |  110 |
    | mysqld  | mysql    | 3306 |

Scenario Outline: Service should not be blocked by firewall
  When I run `ufw status`
  Then the output should match /<service>.*<action>/

  Examples:
    | service | action |
    | OpenSSH |  ALLOW |
    | Apache  |  ALLOW |
    | Postfix |  ALLOW |

How it works (in details)

The idea behind implementation is to be as simple and straightforward as possible. The workflow consists of the following three steps:

  1. Default recipe synchronizes the files/default/suite cookbook's folder with remote node via calling remote_directory LWRP.
  2. Chef handler is registered.
  3. When handler is executed it installs the bundle (it consists of cucumber & aruba) and runs cucumber features.

For now reporting is done only to console.

© 2012 Igor Afonov

simple_cuke's People

Contributors

iafonov avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.