2

I've been looking to see if there are any BDD's for servers, something that would be similar in respects to Cucumber or Behat? Something that has some syntactic sugar such as:

Feature: jre
  In order to use our monitoring software
  As a UNIX user
  I need to have JRE version at 8

  Scenario:
    Given I am in the directory "/usr/local/bin"
    And I have a file named "java" 
    When I run "java -version"
    Then I should get:
      """
      java version "1.8.*"
      """
ehime
  • 597
  • 2
  • 7
  • 15
  • 1
    Look into configuration management systems. I'm a big fan of Ansible for this sort of thing, but Puppet/Chef/Salt are common too. – ceejayoz Sep 14 '15 at 21:04
  • 2
    While I like the _idea_ of BDD, all that typing makes my wrists twitch... – Michael Hampton Sep 14 '15 at 21:25
  • @ceejayoz we already use puppet, it would just be for final pass verification, though we could do passes with puppet or ansible just to validate not install. – ehime Sep 14 '15 at 22:19
  • Or go the docker route. And the container will have everything you need. Of course, get familiar with the pro's and con's first. – hookenz Sep 15 '15 at 03:29
  • @Matt unfortunately dockers isn't something we can use atm – ehime Sep 15 '15 at 16:22

3 Answers3

3

It's not quite as "plain-text" as Cucumber, but serverspec (Ruby, RSpec-based) and testinfra (Python) both provide the ability to write specifications for your machines to validate they're in the state you want.

BTW, testing for your infrastructure is incredibly important, although not so much "run on every machine", but to validate that your configuration management is doing what you expect. Regressions are not uncommon, and knowing that a change to your manifests hasn't prevented a machine from being configured correctly is very reassuring.

It's surprisingly easy to make a change that stops, say, a package from being installed, which is something you will never find out until you go to build a new machine and the package doesn't appear, even though it's on all the other machines. Thus, get your infrastructure test suite integrated with your CI system, doing both incremental and clean (from-scratch) builds on every commit. Then, wave your test suite over the machines once they're built. This will validate that your configuration management is still doing everything it should be.

womble
  • 96,255
  • 29
  • 175
  • 230
1

I'm the author of testinfra, a tool to write infrastructure tests in python (based on pytest). All the testinfra features can be used outside of pytest through the API.

So if you have some skills in python you can plug testinfra with pytest-bdd or behave and achieve behavior driven infrastructure.

NB: As a new user I cannot post more that 2 links (awesome feature...)

  • Testinfra API: testinfra.readthedocs.org/en/latest/api.html
  • pytest-bdd: github.com/pytest-dev/pytest-bdd
  • behave: pythonhosted.org/behave/
philpep
  • 21
  • 1
-3

Mark Burgess has contributed a lot of research into this area:

http://markburgess.org/sysadmin.html

Specifically, take a look at http://cfengine.com, backed by his work.

circles
  • 1
  • 1