Upload
garrett-honeycutt
View
196
Download
2
Embed Size (px)
DESCRIPTION
Why TDD Works for Sysadmins - Presented 2014-11-14 at LISA in Seattle.
Citation preview
Garrett Honeycutt [email protected]
learnpuppet.com @learnpuppet
Garrett Honeycutt [email protected] learnpuppet.com @learnpuppet
TDD?
Why Test?
DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS! DEVELOPERS!
Why Test First?
What to Test?
Tooling
require 'spec_helper' !
describe package('httpd') do it { should be_installed } end !
describe service('httpd') do it { should be_enabled } it { should be_running } end !
describe port(80) do it { should be_listening } end
$ rake spec !
Package "httpd" should be installed !
Service "httpd" should be enabled should be running !
Port "80" should be listening !
4 examples, 0 failures
Monitoring
$ ping -c1 example.com PING example.com (93.184.216.119): 56 data bytes 64 bytes from 93.184.216.119: icmp_seq=0 ttl=58 time=4.947 ms !
--- example.com ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 4.947/4.947/4.947/0.000 ms
$ curl example.com -I HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: max-age=604800 Content-Type: text/html Date: Thu, 13 Nov 2014 03:52:15 GMT Etag: "359670651" Expires: Thu, 20 Nov 2014 03:52:15 GMT Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT Server: ECS (pae/3796) X-Cache: HIT x-ec-custom-error: 1 Content-Length: 1270
write tests (which fail)
just enough code to pass
refactor
Garrett Honeycutt [email protected]
learnpuppet.com @learnpuppet