+
MICHAEL RICHARDSON - @M_RICHO
Testing and Monitoring
Collide
WHAT IS IT?
RSpec Tests for checking your servers are
configured correctly
CM/PROVISIONING TOOL AGNOSTIC
CM/PROVISIONING TOOL AGNOSTIC
SERVERS CAN BE BUILT USING
• CHEF
• PUPPET
• CF-ENGINE
• ANSIBLE
• POWER SHELL
• SHELL SCRIPTS
• MANUAL HACK
• WHAT EVER.
26 RESOURE TYPES INCLUDING
• COMMAND
• DEFAULT_GATEWAY
• FILE
• GROUP
• HOST
• INTERFACE
• IPTABLES
• KERNEL_MODULE
• PACKAGE
• PORT
• PROCESS
• SERVICE
• USER
• WINDOWS_REGISTRY_KEY
That’s super fast
WHEN TO RUN SERVERSPEC TESTS?
??
WHEN TO RUN SERVERSPEC TESTS?
That’s super useful
• When developing config management code (eg
puppet/chef)
• When validating a node or environment
WHEN TO RUN SERVERSPEC TESTS?
Hell yeah. That’s a
great idea.
• What about every 2 minutes on all hosts via your
monitoring tool
WHY?
• Fast
• Lightweight
• Overlaps with traditional monitoring checks
• Simplifies monitoring tool config
WE USE SENSU FOR MONITORING
It’s
• Simple
• Extensible
• Lightweight
• Simple to install on linux and windows.
• blah…
• blah…
ITERATION 1+
GET SENSU TO JUST RUN THE RSPEC TESTS
ITERATION 1+
RSpec stdout isn’t great to simply pass back to a
monitoring tool.
ITERATION 1+
SURE, WE CAN TIDY UP RSPEC STD OUT
But now have no idea which tests are failing 
2 USEFUL FEATURES TO THE RESCUE
1. Rspec JSON output format
2. Sensu-Client has a local socket to
accept check results
RSPEC JSON OUTPUT
4 example
tests
Summary
results
SENSU CLIENT SOCKET
Send results here
Failures appear here
ITERATION 2+
ITERATION 2+
RSpec in json format
Send each test result
to sensu socket
Report summary serverspec results
to back to sensu defined check
Iterate over rspec results
ITERATION 2+
Summary results Individual test failures
SUMMARY
1. Write tests for your systems
2. Don’t duplicate effort.
3. Run your tests via a monitoring tool
THANK YOU
Michael Richardson - @m_richo
https://github.com/m-richo/sensu_check-rspec

Serverspec and Sensu - Testing and Monitoring collide