Does Behaviour Driven Development have a role in the infrastructure world? Enter Behaviour Driven Infrastructure where systems administrators can apply some simple open source tools and BDD principles to make infrastructure management more powerful, more insightful and deliver more value to their customers.
The typical enterprise monitoring and configuration management set-up for a website is:
- Is the Apache package installed and the appropriate version?
- Is the Apache service running?
- Can I connect to the HTTP port and is HTML returned?
- Multiply this by a few hundred iterations of hosts and types of services and you’re probably looking at your typical Nagios, Puppet, Cfengine, Hyperic set-up.
All this monitoring misses something critical though – we’re not actually monitoring that the service does what it should. Yes, it matters whether Apache is installed, the Apache service is running, and you can connect to HTTP but does this actually prove anything about the availability of the service we’re managing and providing for our customers? Nope…
We need to demonstrate more than just a check that says the Apache server is up. We need to demonstrate that the service delivered by that infrastructure was available to our customers AND functioning as intended.
Enter Behaviour Driven Infrastructure or BDI which applies the principles of Behavioural Driven Development to the management of infrastructure. In this presentation you’ll learn:
- How Behaviour Driven Development works
- What makes a behavioural test
- How to install and use Cucumber to perform BDI
- Practical examples of behavioural tests in Cucumber, and
- How to integrate BDI into your work flow and your enterprise monitoring and configuration management frameworks.
66. Feature: Google search
To increase her knowledge
A user
Needs a search interface
To discover information
Scenario: Home page
When I visit "http://google.com.au/"
And I fill in "q" with "great balls of fire"
Then I should see "great balls of fire"
75. Feature: Google search
To increase her knowledge
A user
Needs a search interface
To discover information
Scenario: Home page
When I visit "http://google.com.au/"
And I fill in "q" with "great balls of fire"
Then I should see "great balls of fire"
76. When /^I visit "([^"]*)"$/ do |location|
# code
end
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |input, value|
# code
end
Then /^I should see "([^"]*)"$/ do |string|
# code
end
77. When /^I visit "([^"]*)"$/ do |location|
visit(location)
end
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |input, value|
fill_in(input, :with => value)
end
Then /^I should see "([^"]*)"$/ do |string|
response.body.should match(string)
end
91. write test
run test
refactor
test fails
make test pass
92. $ apt-get install rubygems
$ gem install cucumber
$ mkdir -p project/features/steps
$ cd project
$ vim features/site.feature
93. Feature: Google search
To increase her knowledge
A user
Needs a search interface
To discover information
Scenario: Home page
When I visit "http://google.com.au/"
And I fill in "q" with "great balls of fire"
Then I should see "great balls of fire"
94. $ apt-get install rubygems
$ gem install cucumber
$ mkdir -p project/features/steps
$ cd project
$ vim features/site.feature
$ cucumber features/site.feature
$ vim features/steps/site_steps.rb
95. $ apt-get install rubygems
$ gem install cucumber
$ mkdir -p project/features/steps
$ cd project
$ vim features/site.feature
$ cucumber features/site.feature
$ vim features/steps/site_steps.rb
$ cucumber features/site.feature